Revision 56e4c4a0

b/lib/utils.py
1794 1794
def OwnIpAddress(address):
1795 1795
  """Check if the current host has the the given IP address.
1796 1796

  
1797
  Currently this is done by TCP-pinging the address from the loopback
1798
  address.
1797
  This is done by trying to bind the given address. We return True if we
1798
  succeed or false if a socket.error is raised.
1799 1799

  
1800 1800
  @type address: string
1801 1801
  @param address: the address to check
......
1803 1803
  @return: True if we own the address
1804 1804

  
1805 1805
  """
1806
  return TcpPing(address, constants.DEFAULT_NODED_PORT,
1807
                 source=constants.IP4_ADDRESS_LOCALHOST)
1806
  family = GetAddressFamily(address)
1807
  s = socket.socket(family, socket.SOCK_DGRAM)
1808
  success = False
1809
  try:
1810
    s.bind((address, 0))
1811
    success = True
1812
  except socket.error:
1813
    success = False
1814
  finally:
1815
    s.close()
1816
  return success
1808 1817

  
1809 1818

  
1810 1819
def ListVisibleFiles(path):

Also available in: Unified diff