Remove the hostname as separate from machine name.
[invirt/packages/invirt-web.git] / templates / main.py
index cc8c3d8..7e92c8b 100755 (executable)
@@ -258,15 +258,16 @@ def getNicInfo(data_dict, machine):
     of (key, name) pairs to display "name: data_dict[key]" to the user.
     """
     data_dict['num_nics'] = len(machine.nics)
-    nic_fields_template = [('nic%s_hostname', 'NIC %s hostname'),
+    nic_fields_template = [('nic%s_hostname', 'NIC %s Hostname'),
                            ('nic%s_mac', 'NIC %s MAC Addr'),
                            ('nic%s_ip', 'NIC %s IP'),
                            ]
     nic_fields = []
     for i in range(len(machine.nics)):
         nic_fields.extend([(x % i, y % i) for x, y in nic_fields_template])
-        data_dict['nic%s_hostname' % i] = (machine.nics[i].hostname + 
-                                           '.servers.csail.mit.edu')
+        if not i:
+            data_dict['nic%s_hostname' % i] = (machine.name + 
+                                               '.servers.csail.mit.edu')
         data_dict['nic%s_mac' % i] = machine.nics[i].mac_addr
         data_dict['nic%s_ip' % i] = machine.nics[i].ip
     if len(machine.nics) == 1:
@@ -328,8 +329,6 @@ def modifyDict(user, fields):
                                      machine)
         contact = validation.testContact(user, fields.getfirst('contact'),
                                          machine)
-        hostname = validation.testHostname(owner, fields.getfirst('hostname'),
-                                           machine)
         name = validation.testName(user, fields.getfirst('name'), machine)
         oldname = machine.name
         command = "modify"
@@ -348,12 +347,6 @@ def modifyDict(user, fields):
                 disk.size = disksize
                 ctx.current.save(disk)
         
-        # XXX first NIC gets hostname on change?  
-        # Interface doesn't support more.
-        for nic in machine.nics[:1]:
-            nic.hostname = hostname
-            ctx.current.save(nic)
-
         if owner is not None:
             machine.owner = owner
         if name is not None:
@@ -512,8 +505,6 @@ def infoDict(user, machine):
     defaults = Defaults()
     for name in 'machine_id name administrator owner memory contact'.split():
         setattr(defaults, name, getattr(machine, name))
-    if machine.nics:
-        defaults.hostname = machine.nics[0].hostname
     defaults.disk = "%0.2f" % (machine.disks[0].size/1024.)
     d = dict(user=user,
              cdroms=CDROM.select(),