Add "renumber" to the list of valid commands.
[invirt/packages/invirt-web.git] / code / controls.py
index a5f1693..c9193cb 100644 (file)
@@ -223,12 +223,13 @@ def deleteVM(machine):
 
 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)    
-    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:
@@ -274,10 +275,14 @@ def commandResult(username, state, command_name, machine_id, fields):
                 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)
+    if result:
+        d['result'] = result
     return d
 
 def resizeDisk(machine_name, disk_name, new_size):