'&simple=true" target="_blank" ' +
'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>')
-class User:
- """User class (sort of useless, I admit)"""
- def __init__(self, username, email):
- self.username = username
- self.email = email
-
def makeErrorPre(old, addition):
if addition is None:
return
raise InvalidInput('name', name,
"Name already exists.")
+ owner = validation.testOwner(user, fields.getfirst('owner'))
+
memory = fields.getfirst('memory')
memory = validation.validMemory(user, memory, on=True)
cdrom = fields.getfirst('cdrom')
if cdrom is not None and not CDROM.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
- return dict(user=user, name=name, memory=memory, disk=disk,
- is_hvm=is_hvm, cdrom=cdrom)
+ return dict(contact=user, name=name, memory=memory, disk=disk,
+ owner=owner, is_hvm=is_hvm, cdrom=cdrom)
def create(user, fields):
"""Handler for create requests."""
max_disk = validation.maxDisk(user)
defaults = Defaults(max_memory=max_memory,
max_disk=max_disk,
+ owner=user,
cdrom='gutsy-i386')
d = dict(user=user,
cant_add_vm=validation.cantAddVm(user),
TOKEN_KEY = "0M6W0U1IXexThi5idy8mnkqPKEq1LtEnlK/pZSn0cDrN"
data = {}
- data["user"] = user.username
+ data["user"] = user
data["machine"] = machine.name
data["expires"] = time.time()+(5*60)
pickled_data = cPickle.dumps(data)
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:
name = disk.guest_device_name
disk_fields.extend([(x % name, y % name) for x, y in
disk_fields_template])
- data_dict['%s_size' % name] = "%0.1f GB" % (disk.size / 1024.)
+ data_dict['%s_size' % name] = "%0.1f GiB" % (disk.size / 1024.)
return disk_fields
def command(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"
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:
display_fields = (display_fields[:disk_point] + disk_fields +
display_fields[disk_point+1:])
- main_status['memory'] += ' MB'
+ main_status['memory'] += ' MiB'
for field, disp in display_fields:
if field in ('uptime', 'cputime') and locals()[field] is not None:
fields.append((disp, locals()[field]))
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(),
"""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 User(username, os.environ['SSL_CLIENT_S_DN_Email'])
+ return username
else:
- return User('moo', 'nobody')
+ return 'moo'
def main(operation, user, fields):
fun = mapping.get(operation, badOperation)