web.pluginmanager.plugins.hardware_inventory.model

Package web :: Package pluginmanager :: Package plugins :: Package hardware_inventory :: Module model |
[hide private]
[frames] | no frames]

# Source Code for Module web.pluginmanager.plugins.hardware_inventory.model

     1  from db import Base
     2  from sqlalchemy import Column, Unicode, Table, Integer, ForeignKey
     3  from sqlalchemy.orm import relation, backref
     4  from main.model import Computer
     5
     6  metadata = Base.metadata
     7
     8 -class HardwareProfile(Base):
     9      __tablename__ = 'hardware_profile'
    10
    11      id = Column(Integer, primary_key=True)
    12      name = Column(Unicode(256))
    13
    14      hardware_profile_computer = Table(
    15              'hardware_profile_computer', metadata,
    16              Column('profile_id', Integer, ForeignKey('hardware_profile.id')),
    17              Column('computer_id', Integer, ForeignKey('computer.id')))
    18      computers = relation('Computer', secondary = hardware_profile_computer,
    19              backref='hardware')
    20
    21 -    def __init__(self, name=''):
    22          self.name = name
    23
    24 -class HardwareElement(Base):
    25      __tablename__ = 'hardware_element'
    26
    27      id = Column(Integer, primary_key=True)
    28      type = Column(Unicode(3), primary_key=True)
    29      description = Column(Unicode(512), primary_key=True)
    30
    31      hardware_profile_hardware_element = Table(
    32              'hardware_profile_hardware_element',metadata,
    33              Column('element_id', Integer, ForeignKey('hardware_element.id')),
    34              Column('profile_id', Integer, ForeignKey('hardware_profile.id')))
    35
    36      profiles = relation('HardwareProfile',
    37              secondary = hardware_profile_hardware_element, backref='elements')
    38
    39 -    def __cmp__(self, other):
    40          return self.id == other.id
    41