Ignore:
Timestamp:
Jun 21, 2008, 10:39:27 PM (16 years ago)
Author:
andersk
Message:

Add overlord mode, accessible from xvm.mit.edu/overlord by
system:sipb-xen.

File:
1 edited

Legend:

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

    r629 r632  
    3737
    3838        if machine_id is not None:
    39             self.machine = testMachineId(username, machine_id)
     39            self.machine = testMachineId(username, state, machine_id)
    4040        machine = getattr(self, 'machine', None)
    4141
     
    5959                                      on=not created_new)
    6060        if disksize is not None:
    61             self.disksize = validDisk(self.owner, disksize, machine)
     61            self.disksize = validDisk(self.owner, state, disksize, machine)
    6262        if vmtype is not None:
    6363            self.vmtype = validVmType(vmtype)
     
    124124    return False
    125125
    126 def haveAccess(user, machine):
     126def haveAccess(user, state, machine):
    127127    """Return whether a user has administrative access to a machine"""
    128     return user in cache_acls.accessList(machine)
     128    return state.overlord or user in cache_acls.accessList(machine)
    129129
    130130def owns(user, machine):
     
    158158                           "Minimum %s MiB" % MIN_MEMORY_SINGLE)
    159159    max_val = maxMemory(owner, g, machine, on)
    160     if memory > max_val:
     160    if not g.overlord and memory > max_val:
    161161        raise InvalidInput('memory', memory,
    162162                           'Maximum %s MiB for %s' % (max_val, owner))
    163163    return memory
    164164
    165 def validDisk(owner, disk, machine=None):
     165def validDisk(owner, g, disk, machine=None):
    166166    """Parse and validate limits for disk for a given owner and machine."""
    167167    try:
    168168        disk = float(disk)
    169         if disk > maxDisk(owner, machine):
     169        if not g.overlord and disk > maxDisk(owner, machine):
    170170            raise InvalidInput('disk', disk,
    171171                               "Maximum %s G" % maxDisk(owner, machine))
     
    186186    return t
    187187
    188 def testMachineId(user, machine_id, exists=True):
     188def testMachineId(user, state, machine_id, exists=True):
    189189    """Parse, validate and check authorization for a given user and machine.
    190190
     
    201201    if exists and machine is None:
    202202        raise InvalidInput('machine_id', machine_id, "Does not exist.")
    203     if machine is not None and not haveAccess(user, machine):
     203    if machine is not None and not haveAccess(user, state, machine):
    204204        raise InvalidInput('machine_id', machine_id,
    205205                           "You do not have access to this machine.")
Note: See TracChangeset for help on using the changeset viewer.