def getListDict(user):
machines = [m for m in Machine.select()
if validation.haveAccess(user, m)]
- #if user == 'moo':
- # machines = Machine.select()
- #else:
- # machines = Machine.query().join('users').filter_by(user=user).all()
checkpoint.checkpoint('Got my machines')
on = {}
has_vnc = {}
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.
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:
def getUser():
"""Return the current user based on the SSL environment variables"""
- if 'SSL_CLIENT_S_DN_Email' in os.environ:
- username = os.environ['SSL_CLIENT_S_DN_Email'].split("@")[0]
- return username
- else:
- return 'moo'
+ username = os.environ['SSL_CLIENT_S_DN_Email'].split("@")[0]
+ return username
def main(operation, user, fields):
start_time = time.time()
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)