class_docstr: Interface for getting and returning nodes from a Cloud.
  
  **Important**: This is an INTERNAL API that is only exposed for the purpose
  of implementing custom node providers. It is not allowed to call into
  NodeProvider methods from any Ray package outside the autoscaler, only to
  define new implementations of NodeProvider for use with the "external" node
  provider option.
  
  NodeProviders are namespaced by the `cluster_name` parameter; they only
  operate on nodes within that namespace.
  
  Nodes may be in one of three states: {pending, running, terminated}. Nodes
  appear immediately once started by `create_node`, and transition
  immediately to terminated when `terminate_node` is called.
class_docstr_tok: ["Interface","for","getting","and","returning","nodes","from","a","Cloud",".","*","*","Important","*","*",":","This","is","an","INTERNAL","API","that","is","only","exposed","for","the","purpose","of","implementing","custom","node","providers",".","It","is","not","allowed","to","call","into","NodeProvider","methods","from","any","Ray","package","outside","the","autoscaler",",","only","to","define","new","implementations","of","NodeProvider","for","use","with","the","``","external","''","node","provider","option",".","NodeProviders","are","namespaced","by","the","`","cluster_name","`","parameter",";","they","only","operate","on","nodes","within","that","namespace",".","Nodes","may","be","in","one","of","three","states",":","{","pending",",","running",",","terminated","}",".","Nodes","appear","immediately","once","started","by","`","create_node","`",",","and","transition","immediately","to","terminated","when","`","terminate_node","`","is","called","."]
docstr: Returns the node_id given an IP address.
  
  Assumes ip-address is unique per node.
  
  Args:
      ip_address: Address of node.
      use_internal_ip: Whether the ip address is
          public or private.
  
  Raises:
      ValueError if not found.
docstr_tok: ["Returns","the","node_id","given","an","IP","address",".","Assumes","ip-address","is","unique","per","node",".","Args",":","ip_address",":","Address","of","node",".","use_internal_ip",":","Whether","the","ip","address","is","public","or","private",".","Raises",":","ValueError","if","not","found","."]
code: def get_node_id(
      self, ip_address: str, use_internal_ip: bool = False
  ) -> str:
      """Returns the node_id given an IP address.
  
      Assumes ip-address is unique per node.
  
      Args:
          ip_address: Address of node.
          use_internal_ip: Whether the ip address is
              public or private.
  
      Raises:
          ValueError if not found.
      """
  
      def find_node_id():
          if use_internal_ip:
              return self._internal_ip_cache.get(ip_address)
          else:
              return self._external_ip_cache.get(ip_address)
  
      if not find_node_id():
          all_nodes = self.non_terminated_nodes({})
          ip_func = (
              self.internal_ip if use_internal_ip else self.external_ip
          )
          ip_cache = (
              self._internal_ip_cache
              if use_internal_ip
              else self._external_ip_cache
          )
          for node_id in all_nodes:
              ip_cache[ip_func(node_id)] = node_id
  
      if not find_node_id():
          if use_internal_ip:
              known_msg = f"Worker internal IPs: {list(self._internal_ip_cache)}"
          else:
              known_msg = (
                  f"Worker external IP: {list(self._external_ip_cache)}"
              )
          raise ValueError(f"ip {ip_address} not found. " + known_msg)
  
      return find_node_id()
  
imports: import logging
  from types import ModuleType
  from typing import Any, Dict, List, Optional
  from ray.autoscaler._private.command_runner import DockerCommandRunner, SSHCommandRunner
  from ray.autoscaler.command_runner import CommandRunnerInterface
  from ray.util.annotations import DeveloperAPI
label_desc: Use image node_id 9 for calling the NodeProvider obj's underlying member method code with example usage: obj.get_node_id(ip_address, use_internal_ip) and returns: find_node_id, self, self