X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/77269356e0e57b5e35fec45eb5fa235dfcc821d5..31a80e557fe527ec94c3a490b4b6bd73a4fd9af5:/main.py?ds=sidebyside diff --git a/main.py b/main.py index d4ae1c5..e182095 100755 --- a/main.py +++ b/main.py @@ -274,6 +274,15 @@ def vnc(user, fields): authtoken=token) return templates.vnc(searchList=[d]) +def getHostname(nic): + if nic.hostname and '.' in nic.hostname: + return nic.hostname + elif nic.machine: + return nic.machine.name + '.servers.csail.mit.edu' + else: + return None + + def getNicInfo(data_dict, machine): """Helper function for info, get data on nics for a machine. @@ -289,8 +298,7 @@ def getNicInfo(data_dict, machine): for i in range(len(machine.nics)): nic_fields.extend([(x % i, y % i) for x, y in nic_fields_template]) if not i: - data_dict['nic%s_hostname' % i] = (machine.name + - '.servers.csail.mit.edu') + data_dict['nic%s_hostname' % i] = getHostname(machine.nics[i]) 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: @@ -640,7 +648,8 @@ if __name__ == '__main__': if not operation: operation = 'list' - main(operation, u, fields) - #import profile - #profile.run('main(operation, u, fields)', 'log-'+operation) - + if os.getenv("SIPB_XEN_PROFILE"): + import profile + profile.run('main(operation, u, fields)', 'log-'+operation) + else: + main(operation, u, fields)