Changeset 238


Ignore:
Timestamp:
Nov 12, 2007, 4:22:49 AM (16 years ago)
Author:
quentin
Message:

Add a machine_access table where access information will be cached

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-database/sipb-xen-database/sipb_xen_database/models.py

    r204 r238  
    5656       Column('description', String, nullable=False))
    5757
     58machine_access_table = Table('machine_access', meta,
     59       Column('machine_id', Integer, ForeignKey('machines.machine_id'), nullable=False, index=True),
     60       Column('user', String, nullable=False, index=True),
     61       PrimaryKeyConstraint('machine_id', 'user'))
    5862
    5963class Machine(object):
    6064    def __repr__(self):
    6165        return "<Machine %s: name='%s' owner='%s'>" % (self.machine_id, self.name, self.owner)
     66
     67class MachineAccess(object):
     68    def __repr__(self):
     69        return "<MachineAccess machine='%s' user='%s'>" % (self.machine, self.user)
    6270
    6371class NIC(object):
     
    92100              properties={'nics': relation(NIC, backref="machine"),
    93101                          'disks': relation(Disk, backref="machine"),
    94                           'type': relation(Type)});
     102                          'type': relation(Type),
     103                          'users': relation(MachineAccess, backref="machine")});
     104assign_mapper(ctx, MachineAccess, machine_access_table)
    95105assign_mapper(ctx, NIC, nic_table)
    96106assign_mapper(ctx, Disk, disk_table)
    97107assign_mapper(ctx, Type, types_table)
    98108assign_mapper(ctx, CDROM, cdroms_table)
    99 
Note: See TracChangeset for help on using the changeset viewer.