Revision 7fbb1f65

b/lib/utils.py
756 756
  """Sets the name of an IP address and hostname in /etc/hosts.
757 757

  
758 758
  """
759
  # Ensure aliases are unique
760
  aliases = UniqueSequence([hostname] + aliases)[1:]
761

  
759 762
  fd, tmpname = tempfile.mkstemp(dir=os.path.dirname(file_name))
760 763
  try:
761 764
    out = os.fdopen(fd, 'w')
b/test/ganeti.utils_unittest.py
456 456
      "127.0.0.1\tlocalhost\n"
457 457
      "192.168.1.1\tmyhost.domain.tld myhost\n")
458 458

  
459
  def testSettingDuplicateName(self):
460
    SetEtcHostsEntry(self.tmpname, '1.2.3.4', 'myhost', ['myhost'])
461

  
462
    self.assertFileContent(self.tmpname,
463
      "# This is a test file for /etc/hosts\n"
464
      "127.0.0.1\tlocalhost\n"
465
      "192.168.1.1 router gw\n"
466
      "1.2.3.4\tmyhost\n")
467

  
459 468
  def testRemovingExistingHost(self):
460 469
    RemoveEtcHostsEntry(self.tmpname, 'router')
461 470

  

Also available in: Unified diff