Changeset 243 for trunk


Ignore:
Timestamp:
Nov 12, 2007, 5:05:26 AM (17 years ago)
Author:
quentin
Message:

Remove unnecessary constructors

Rename disk to disk_size in some (but not all!) places

Added MachineAccess? to all

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-database/sipb-xen-database/debian/changelog

    r241 r243  
     1sipb-xen-database (10.2) unstable; urgency=low
     2
     3  * Add MachineAccess to __all__ so it can be imported
     4  * Remove unnecessary constructors for database objects
     5
     6 -- Quentin Smith <quentin@sipb-xen-dev.mit.edu>  Mon, 12 Nov 2007 04:53:47 -0500
     7
    18sipb-xen-database (10.1) unstable; urgency=low
    29
  • trunk/packages/sipb-xen-database/sipb-xen-database/sipb_xen_database/models.py

    r238 r243  
    77           'ctx',
    88           'machine_table',
     9           'machine_access_table',
    910           'nic_table',
    1011           'disk_table',
     
    1213           'cdroms_table',
    1314           'Machine',
     15           'MachineAccess',
    1416           'NIC',
    1517           'Disk',
     
    7072
    7173class NIC(object):
    72     def __init__(self, machine_id, mac_addr, ip, hostname):
    73         self.machine_id = machine_id
    74         self.mac_addr = mac_addr
    75         self.ip = ip
    76         self.hostname = hostname
    7774    def __repr__(self):
    7875        return "<NIC: mac='%s' machine='%s' ip='%s' hostname='%s'>" % (self.mac_addr, self.machine_id, self.ip, self.hostname)
    7976
    8077class Disk(object):
    81     def __init__(self, machine_id, guest, size):
    82         self.machine_id = machine_id
    83         self.guest_device_name = guest
    84         self.size = size
    8578    def __repr__(self):
    8679        return "<Disk: machine=%s device=%s size=%s>" % (self.machine_id, self.guest_device_name, self.size)
     
    9184
    9285class CDROM(object):
    93     def __init__(self, cdrom_id, description):
    94         self.cdrom_id = cdrom_id
    95         self.description = description
    9686    def __repr__(self):
    9787        return "<CDROM %s: %s>" % (self.cdrom_id, self.description)
  • trunk/web/controls.py

    r236 r243  
    8888    remctl('web', 'unregister', machine.name)
    8989
    90 def createVm(owner, contact, name, memory, disk, is_hvm, cdrom):
     90def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom):
    9191    """Create a VM and put it in the database"""
    9292    # put stuff in the table
     
    9494    try:
    9595        validation.validMemory(owner, memory)
    96         validation.validDisk(owner, disk  * 1. / 1024)
     96        validation.validDisk(owner, disk_size  * 1. / 1024)
    9797        validation.validAddVm(owner)
    9898        res = meta.engine.execute('select nextval('
     
    111111        machine.type_id = machine_type.type_id
    112112        ctx.current.save(machine)
    113         disk = Disk(machine.machine_id,
    114                     'hda', disk)
     113        disk = Disk(machine_id=machine.machine_id,
     114                    guest_device_name='hda', size=disk_size)
    115115        open_nics = NIC.select_by(machine_id=None)
    116116        if not open_nics: #No IPs left!
  • trunk/web/main.py

    r236 r243  
    150150    memory = validation.validMemory(user, memory, on=True)
    151151   
    152     disk = fields.getfirst('disk')
    153     disk = validation.validDisk(user, disk)
     152    disk_size = fields.getfirst('disk')
     153    disk_size = validation.validDisk(user, disk_size)
    154154
    155155    vm_type = fields.getfirst('vmtype')
     
    161161    if cdrom is not None and not CDROM.get(cdrom):
    162162        raise CodeError("Invalid cdrom type '%s'" % cdrom)
    163     return dict(contact=user, name=name, memory=memory, disk=disk,
     163    return dict(contact=user, name=name, memory=memory, disk_size=disk_size,
    164164                owner=owner, is_hvm=is_hvm, cdrom=cdrom)
    165165
  • trunk/web/xen-ips

    r113 r243  
    3838
    3939def addip(ip):
    40     n = NIC(None, randomMAC(), ip, None)
     40    n = NIC(machine_id=None, mac_addr=randomMAC(), ip=ip, hostname=None)
    4141    ctx.current.save(n)
    4242    ctx.current.flush()
Note: See TracChangeset for help on using the changeset viewer.