Changeset 609 for trunk/packages/sipb-xen-www
- Timestamp:
- Jun 18, 2008, 3:50:31 AM (17 years ago)
- Location:
- trunk/packages/sipb-xen-www/code
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/controls.py
r589 r609 93 93 % (err, machine.name, cdtype)) 94 94 95 def createVm(username, state, owner, contact, name, memory, disksize, machine_type, cdrom, clone_from):95 def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, clone_from): 96 96 """Create a VM and put it in the database""" 97 97 # put stuff in the table 98 98 transaction = ctx.current.create_transaction() 99 99 try: 100 validation.Validate(username, state, name=name, owner=owner, memory=memory, disksize=disksize/1024.)100 validation.Validate(username, state, name=name, description=description, owner=owner, memory=memory, disksize=disksize/1024.) 101 101 res = meta.engine.execute('select nextval(' 102 102 '\'"machines_machine_id_seq"\')') … … 105 105 machine.machine_id = id 106 106 machine.name = name 107 machine.description = description 107 108 machine.memory = memory 108 109 machine.owner = owner -
trunk/packages/sipb-xen-www/code/main.py
r607 r609 104 104 autoinstall = '' 105 105 name = '' 106 description = '' 106 107 type = 'linux-hvm' 107 108 … … 136 137 137 138 def parseCreate(username, state, fields): 138 kws = dict([(kw, fields.getfirst(kw)) for kw in 'name owner memory disksize vmtype cdrom clone_from'.split()])139 kws = dict([(kw, fields.getfirst(kw)) for kw in 'name description owner memory disksize vmtype cdrom clone_from'.split()]) 139 140 validate = validation.Validate(username, state, strict=True, **kws) 140 return dict(contact=username, name=validate.name, memory=validate.memory,141 return dict(contact=username, name=validate.name, description=validate.description, memory=validate.memory, 141 142 disksize=validate.disksize, owner=validate.owner, machine_type=validate.vmtype, 142 143 cdrom=getattr(validate, 'cdrom', None), … … 347 348 transaction = ctx.current.create_transaction() 348 349 try: 349 kws = dict([(kw, fields.getfirst(kw)) for kw in 'machine_id owner admin contact name memory vmtype disksize'.split()])350 kws = dict([(kw, fields.getfirst(kw)) for kw in 'machine_id owner admin contact name description memory vmtype disksize'.split()]) 350 351 validate = validation.Validate(username, state, **kws) 351 352 machine = validate.machine … … 372 373 if hasattr(validate, 'name'): 373 374 machine.name = validate.name 375 if hasattr(validate, 'description'): 376 machine.description = validate.description 374 377 if hasattr(validate, 'admin') and validate.admin != machine.administrator: 375 378 machine.administrator = validate.admin … … 489 492 on_poweroff on_crash on_xend_start on_xend_stop bootloader""".split() 490 493 display_fields = [('name', 'Name'), 494 ('description', 'Description'), 491 495 ('owner', 'Owner'), 492 496 ('administrator', 'Administrator'), … … 510 514 machine_info = {} 511 515 machine_info['name'] = machine.name 516 machine_info['description'] = machine.description 512 517 machine_info['type'] = machine.type.hvm and 'HVM' or 'ParaVM' 513 518 machine_info['owner'] = machine.owner … … 544 549 max_disk = validation.maxDisk(machine.owner, machine) 545 550 defaults = Defaults() 546 for name in 'machine_id name administrator owner memory contact'.split():551 for name in 'machine_id name description administrator owner memory contact'.split(): 547 552 setattr(defaults, name, getattr(machine, name)) 548 553 defaults.type = machine.type.type_id … … 613 618 errorMessage=str(err), stderr=emsg, traceback=traceback) 614 619 details = templates.error_raw(searchList=[d]) 615 send_error_mail('xvm error on %s for %s: %s' % (op, username, err),616 details)617 620 d['details'] = details 618 621 return templates.error(searchList=[d]) -
trunk/packages/sipb-xen-www/code/templates/info.tmpl
r572 r609 66 66 <input type="hidden" name="machine_id" value="$defaults.machine_id"/> 67 67 <table> 68 <tr><td>Description:</td><td colspan="2"><textarea name="description" rows="4" cols="60">$defaults.description</textarea></td></tr> 68 69 <tr><td>Owner#slurp 69 70 #filter None -
trunk/packages/sipb-xen-www/code/templates/list.tmpl
r572 r609 30 30 #filter None 31 31 $errorRow('name', $err) 32 #end filter 33 <tr> 34 <td>Description</td> 35 <td><textarea name="description" rows="4" cols="60">$defaults.description</textarea></td> 36 </tr> 37 #filter None 38 $errorRow('description', $err) 32 39 #end filter 33 40 <tr> … … 136 143 #end if 137 144 </td> 138 <td >145 <td rowspan="2"> 139 146 <form action="command" method="post"> 140 147 <input type="hidden" name="back" value="list"/> … … 146 153 </form> 147 154 </td> 155 </tr> 156 <tr> 157 <td colspan="7" style="padding-left: 1em; color: #666">$machine.description</td> 148 158 </tr> 149 159 #end def -
trunk/packages/sipb-xen-www/code/validation.py
r584 r609 18 18 19 19 class Validate: 20 def __init__(self, username, state, machine_id=None, name=None, owner=None,20 def __init__(self, username, state, machine_id=None, name=None, description=None, owner=None, 21 21 admin=None, contact=None, memory=None, disksize=None, 22 22 vmtype=None, cdrom=None, clone_from=None, strict=False): … … 29 29 if name is None: 30 30 raise InvalidInput('name', name, "You must provide a machine name.") 31 if description is None: 32 raise InvalidInput('description', description, "You must provide a description.") 31 33 if memory is None: 32 34 raise InvalidInput('memory', memory, "You must provide a memory size.") … … 50 52 if name is not None: 51 53 self.name = name 54 description = testDescription(username, description, machine) 55 if description is not None: 56 self.description = description 52 57 if memory is not None: 53 58 self.memory = validMemory(self.owner, state, memory, machine, … … 270 275 raise InvalidInput('name', name, "Name is already taken.") 271 276 277 def testDescription(user, description, machine=None): 278 if description is None or description.strip() == '': 279 return None 280 return description.strip() 281 272 282 def testHostname(user, hostname, machine): 273 283 for nic in machine.nics:
Note: See TracChangeset
for help on using the changeset viewer.