Changeset 134
- Timestamp:
- Oct 8, 2007, 2:17:26 AM (17 years ago)
- Location:
- trunk/web/templates
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/templates/create.tmpl
r113 r134 13 13 <p>Odd... no error, but no machine.</p> 14 14 #end if 15 <p><a href="list">Return</a></p> 15 16 #end def -
trunk/web/templates/main.py
r133 r134 213 213 return machine 214 214 215 def create(user, fields): 216 name = fields.getfirst('name') 217 if not validMachineName(name): 218 raise MyException("Invalid name '%s'" % name) 219 name = user.username + '_' + name.lower() 220 221 if Machine.get_by(name=name): 222 raise MyException("A machine named '%s' already exists" % name) 223 224 memory = fields.getfirst('memory') 215 def validMemory(user, memory, machine=None): 225 216 try: 226 217 memory = int(memory) … … 229 220 except ValueError: 230 221 raise MyException("Invalid memory amount") 231 if memory > maxMemory(user ):222 if memory > maxMemory(user, machine): 232 223 raise MyException("Too much memory requested") 233 234 disk = fields.getfirst('disk') 224 return memory 225 226 def validDisk(user, disk, machine=None): 235 227 try: 236 228 disk = float(disk) 237 if disk > maxDisk(user ):229 if disk > maxDisk(user, machine): 238 230 raise MyException("Too much disk requested") 239 231 disk = int(disk * 1024) … … 242 234 except ValueError: 243 235 raise MyException("Invalid disk amount") 244 236 return disk 237 238 def create(user, fields): 239 name = fields.getfirst('name') 240 if not validMachineName(name): 241 raise MyException("Invalid name '%s'" % name) 242 name = user.username + '_' + name.lower() 243 244 if Machine.get_by(name=name): 245 raise MyException("A machine named '%s' already exists" % name) 246 247 memory = fields.getfirst('memory') 248 memory = validMemory(user, memory) 249 250 disk = fields.getfirst('disk') 251 disk = validDisk(user, disk) 252 245 253 vm_type = fields.getfirst('vmtype') 246 254 if vm_type not in ('hvm', 'paravm'):
Note: See TracChangeset
for help on using the changeset viewer.