AppController/djinn.rb
# Searches through @nodes to try to find out which node is ours. Strictly
# speaking, we assume that our node is identifiable by private IP, but
# we also check our public IPs (for AWS and GCE) in case the user got it
# wrong.
Searches through @nodes to try to find out which node is ours. Strictly
speaking, we assume that our node is identifiable by private IP, but
we also check our public IPs (for AWS and GCE) in case the user got it
wrong.
Searches through @nodes to try to find out which node is ours . Strictly speaking we assume that our node is identifiable by private IP but we also check our public IPs ( for AWS and GCE ) in case the user got it wrong .
def find_me_in_locations()
    @my_index = nil
    all_local_ips = HelperFunctions.get_all_local_ips()
    Djinn.log_debug("Searching for a node with any of these private IPs: " +
      "#{all_local_ips.join(', ')}")
    Djinn.log_debug("All nodes are: #{@nodes.join(', ')}")
    @nodes.each_with_index { |node, index|
      all_local_ips.each_with_index { |ip, eth_interface|
        if ip == node.private_ip
          @my_index = index
          HelperFunctions.set_local_ip(node.private_ip)
          @my_public_ip = node.public_ip
          @my_private_ip = node.private_ip
          @eth_interface = eth_interface
          return
        end
      }
    }
    public_ip = HelperFunctions.get_public_ip_from_metadata_service()
    @nodes.each { |node|
      if node.private_ip == public_ip
        HelperFunctions.log_and_crash("Found my public ip (#{public_ip}) " +
            "but not my private ip in @nodes. Please correct it. @nodes=#{@nodes}")
      end
      if node.public_ip == public_ip
        HelperFunctions.log_and_crash("Found my public ip (#{public_ip}) " +
            "in @nodes but my private ip is not matching! @nodes=#{@nodes}.")
      end
    }
    HelperFunctions.log_and_crash("Can't find my node in @nodes: #{@nodes}. " +
      "My local IPs are: #{all_local_ips.join(', ')}")
  end
def find_me_in_locations ( ) @my_index = nil all_local_ips = HelperFunctions . get_all_local_ips ( ) Djinn . log_debug ( "Searching for a node with any of these private IPs: " + "#{all_local_ips.join(', ')}" ) Djinn . log_debug ( "All nodes are: #{@nodes.join(', ')}" ) @nodes . each_with_index { | node , index | all_local_ips . each_with_index { | ip , eth_interface | if ip == node . private_ip @my_index = index HelperFunctions . set_local_ip ( node . private_ip ) @my_public_ip = node . public_ip @my_private_ip = node . private_ip @eth_interface = eth_interface return end } } public_ip = HelperFunctions . get_public_ip_from_metadata_service ( ) @nodes . each { | node | if node . private_ip == public_ip HelperFunctions . log_and_crash ( "Found my public ip (#{public_ip}) " + "but not my private ip in @nodes. Please correct it. @nodes=#{@nodes}" ) end if node . public_ip == public_ip HelperFunctions . log_and_crash ( "Found my public ip (#{public_ip}) " + "in @nodes but my private ip is not matching! @nodes=#{@nodes}." ) end } HelperFunctions . log_and_crash ( "Can't find my node in @nodes: #{@nodes}. " + "My local IPs are: #{all_local_ips.join(', ')}" ) end
Searches through @nodes to try to find out which node is ours.
Searches through @nodes to try to find out which node is ours .
# We haven't found our ip in the nodes layout: let's try to give # better debugging info to the user.