minor bugfix, and check not reusing names.
[invirt/packages/invirt-web.git] / templates / main.py
index 36ea239..bf40069 100755 (executable)
@@ -583,7 +583,10 @@ def testDisk(user, disksize, machine=None):
     return disksize
 
 def testName(user, name, machine=None):
-    return name
+    if Machine.select_by(name=name) == []:
+        return name
+    raise InvalidInput('name', name,
+                       "Already taken")
 
 def testHostname(user, hostname, machine):
     for nic in machine.nics:
@@ -640,6 +643,7 @@ def modify(user, fields):
         transaction.commit()
     except:
         transaction.rollback()
+        raise
     remctl("web", "moveregister", oldname, name)
     for disk in machine.disks:
         # XXX all disks get the same size on change?  Interface doesn't support more.