help._cp_config['tools.require_login.on'] = False
def parseCreate(self, fields):
- kws = dict([(kw, fields.get(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split() if fields.get(kw)])
- validate = validation.Validate(cherrypy.request.login, cherrypy.request.state, strict=True, **kws)
- return dict(contact=cherrypy.request.login, name=validate.name, description=validate.description, memory=validate.memory,
- disksize=validate.disksize, owner=validate.owner, machine_type=getattr(validate, 'vmtype', Defaults.type),
+ kws = dict([(kw, fields.get(kw)) for kw in
+ 'name description owner memory disksize vmtype cdrom autoinstall'.split()
+ if fields.get(kw)])
+ validate = validation.Validate(cherrypy.request.login,
+ cherrypy.request.state,
+ strict=True, **kws)
+ return dict(contact=cherrypy.request.login, name=validate.name,
+ description=validate.description, memory=validate.memory,
+ disksize=validate.disksize, owner=validate.owner,
+ machine_type=getattr(validate, 'vmtype', Defaults.type),
cdrom=getattr(validate, 'cdrom', None),
autoinstall=getattr(validate, 'autoinstall', None))
"""Handler for create requests."""
try:
parsed_fields = self.parseCreate(fields)
- machine = controls.createVm(cherrypy.request.login, cherrypy.request.state, **parsed_fields)
+ machine = controls.createVm(cherrypy.request.login,
+ cherrypy.request.state, **parsed_fields)
except InvalidInput, err:
pass
else:
@cherrypy.tools.mako(filename="/info.mako")
def info(self, machine_id):
"""Handler for info on a single VM."""
- machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+ machine = validation.Validate(cherrypy.request.login,
+ cherrypy.request.state,
+ machine_id=machine_id).machine
d = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
checkpoint.checkpoint('Got infodict')
return d
def modify(self, machine_id, **fields):
"""Handler for modifying attributes of a machine."""
try:
- modify_dict = modifyDict(cherrypy.request.login, cherrypy.request.state, machine_id, fields)
+ modify_dict = modifyDict(cherrypy.request.login,
+ cherrypy.request.state,
+ machine_id, fields)
except InvalidInput, err:
result = None
- machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+ machine = validation.Validate(cherrypy.request.login,
+ cherrypy.request.state,
+ machine_id=machine_id).machine
else:
machine = modify_dict['machine']
result = 'Success!'
err = None
- info_dict = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
+ info_dict = infoDict(cherrypy.request.login,
+ cherrypy.request.state, machine)
info_dict['err'] = err
if err:
for field in fields.keys():
Remember to enable iptables!
echo 1 > /proc/sys/net/ipv4/ip_forward
"""
- machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
-
+ machine = validation.Validate(cherrypy.request.login,
+ cherrypy.request.state,
+ machine_id=machine_id).machine
token = controls.vnctoken(machine)
host = controls.listHost(machine)
if host:
"""Handler for running commands like boot and delete on a VM."""
back = kwargs.get('back', None)
try:
- d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs)
+ d = controls.commandResult(cherrypy.request.login,
+ cherrypy.request.state,
+ command_name, machine_id, kwargs)
if d['command'] == 'Delete VM':
back = 'list'
except InvalidInput, err:
return d
if back == 'list':
cherrypy.request.state.clear() #Changed global state
- raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result))
+ raise cherrypy.InternalRedirect('/list?result=%s'
+ % urllib.quote(result))
elif back == 'info':
- raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303)
+ raise cherrypy.HTTPRedirect(cherrypy.request.base
+ + '/machine/%d/' % machine_id,
+ status=303)
else:
raise InvalidInput('back', back, 'Not a known back page.')
olddisk = {}
session.begin()
try:
- kws = dict([(kw, fields.get(kw)) for kw in 'owner admin contact name description memory vmtype disksize'.split() if fields.get(kw)])
+ kws = dict([(kw, fields.get(kw)) for kw in
+ 'owner admin contact name description memory vmtype disksize'.split()
+ if fields.get(kw)])
kws['machine_id'] = machine_id
validate = validation.Validate(username, state, **kws)
machine = validate.machine