from sqlalchemy.ext.sessioncontext import SessionContext
from sqlalchemy.ext.assignmapper import assign_mapper
+import datetime
+
from invirt.database import record
__all__ = ['meta',
'autoinstalls_table',
'owners_table',
'admins_table',
+ 'builds_table',
'Machine',
'MachineAccess',
'NIC',
'Autoinstall',
'Owner',
'Admin',
+ 'Build',
'or_',
]
Column('vms_quota_total', Integer, nullable=True, default=None),
Column('vms_quota_active', Integer, nullable=True, default=None))
+builds_table = Table('builds', meta,
+ Column('build_id', Integer, primary_key=True, nullable=False),
+ Column('package', String, nullable=False),
+ Column('pocket', String, nullable=False),
+ Column('commit', String, nullable=False),
+ Column('version', String, nullable=True, default=None),
+ Column('principal', String, nullable=False),
+ Column('succeeded', Boolean, nullable=False),
+ Column('failed_stage', String, nullable=True, default=None),
+ Column('inserted_at', DateTime, nullable=False, default=datetime.datetime.utcnow))
+
machine_access_table = Table('machine_access', meta,
Column('machine_id', Integer, ForeignKey('machines.machine_id', ondelete='CASCADE'), nullable=False, index=True),
Column('user', String, nullable=False, index=True),
class Admin(record.Record):
_identity_field = 'user'
+class Build(record.Record):
+ _identity_field = 'build_id'
+
from invirt.database.owner import Owner
session.mapper(Machine, machine_table,
session.mapper(Autoinstall, autoinstalls_table)
session.mapper(Owner, owners_table)
session.mapper(Admin, admins_table)
+session.mapper(Build, builds_table)
def clear_cache():
"""Clear sqlalchemy's cache