projects
/
invirt/packages/invirt-web.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add "renumber" to the list of valid commands.
[invirt/packages/invirt-web.git]
/
code
/
controls.py
diff --git
a/code/controls.py
b/code/controls.py
index
0acca3a
..
c9193cb
100644
(file)
--- a/
code/controls.py
+++ b/
code/controls.py
@@
-94,7
+94,7
@@
def bootMachine(machine, cdtype):
raise CodeError('"%s" on "control %s create %s'
% (err, machine.name, cdtype))
raise CodeError('"%s" on "control %s create %s'
% (err, machine.name, cdtype))
-def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, nic_type, cdrom, autoinstall):
+def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, autoinstall):
"""Create a VM and put it in the database"""
# put stuff in the table
session.begin()
"""Create a VM and put it in the database"""
# put stuff in the table
session.begin()
@@
-119,7
+119,6
@@
def createVm(username, state, owner, contact, name, description, memory, disksiz
"Contact %s." % config.contact)
nic.machine = machine
nic.hostname = name
"Contact %s." % config.contact)
nic.machine = machine
nic.hostname = name
- nic.nic_type = nic_type
session.add(nic)
session.add(disk)
cache_acls.refreshMachine(machine)
session.add(nic)
session.add(disk)
cache_acls.refreshMachine(machine)
@@
-224,12
+223,13
@@
def deleteVM(machine):
def commandResult(username, state, command_name, machine_id, fields):
start_time = 0
def commandResult(username, state, command_name, machine_id, fields):
start_time = 0
+ result = None
machine = validation.Validate(username, state, machine_id=machine_id).machine
action = command_name
cdrom = fields.get('cdrom') or None
if cdrom is not None and not CDROM.query.filter_by(cdrom_id=cdrom).one():
raise CodeError("Invalid cdrom type '%s'" % cdrom)
machine = validation.Validate(username, state, machine_id=machine_id).machine
action = command_name
cdrom = fields.get('cdrom') or None
if cdrom is not None and not CDROM.query.filter_by(cdrom_id=cdrom).one():
raise CodeError("Invalid cdrom type '%s'" % cdrom)
- if action not in "reboot create destroy shutdown delete".split(" "):
+ if action not in "reboot create destroy shutdown delete renumber".split(" "):
raise CodeError("Invalid action '%s'" % action)
if action == 'reboot':
if cdrom is not None:
raise CodeError("Invalid action '%s'" % action)
if action == 'reboot':
if cdrom is not None:
@@
-275,10
+275,14
@@
def commandResult(username, state, command_name, machine_id, fields):
raise CodeError('ERROR on remctl')
elif action == 'delete':
deleteVM(machine)
raise CodeError('ERROR on remctl')
elif action == 'delete':
deleteVM(machine)
+ elif action == 'renumber':
+ result = remctl('control', machine.name, 'renumber')
d = dict(user=username,
command=action,
machine=machine)
d = dict(user=username,
command=action,
machine=machine)
+ if result:
+ d['result'] = result
return d
def resizeDisk(machine_name, disk_name, new_size):
return d
def resizeDisk(machine_name, disk_name, new_size):