-from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess
+import sipb_xen_database
+from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type
- return ('<span class="helplink"><a href="help?subject=' + subj +
- '&simple=true" target="_blank" ' +
+ return ('<span class="helplink"><a href="help?subject=' + subj +
+ '&simple=true" target="_blank" ' +
'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>')
def makeErrorPre(old, addition):
'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>')
def makeErrorPre(old, addition):
def __init__(self, max_memory=None, max_disk=None, **kws):
def __init__(self, max_memory=None, max_disk=None, **kws):
if max_memory is not None:
self.memory = min(self.memory, max_memory)
if max_disk is not None:
if max_memory is not None:
self.memory = min(self.memory, max_memory)
if max_disk is not None:
if Machine.get_by(name=name):
raise InvalidInput('name', name,
"Name already exists.")
if Machine.get_by(name=name):
raise InvalidInput('name', name,
"Name already exists.")
owner = validation.testOwner(user, fields.getfirst('owner'))
memory = fields.getfirst('memory')
memory = validation.validMemory(owner, memory, on=True)
owner = validation.testOwner(user, fields.getfirst('owner'))
memory = fields.getfirst('memory')
memory = validation.validMemory(owner, memory, on=True)
disk_size = fields.getfirst('disk')
disk_size = validation.validDisk(owner, disk_size)
vm_type = fields.getfirst('vmtype')
disk_size = fields.getfirst('disk')
disk_size = validation.validDisk(owner, disk_size)
vm_type = fields.getfirst('vmtype')
- if vm_type not in ('hvm', 'paravm'):
- raise CodeError("Invalid vm type '%s'" % vm_type)
- is_hvm = (vm_type == 'hvm')
+ vm_type = validation.validVmType(vm_type)
clone_from = fields.getfirst('clone_from')
if clone_from and clone_from != 'ice3':
raise CodeError("Invalid clone image '%s'" % clone_from)
clone_from = fields.getfirst('clone_from')
if clone_from and clone_from != 'ice3':
raise CodeError("Invalid clone image '%s'" % clone_from)
return dict(contact=user, name=name, memory=memory, disk_size=disk_size,
return dict(contact=user, name=name, memory=memory, disk_size=disk_size,
- owner=owner, is_hvm=is_hvm, cdrom=cdrom, clone_from=clone_from)
+ owner=owner, machine_type=vm_type, cdrom=cdrom, clone_from=clone_from)
def create(user, fields):
"""Handler for create requests."""
def create(user, fields):
"""Handler for create requests."""
echo 1 > /proc/sys/net/ipv4/ip_forward
"""
machine = validation.testMachineId(user, fields.getfirst('machine_id'))
echo 1 > /proc/sys/net/ipv4/ip_forward
"""
machine = validation.testMachineId(user, fields.getfirst('machine_id'))
token = {'data': pickled_data, 'digest': m.digest()}
token = cPickle.dumps(token)
token = base64.urlsafe_b64encode(token)
token = {'data': pickled_data, 'digest': m.digest()}
token = cPickle.dumps(token)
token = base64.urlsafe_b64encode(token)
raise InvalidInput('back', back, 'Not a known back page.')
def modifyDict(user, fields):
raise InvalidInput('back', back, 'Not a known back page.')
def modifyDict(user, fields):
if memory is not None:
memory = validation.validMemory(user, memory, machine, on=False)
machine.memory = memory
if memory is not None:
memory = validation.validMemory(user, memory, machine, on=False)
machine.memory = memory
disksize = validation.testDisk(user, fields.getfirst('disk'))
if disksize is not None:
disksize = validation.validDisk(user, disksize, machine)
disksize = validation.testDisk(user, fields.getfirst('disk'))
if disksize is not None:
disksize = validation.validDisk(user, disksize, machine)
def modify(user, fields):
"""Handler for modifying attributes of a machine."""
try:
def modify(user, fields):
"""Handler for modifying attributes of a machine."""
try:
setattr(info_dict['defaults'], field, fields.getfirst(field))
info_dict['result'] = result
return templates.info(searchList=[info_dict])
setattr(info_dict['defaults'], field, fields.getfirst(field))
info_dict['result'] = result
return templates.info(searchList=[info_dict])
def helpHandler(user, fields):
"""Handler for help messages."""
simple = fields.getfirst('simple')
subjects = fields.getlist('subject')
def helpHandler(user, fields):
"""Handler for help messages."""
simple = fields.getfirst('simple')
subjects = fields.getlist('subject')
-ParaVM machines do not support console access over VNC. To access
-these machines, you either need to boot with a liveCD and ssh in or
-hope that the sipb-xen maintainers add support for serial consoles.""",
+ParaVM machines do not support local console access over VNC. To
+access the serial console of these machines, you can SSH with Kerberos
+to sipb-xen-console.mit.edu, using the name of the machine as your
+username.""",
hvm_paravm="""
HVM machines use the virtualization features of the processor, while
ParaVM machines use Xen's emulation of virtualization features. You
hvm_paravm="""
HVM machines use the virtualization features of the processor, while
ParaVM machines use Xen's emulation of virtualization features. You
href="help?subject=quotas">quotas</a>. It must be the name of a
locker that you are an AFS administrator of. In particular, you or an
AFS group you are a member of must have AFS rlidwka bits on the
href="help?subject=quotas">quotas</a>. It must be the name of a
locker that you are an AFS administrator of. In particular, you or an
AFS group you are a member of must have AFS rlidwka bits on the
-locker. You can check see who administers the LOCKER locker using the
-command 'fs la /mit/LOCKER' on Athena.) See also <a
+locker. You can check who administers the LOCKER locker using the
+commands 'attach LOCKER; fs la /mit/LOCKER' on Athena.) See also <a
href="help?subject=administrator">administrator</a>.""",
administrator="""
The administrator field determines who can access the console and
href="help?subject=administrator">administrator</a>.""",
administrator="""
The administrator field determines who can access the console and
raise CodeError("Unknown operation")
def infoDict(user, machine):
raise CodeError("Unknown operation")
def infoDict(user, machine):
nic_fields = getNicInfo(machine_info, machine)
nic_point = display_fields.index('NIC_INFO')
nic_fields = getNicInfo(machine_info, machine)
nic_point = display_fields.index('NIC_INFO')
display_fields[nic_point+1:])
disk_fields = getDiskInfo(machine_info, machine)
disk_point = display_fields.index('DISK_INFO')
display_fields[nic_point+1:])
disk_fields = getDiskInfo(machine_info, machine)
disk_point = display_fields.index('DISK_INFO')
main_status['memory'] += ' MiB'
for field, disp in display_fields:
if field in ('uptime', 'cputime') and locals()[field] is not None:
main_status['memory'] += ' MiB'
for field, disp in display_fields:
if field in ('uptime', 'cputime') and locals()[field] is not None:
checkpoint.checkpoint('Got mem')
max_disk = validation.maxDisk(user, machine)
defaults = Defaults()
checkpoint.checkpoint('Got mem')
max_disk = validation.maxDisk(user, machine)
defaults = Defaults()
setattr(defaults, name, getattr(machine, name))
defaults.disk = "%0.2f" % (machine.disks[0].size/1024.)
checkpoint.checkpoint('Got defaults')
setattr(defaults, name, getattr(machine, name))
defaults.disk = "%0.2f" % (machine.disks[0].size/1024.)
checkpoint.checkpoint('Got defaults')
for key, value in headers.iteritems():
print '%s: %s' % (key, value)
print
for key, value in headers.iteritems():
print '%s: %s' % (key, value)
print