X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-database.git/blobdiff_plain/2eaf13725429492375779f86f0586273fb1969c8..338300a538a25a187485c5929812100aa19964de:/python/database/models.py diff --git a/python/database/models.py b/python/database/models.py index 5c3a19a..e3f2996 100644 --- a/python/database/models.py +++ b/python/database/models.py @@ -14,6 +14,7 @@ __all__ = ['meta', 'disk_table', 'types_table', 'cdroms_table', + 'mirrors_table', 'autoinstalls_table', 'Machine', 'MachineAccess', @@ -21,6 +22,7 @@ __all__ = ['meta', 'Disk', 'Type', 'CDROM', + 'Mirror', 'Autoinstall', 'or_', ] @@ -36,7 +38,7 @@ machine_table = Table('machines', meta, Column('owner', String, nullable=False), Column('contact', String, nullable=False), Column('uuid', String, nullable=False), - Column('administrator', String, nullable=False, default=False), + Column('administrator', String, nullable=True, default=None), Column('type_id', String, ForeignKey('types.type_id'), nullable=False), Column('autorestart', Boolean, nullable=False, default=False), Column('cpus', Integer, nullable=False, default=1), @@ -77,7 +79,8 @@ autoinstalls_table = Table('autoinstalls', meta, Column('description', String, nullable=False), Column('type_id', String, ForeignKey('types.type_id'), nullable=False), Column('distribution', String, nullable=False), - Column('mirror', String, nullable=False)) + Column('mirror', String, nullable=False), + Column('arch', String, nullable=False)) machine_access_table = Table('machine_access', meta, Column('machine_id', Integer, ForeignKey('machines.machine_id', ondelete='CASCADE'), nullable=False, index=True), @@ -117,16 +120,17 @@ class Autoinstall(object): return "" % (self.autoinstall_id, self.description, self.type.type_id) session.mapper(Machine, machine_table, - properties={'nics': relation(NIC, backref="machine", lazy=False), - 'disks': relation(Disk, backref="machine", lazy=False), - 'type': relation(Type, lazy=False), - 'acl': relation(MachineAccess, backref="machine", lazy=False, passive_deletes=True, cascade="all, delete-orphan")}); + properties={'nics': relation(NIC, backref="machine"), + 'disks': relation(Disk, backref="machine"), + 'type': relation(Type), + 'acl': relation(MachineAccess, backref="machine", passive_deletes=True, cascade="all, delete-orphan")}); session.mapper(MachineAccess, machine_access_table) session.mapper(NIC, nic_table) session.mapper(Disk, disk_table) session.mapper(Type, types_table) session.mapper(Mirror, mirrors_table) -session.mapper(CDROM, cdroms_table) +session.mapper(CDROM, cdroms_table, + properties={'mirror': relation(Mirror, backref="cdroms")}) session.mapper(Autoinstall, autoinstalls_table) def clear_cache():