+ """Handler for modifying attributes of a machine."""
+
+ olddisk = {}
+ transaction = ctx.current.create_transaction()
+ try:
+ machine = testMachineId(user, fields.getfirst('machine_id'))
+ owner = testOwner(user, fields.getfirst('owner'), machine)
+ contact = testContact(user, fields.getfirst('contact'))
+ hostname = testHostname(owner, fields.getfirst('hostname'),
+ machine)
+ name = testName(user, fields.getfirst('name'), machine)
+ oldname = machine.name
+ command="modify"
+
+ memory = fields.getfirst('memory')
+ if memory is not None:
+ memory = validMemory(user, memory, machine, on=False)
+ machine.memory = memory
+
+ disksize = testDisk(user, fields.getfirst('disk'))
+ if disksize is not None:
+ disksize = validDisk(user, disksize, machine)
+ disk = machine.disks[0]
+ if disk.size != disksize:
+ olddisk[disk.guest_device_name] = disksize
+ 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 and owner != machine.owner:
+ machine.owner = owner
+ if name is not None and name != machine.name:
+ machine.name = name
+
+ ctx.current.save(machine)
+ transaction.commit()
+ except:
+ transaction.rollback()
+ raise
+ for diskname in olddisk:
+ remctl("web", "lvresize", oldname, diskname, str(olddisk[diskname]))
+ if name is not None and name != oldname:
+ for disk in machine.disks:
+ if oldname != name:
+ remctl("web", "lvrename", oldname, disk.guest_device_name, name)
+ remctl("web", "moveregister", oldname, name)
+ d = dict(user=user,
+ command=command,
+ machine=machine)
+ return Template(file="command.tmpl", searchList=[d, global_dict])
+
+
+def help(user, fields):
+ """Handler for help messages."""
+ simple = fields.getfirst('simple')
+ subjects = fields.getlist('subject')
+
+ mapping = dict(paravm_console="""
+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.""",
+ hvm_paravm="""
+HVM machines use the virtualization features of the processor, while
+ParaVM machines use Xen's emulation of virtualization features. You
+want an HVM virtualized machine.""",
+ cpu_weight="""Don't ask us! We're as mystified as you are.""",
+ owner="""The Owner 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.)""")
+
+ d = dict(user=user,
+ simple=simple,
+ subjects=subjects,
+ mapping=mapping)
+
+ return Template(file="help.tmpl", searchList=[d, global_dict])