Changeset 577


Ignore:
Timestamp:
Jun 2, 2008, 11:58:25 PM (17 years ago)
Author:
ecprice
Message:

Fix more bugs

Location:
trunk/packages/sipb-xen-www/code
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-www/code/controls.py

    r574 r577  
    9898    transaction = ctx.current.create_transaction()
    9999    try:
    100         validation.Validate(username, state, owner=owner, memory=memory, disksize=disksize/1024.)
     100        validation.Validate(username, state, name=name, owner=owner, memory=memory, disksize=disksize/1024.)
    101101        res = meta.engine.execute('select nextval('
    102102                                  '\'"machines_machine_id_seq"\')')
  • trunk/packages/sipb-xen-www/code/main.py

    r576 r577  
    145145def parseCreate(username, state, fields):
    146146    kws = dict([(kw, fields.getfirst(kw)) for kw in 'name owner memory disksize vmtype cdrom clone_from'.split()])
    147     validate = validation.Validate(username, state, **kws)
     147    validate = validation.Validate(username, state, strict=True, **kws)
    148148    return dict(contact=username, name=validate.name, memory=validate.memory,
    149149                disksize=validate.disksize, owner=validate.owner, machine_type=validate.vmtype,
     
    155155    try:
    156156        parsed_fields = parseCreate(username, state, fields)
    157         machine = controls.createVm(username, **parsed_fields)
     157        machine = controls.createVm(username, state, **parsed_fields)
    158158    except InvalidInput, err:
    159159        pass
  • trunk/packages/sipb-xen-www/code/validation.py

    r576 r577  
    2020    def __init__(self, username, state, machine_id=None, name=None, owner=None,
    2121                 admin=None, contact=None, memory=None, disksize=None,
    22                  vmtype=None, cdrom=None, clone_from=None):
     22                 vmtype=None, cdrom=None, clone_from=None, strict=False):
    2323        # XXX Successive quota checks aren't a good idea, since you
    2424        # can't necessarily change the locker and disk size at the
    2525        # same time.
    2626        created_new = (machine_id is None)
     27
     28        if strict:
     29            if name is None:
     30                raise InvalidInput('name', name, "You must provide a machine name.")
     31            if memory is None:
     32                raise InvalidInput('memory', memory, "You must provide a memory size.")
     33            if disksize is None:
     34                raise InvalidInput('disk', disksize, "You must provide a disk size.")
    2735
    2836        if machine_id is not None:
Note: See TracChangeset for help on using the changeset viewer.