diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2009-10-07 14:46:08 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2009-10-07 14:46:08 +0000 |
commit | eac52c270b8b3b10e461bc46502b64c5f898bd7d (patch) | |
tree | 96da2e78af41305b445de23596b75bf754eedbbc /src/lib/Server/Snapshots | |
parent | e686d3b69600441e943c2913542e5477af528d87 (diff) | |
download | bcfg2-eac52c270b8b3b10e461bc46502b64c5f898bd7d.tar.gz bcfg2-eac52c270b8b3b10e461bc46502b64c5f898bd7d.tar.bz2 bcfg2-eac52c270b8b3b10e461bc46502b64c5f898bd7d.zip |
Pylint/PEP 8 Code cleanups
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5477 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Snapshots')
-rw-r--r-- | src/lib/Server/Snapshots/__init__.py | 5 | ||||
-rw-r--r-- | src/lib/Server/Snapshots/model.py | 22 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/lib/Server/Snapshots/__init__.py b/src/lib/Server/Snapshots/__init__.py index eb849e715..c13dee42e 100644 --- a/src/lib/Server/Snapshots/__init__.py +++ b/src/lib/Server/Snapshots/__init__.py @@ -1,6 +1,9 @@ __all__ = ['models', 'db_from_config', 'setup_session'] -import sqlalchemy, sqlalchemy.orm, ConfigParser +import sqlalchemy +import sqlalchemy.orm +import ConfigParser + def db_from_config(fname='/etc/bcfg2.conf'): cp = ConfigParser.ConfigParser() diff --git a/src/lib/Server/Snapshots/model.py b/src/lib/Server/Snapshots/model.py index cd2e617f5..cbb14be79 100644 --- a/src/lib/Server/Snapshots/model.py +++ b/src/lib/Server/Snapshots/model.py @@ -1,11 +1,14 @@ -from sqlalchemy import Table, Column, Integer, Unicode, ForeignKey, Boolean, DateTime, UnicodeText, desc +from sqlalchemy import Table, Column, Integer, Unicode, ForeignKey, Boolean, \ + DateTime, UnicodeText, desc import datetime import sqlalchemy.exceptions from sqlalchemy.orm import relation, backref from sqlalchemy.ext.declarative import declarative_base + class Uniquer(object): force_rt = True + @classmethod def by_value(cls, session, **kwargs): if cls.force_rt: @@ -22,6 +25,7 @@ class Uniquer(object): Base = declarative_base() + class Administrator(Uniquer, Base): __tablename__ = 'administrator' id = Column(Integer, primary_key=True) @@ -36,6 +40,7 @@ admin_group = Table('admin_group', Base.metadata, Column('admin_id', Integer, ForeignKey('administrator.id')), Column('group_id', Integer, ForeignKey('group.id'))) + class Client(Uniquer, Base): __tablename__ = 'client' id = Column(Integer, primary_key=True) @@ -46,6 +51,7 @@ class Client(Uniquer, Base): online = Column(Boolean, default=True) online_ts = Column(DateTime) + class Group(Uniquer, Base): __tablename__ = 'group' id = Column(Integer, primary_key=True) @@ -53,6 +59,7 @@ class Group(Uniquer, Base): admins = relation("Administrator", secondary=admin_group, backref='groups') + class ConnectorKeyVal(Uniquer, Base): __tablename__ = 'connkeyval' id = Column(Integer, primary_key=True) @@ -68,6 +75,7 @@ meta_conn = Table('meta_conn', Base.metadata, Column('metadata_id', Integer, ForeignKey('metadata.id')), Column('connkeyval_id', Integer, ForeignKey('connkeyval.id'))) + class Metadata(Base): __tablename__ = 'metadata' id = Column(Integer, primary_key=True) @@ -96,6 +104,7 @@ class Metadata(Base): value=unicode(value))) return m + class Package(Base, Uniquer): __tablename__ = 'package' id = Column(Integer, primary_key=True) @@ -104,13 +113,15 @@ class Package(Base, Uniquer): version = Column(Unicode(16)) verification_status = Column(Boolean) + class CorrespondenceType(object): mtype = Package + @classmethod def from_record(cls, mysession, record): (mod, corr, name, s_dict, e_dict) = record if not s_dict: - start=None + start = None else: start = cls.mtype.by_value(mysession, name=name, **s_dict) if s_dict != e_dict: @@ -119,6 +130,7 @@ class CorrespondenceType(object): end = start return cls(start=start, end=end, modified=mod, correct=corr) + class PackageCorrespondence(Base, CorrespondenceType): mtype = Package __tablename__ = 'package_pair' @@ -134,6 +146,7 @@ package_snap = Table('package_snap', Base.metadata, Column('ppair_id', Integer, ForeignKey('package_pair.id')), Column('snapshot_id', Integer, ForeignKey('snapshot.id'))) + class Service(Base, Uniquer): __tablename__ = 'service' id = Column(Integer, primary_key=True) @@ -141,6 +154,7 @@ class Service(Base, Uniquer): type = Column(Unicode(12)) status = Column(Boolean) + class ServiceCorrespondence(Base, CorrespondenceType): mtype = Service __tablename__ = 'service_pair' @@ -156,6 +170,7 @@ service_snap = Table('service_snap', Base.metadata, Column('spair_id', Integer, ForeignKey('service_pair.id')), Column('snapshot_id', Integer, ForeignKey('snapshot.id'))) + class File(Base, Uniquer): __tablename__ = 'file' id = Column(Integer, primary_key=True) @@ -166,6 +181,7 @@ class File(Base, Uniquer): perms = Column(Integer(5)) contents = Column(UnicodeText) + class FileCorrespondence(Base, CorrespondenceType): mtype = File __tablename__ = 'file_pair' @@ -193,6 +209,7 @@ extra_service_snap = Table('extra_service_snap', Base.metadata, Column('service_id', Integer, ForeignKey('service.id')), Column('snapshot_id', Integer, ForeignKey('snapshot.id'))) + class Action(Base): __tablename__ = 'action' id = Column(Integer, primary_key=True) @@ -204,6 +221,7 @@ action_snap = Table('action_snap', Base.metadata, Column('action_id', Integer, ForeignKey('action.id')), Column('snapshot_id', Integer, ForeignKey('snapshot.id'))) + class Snapshot(Base): __tablename__ = 'snapshot' id = Column(Integer, primary_key=True) |