class MESD(model_base.BASE, models_v1.HasId, models_v1.HasTenant, models_v1.Audit): """Represents MESD to create MES.""" __tablename__ = 'mesd' # Descriptive name name = sa.Column(sa.String(255), nullable=False) description = sa.Column(sa.Text) # Mesd template source - onboarded template_source = sa.Column(sa.String(255), server_default='onboarded') mesd_mapping = sa.Column(types.Json, nullable=True) # (key, value) pair to spin up attributes = orm.relationship('MESDAttribute', backref='mesd') __table_args__ = ( schema.UniqueConstraint( "tenant_id", "name", name="uniq_mesd0tenant_id0name"), )
class VolumeTypeProjects(BASE, CinderBase): """Represent projects associated volume_types.""" __tablename__ = "volume_type_projects" __table_args__ = (schema.UniqueConstraint( "volume_type_id", "project_id", "deleted", name="uniq_volume_type_projects0volume_type_id0project_id0deleted"), ) id = Column(Integer, primary_key=True) volume_type_id = Column(Integer, ForeignKey('volume_types.id'), nullable=False) project_id = Column(String(255)) volume_type = relationship( VolumeTypes, backref="projects", foreign_keys=volume_type_id, primaryjoin='and_(' 'VolumeTypeProjects.volume_type_id == VolumeTypes.id,' 'VolumeTypeProjects.deleted == False)')
class Job(core.ModelBase, core.DictBase): __tablename__ = 'job' __table_args__ = (schema.UniqueConstraint( 'type', 'status', 'resource_id', 'extra_id', name='job0type0status0resource_id0extra_id'), ) attributes = [ 'id', 'type', 'timestamp', 'status', 'resource_id', 'extra_id' ] id = sql.Column('id', sql.String(length=36), primary_key=True) type = sql.Column('type', sql.String(length=36)) timestamp = sql.Column('timestamp', sql.TIMESTAMP, server_default=sql.text('CURRENT_TIMESTAMP')) status = sql.Column('status', sql.String(length=36)) resource_id = sql.Column('resource_id', sql.String(length=36)) extra_id = sql.Column('extra_id', sql.String(length=36))
class ShareTypeProjects(BASE, ManilaBase): """Represent projects associated share_types.""" __tablename__ = "share_type_projects" __table_args__ = (schema.UniqueConstraint( "share_type_id", "project_id", "deleted", name="uniq_share_type_projects0share_type_id0project_id0deleted"), ) id = Column(Integer, primary_key=True) share_type_id = Column(Integer, ForeignKey('share_types.id'), nullable=False) project_id = Column(String(255)) share_type = orm.relationship( ShareTypes, backref="projects", foreign_keys=share_type_id, primaryjoin='and_(' 'ShareTypeProjects.share_type_id == ShareTypes.id,' 'ShareTypeProjects.deleted == 0)')
class Vim(model_base.BASE, models_v1.HasId, models_v1.HasTenant, models_v1.Audit): type = sa.Column(sa.String(64), nullable=False) name = sa.Column(sa.String(255), nullable=False) description = sa.Column(sa.Text, nullable=True) placement_attr = sa.Column(types.Json, nullable=True) shared = sa.Column(sa.Boolean, default=True, server_default=sql.true( ), nullable=False) is_default = sa.Column(sa.Boolean, default=False, server_default=sql.false( ), nullable=False) vim_auth = orm.relationship('VimAuth') status = sa.Column(sa.String(255), nullable=False) __table_args__ = ( schema.UniqueConstraint( "tenant_id", "name", name="uniq_vim0tenant_id0name"), )
class ClusterTemplate(Base): """Represents a ClusterTemplate.""" __tablename__ = 'cluster_template' __table_args__ = (schema.UniqueConstraint('uuid', name='uniq_baymodel0uuid'), table_args()) id = Column(Integer, primary_key=True) uuid = Column(String(36)) project_id = Column(String(255)) user_id = Column(String(255)) name = Column(String(255)) image_id = Column(String(255)) flavor_id = Column(String(255)) master_flavor_id = Column(String(255)) keypair_id = Column(String(255)) external_network_id = Column(String(255)) fixed_network = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_subnet = Column(String(255, mysql_ndb_type=TINYTEXT)) network_driver = Column(String(255, mysql_ndb_type=TINYTEXT)) volume_driver = Column(String(255, mysql_ndb_type=TINYTEXT)) dns_nameserver = Column(String(255, mysql_ndb_type=TINYTEXT)) apiserver_port = Column(Integer()) docker_volume_size = Column(Integer()) docker_storage_driver = Column(String(255)) cluster_distro = Column(String(255, mysql_ndb_type=TINYTEXT)) coe = Column(String(255, mysql_ndb_type=TINYTEXT)) http_proxy = Column(String(255, mysql_ndb_type=TINYTEXT)) https_proxy = Column(String(255, mysql_ndb_type=TINYTEXT)) no_proxy = Column(String(255, mysql_ndb_type=TINYTEXT)) registry_enabled = Column(Boolean, default=False) labels = Column(JSONEncodedDict) tls_disabled = Column(Boolean, default=False) public = Column(Boolean, default=False) server_type = Column(String(255)) insecure_registry = Column(String(255, mysql_ndb_type=TINYTEXT)) master_lb_enabled = Column(Boolean, default=False) floating_ip_enabled = Column(Boolean, default=True) hidden = Column(Boolean, default=False) tags = Column(String(255))
class Worker(BASE, CinderBase): """Represents all resources that are being worked on by a node.""" __tablename__ = 'workers' __table_args__ = (schema.UniqueConstraint('resource_type', 'resource_id'), { 'mysql_engine': 'InnoDB' }) # We want to overwrite default updated_at definition so we timestamp at # creation as well updated_at = Column(DateTime, default=timeutils.utcnow, onupdate=timeutils.utcnow) # Id added for convenience and speed on some operations id = Column(Integer, primary_key=True, autoincrement=True) # Type of the resource we are working on (Volume, Snapshot, Backup) it must # match the Versioned Object class name. resource_type = Column(String(40), primary_key=True, nullable=False) # UUID of the resource we are working on resource_id = Column(String(36), primary_key=True, nullable=False) # Status that should be cleaned on service failure status = Column(String(255), nullable=False) # Service that is currently processing the operation service_id = Column(Integer, nullable=True) # To prevent claiming and updating races race_preventer = Column(Integer, nullable=False, default=0) # This is a flag we don't need to store in the DB as it is only used when # we are doing the cleanup to let decorators know cleaning = False service = relationship('Service', backref="workers", foreign_keys=service_id, primaryjoin='Worker.service_id == Service.id')
class Cluster(Base): """Represents a Cluster.""" __tablename__ = 'cluster' __table_args__ = (schema.UniqueConstraint('uuid', name='uniq_bay0uuid'), table_args()) id = Column(Integer, primary_key=True) project_id = Column(String(255)) user_id = Column(String(255)) uuid = Column(String(36)) name = Column(String(255)) cluster_template_id = Column(String(255)) keypair = Column(String(255)) docker_volume_size = Column(Integer()) stack_id = Column(String(255)) api_address = Column(String(255)) node_addresses = Column(JSONEncodedList) node_count = Column(Integer()) master_count = Column(Integer()) status = Column(String(20)) status_reason = Column(Text) create_timeout = Column(Integer()) discovery_url = Column(String(255)) master_addresses = Column(JSONEncodedList) # TODO(wanghua): encrypt trust_id in db trust_id = Column(String(255)) trustee_username = Column(String(255)) trustee_user_id = Column(String(255)) # TODO(wanghua): encrypt trustee_password in db trustee_password = Column(String(255)) coe_version = Column(String(255)) container_version = Column(String(255)) # (yuanying) if we use barbican, # cert_ref size is determined by below format # * http(s)://${DOMAIN_NAME}/v1/containers/${UUID} # as a result, cert_ref length is estimated to 312 chars. # but we can use another backend to store certs. # so, we use 512 chars to get some buffer. ca_cert_ref = Column(String(512)) magnum_cert_ref = Column(String(512))
class PciDevice(BASE, NovaBase): """Represents a PCI host device that can be passed through to instances. """ __tablename__ = 'pci_devices' __table_args__ = ( Index('ix_pci_devices_compute_node_id_deleted', 'compute_node_id', 'deleted'), Index('ix_pci_devices_instance_uuid_deleted', 'instance_uuid', 'deleted'), schema.UniqueConstraint( "compute_node_id", "address", "deleted", name="uniq_pci_devices0compute_node_id0address0deleted") ) id = Column(Integer, primary_key=True) compute_node_id = Column(Integer, ForeignKey('compute_nodes.id'), nullable=False) # physical address of device domain:bus:slot.func (0000:09:01.1) address = Column(String(12), nullable=False) vendor_id = Column(String(4), nullable=False) product_id = Column(String(4), nullable=False) dev_type = Column(String(8), nullable=False) dev_id = Column(String(255)) # label is abstract device name, that is used to unify devices with the # same functionality with different addresses or host. label = Column(String(255), nullable=False) status = Column(String(36), nullable=False) extra_info = Column(Text) instance_uuid = Column(String(36)) instance = orm.relationship(Instance, backref="pci_devices", foreign_keys=instance_uuid, primaryjoin='and_(' 'PciDevice.instance_uuid == Instance.uuid,' 'PciDevice.deleted == 0)')
class Residence(Base): __tablename__ = "residence" __table_args__ = (sql_schema.UniqueConstraint("id", "community_id"), ) id = Column(sql_types.Integer, primary_key=True) community_id = Column(sql_types.Integer, ForeignKey("community.id"), nullable=False) unit_no = Column(sql_types.String(40)) street = Column(sql_types.String(80), nullable=False) locality = Column(sql_types.String(40), nullable=False) postcode = Column(sql_types.String(20), nullable=False) region = Column(sql_types.String(40), nullable=False) ownership_stake = Column(SqliteSafeDecimal) occupants = orm.relationship( "User", secondary="residence_occupancy", lazy=True, backref=orm.backref("residences", lazy=True), ) residence_charges = orm.relationship("BillingCharge", lazy=True, backref=orm.backref( "charged_residence", lazy=True)) recurring_charges = orm.relationship( "RecurringCharge", lazy=True, backref=orm.backref("charged_residence", lazy=True), ) def __repr__(self): return (f"Residence(" f"unit_no={self.unit_no}," f"street={self.street}," f"locality={self.locality}," f"postcode={self.postcode}," f"region={self.region}" f")")
class ResourceRouting(core.ModelBase, core.DictBase, models.TimestampMixin): __tablename__ = 'resource_routings' __table_args__ = ( schema.UniqueConstraint( 'top_id', 'pod_id', 'resource_type', name='resource_routings0top_id0pod_id0resource_type'), ) attributes = ['id', 'top_id', 'bottom_id', 'pod_id', 'project_id', 'resource_type', 'created_at', 'updated_at'] # sqlite doesn't support auto increment on big integers so we use big int # for everything but sqlite id = sql.Column(sql.BigInteger().with_variant(sql.Integer(), 'sqlite'), primary_key=True, autoincrement=True) top_id = sql.Column('top_id', sql.String(length=127), nullable=False) bottom_id = sql.Column('bottom_id', sql.String(length=36), index=True) pod_id = sql.Column('pod_id', sql.String(length=36), sql.ForeignKey('pods.pod_id'), nullable=False) project_id = sql.Column('project_id', sql.String(length=36)) resource_type = sql.Column('resource_type', sql.String(length=64), nullable=False)
class InstanceGroup(API_BASE): """Represents an instance group. A group will maintain a collection of instances and the relationship between them. """ __tablename__ = 'instance_groups' __table_args__ = (schema.UniqueConstraint( 'uuid', name='uniq_instance_groups0uuid'), ) id = Column(Integer, primary_key=True, autoincrement=True) user_id = Column(String(255)) project_id = Column(String(255)) uuid = Column(String(36), nullable=False) name = Column(String(255)) _policies = orm.relationship( InstanceGroupPolicy, primaryjoin='InstanceGroup.id == InstanceGroupPolicy.group_id') # WRS:extension - metadata _metadata = orm.relationship( InstanceGroupMetadata, primaryjoin='InstanceGroup.id == InstanceGroupMetadata.group_id') _members = orm.relationship( InstanceGroupMember, primaryjoin='InstanceGroup.id == InstanceGroupMember.group_id') @property def policies(self): return [p.policy for p in self._policies] # WRS:extension - metadetails @property def metadetails(self): return {m.key: m.value for m in self._metadata} @property def members(self): return [m.instance_uuid for m in self._members]
class ExecInstance(Base): """Represents an exec instance.""" __tablename__ = 'exec_instance' __table_args__ = ( schema.UniqueConstraint( 'container_id', 'exec_id', name='uniq_exec_instance0container_id_exec_id'), table_args() ) id = Column(Integer, primary_key=True, nullable=False) container_id = Column(Integer, ForeignKey('container.id', ondelete="CASCADE"), nullable=False) exec_id = Column(String(255), nullable=False) token = Column(String(255), nullable=True) url = Column(String(255), nullable=True) container = orm.relationship( Container, backref=orm.backref('exec_instances'), foreign_keys=container_id, primaryjoin='and_(ExecInstance.container_id==Container.id)')
class ResourceRouting(core.ModelBase, core.DictBase, models.TimestampMixin): __tablename__ = 'cascaded_pods_resource_routing' __table_args__ = (schema.UniqueConstraint( 'top_id', 'pod_id', name='cascaded_pods_resource_routing0top_id0pod_id'), ) attributes = [ 'id', 'top_id', 'bottom_id', 'pod_id', 'project_id', 'resource_type', 'created_at', 'updated_at' ] id = sql.Column('id', sql.Integer, primary_key=True) top_id = sql.Column('top_id', sql.String(length=127), nullable=False) bottom_id = sql.Column('bottom_id', sql.String(length=36)) pod_id = sql.Column('pod_id', sql.String(length=64), sql.ForeignKey('cascaded_pods.pod_id'), nullable=False) project_id = sql.Column('project_id', sql.String(length=36)) resource_type = sql.Column('resource_type', sql.String(length=64), nullable=False)
class FloatingIp(BASE, NovaBase): """Represents a floating ip that dynamically forwards to a fixed ip.""" __tablename__ = 'floating_ips' __table_args__ = ( schema.UniqueConstraint("address", "deleted", name="uniq_floating_ips0address0deleted"), ) id = Column(Integer, primary_key=True) address = Column(types.IPAddress()) fixed_ip_id = Column(Integer, nullable=True) project_id = Column(String(255)) host = Column(String(255)) # , ForeignKey('hosts.id')) auto_assigned = Column(Boolean, default=False, nullable=False) pool = Column(String(255)) interface = Column(String(255)) fixed_ip = relationship(FixedIp, backref=backref('floating_ips'), foreign_keys=fixed_ip_id, primaryjoin='and_(' 'FloatingIp.fixed_ip_id == FixedIp.id,' 'FloatingIp.deleted == 0,' 'FixedIp.deleted == 0)')
class AggregateMetadata(Base): """Represents additional metadata as key/value pairs for an aggregate.""" __tablename__ = 'aggregate_metadata' __table_args__ = (schema.UniqueConstraint("aggregate_uuid", "key", name=("uniq_aggregate_metadata0" "aggregate_uuid")), table_args()) id = Column(Integer, primary_key=True) key = Column(String(255)) value = Column(String(255)) aggregate_uuid = Column(String(36), ForeignKey('aggregates.uuid'), nullable=False) aggregate = orm.relationship(Aggregates, backref="metadata", foreign_keys=aggregate_uuid, primaryjoin='AggregateMetadata.aggregate_uuid' '== Aggregates.uuid') #Base.metadata.create_all(_engine)
class InstanceGroup(BASE, NovaBase): """Represents an instance group. A group will maintain a collection of instances and the relationship between them. """ __tablename__ = 'instance_groups' __table_args__ = (schema.UniqueConstraint("uuid", "deleted"), ) id = Column(Integer, primary_key=True, autoincrement=True) user_id = Column(String(255)) project_id = Column(String(255)) uuid = Column(String(36), nullable=False) name = Column(String(255)) _policies = relationship(InstanceGroupPolicy, primaryjoin='and_(' 'InstanceGroup.id == InstanceGroupPolicy.group_id,' 'InstanceGroupPolicy.deleted == 0,' 'InstanceGroup.deleted == 0)') _metadata = relationship(InstanceGroupMetadata, primaryjoin='and_(' 'InstanceGroup.id == InstanceGroupMetadata.group_id,' 'InstanceGroupMetadata.deleted == 0,' 'InstanceGroup.deleted == 0)') _members = relationship(InstanceGroupMember, primaryjoin='and_(' 'InstanceGroup.id == InstanceGroupMember.group_id,' 'InstanceGroupMember.deleted == 0,' 'InstanceGroup.deleted == 0)') @property def policies(self): return [p.policy for p in self._policies] @property def metadetails(self): return dict((m.key, m.value) for m in self._metadata) @property def members(self): return [m.instance_id for m in self._members]
class InstanceTypeProjects(BASE, NovaBase): """Represent projects associated instance_types.""" __tablename__ = "instance_type_projects" __table_args__ = (schema.UniqueConstraint( "instance_type_id", "project_id", "deleted", name="uniq_instance_type_projects0instance_type_id0project_id0deleted" ), ) id = Column(Integer, primary_key=True) instance_type_id = Column(Integer, ForeignKey('instance_types.id'), nullable=False) project_id = Column(String(255)) instance_type = relationship( InstanceTypes, backref="projects", foreign_keys=instance_type_id, primaryjoin='and_(' 'InstanceTypeProjects.instance_type_id == InstanceTypes.id,' 'InstanceTypeProjects.deleted == 0)')
class WPTemplatePairing(db.Model, ToDictMixin): """Not quite a true association table (because it has ordinal data) between workout templates and piece templates (one-to-many with both)""" __tablename__ = "w_p_template_pairings" w_p_template_pairing_id = db.Column(db.Integer, primary_key=True, autoincrement=True) workout_template_id = db.Column(db.Integer, db.ForeignKey("workout_templates.workout_template_id"), nullable=False) piece_template_id = db.Column(db.Integer, db.ForeignKey("piece_templates.piece_template_id"), nullable=False) ordinal = db.Column(db.Integer, nullable=False) #this makes sure that two different pieces can't be the nth piece in a #given workout __table_args__ = (schema.UniqueConstraint(workout_template_id, ordinal),)
class Container(Base): """Represents a container.""" __tablename__ = 'container' __table_args__ = (schema.UniqueConstraint('uuid', name='uniq_container0uuid'), table_args()) id = Column(Integer, primary_key=True) project_id = Column(String(255)) user_id = Column(String(255)) uuid = Column(String(36)) container_id = Column(String(36)) name = Column(String(255)) image = Column(String(255)) cpu = Column(Float) command = Column(String(255)) memory = Column(String(255)) status = Column(String(20)) status_reason = Column(Text, nullable=True) task_state = Column(String(20)) environment = Column(JSONEncodedDict) workdir = Column(String(255)) ports = Column(JSONEncodedList) hostname = Column(String(63)) labels = Column(JSONEncodedDict) meta = Column(JSONEncodedDict) addresses = Column(JSONEncodedDict) image_pull_policy = Column(Text, nullable=True) host = Column(String(255)) restart_policy = Column(JSONEncodedDict) status_detail = Column(String(50)) interactive = Column(Boolean, default=False) image_driver = Column(String(255)) websocket_url = Column(String(255)) websocket_token = Column(String(255)) security_groups = Column(JSONEncodedList) auto_remove = Column(Boolean, default=False) runtime = Column(String(32)) disk = Column(Integer, default=0)
class InstanceGroup(API_BASE): """Represents an instance group. A group will maintain a collection of instances and the relationship between them. """ __tablename__ = 'instance_groups' __table_args__ = (schema.UniqueConstraint( 'uuid', name='uniq_instance_groups0uuid'), ) id = Column(Integer, primary_key=True, autoincrement=True) user_id = Column(String(255)) project_id = Column(String(255)) uuid = Column(String(36), nullable=False) name = Column(String(255)) _policies = orm.relationship( InstanceGroupPolicy, primaryjoin='InstanceGroup.id == InstanceGroupPolicy.group_id') _members = orm.relationship( InstanceGroupMember, primaryjoin='InstanceGroup.id == InstanceGroupMember.group_id') @property def policy(self): if len(self._policies) > 1: msg = ("More than one policy (%(policies)s) is associated with " "group %(group_name)s, only the first one in the list " "would be returned.") LOG.warning( msg, { "policies": [p.policy for p in self._policies], "group_name": self.name }) return self._policies[0] if self._policies else None @property def members(self): return [m.instance_uuid for m in self._members]
class ComputeNode(Base): """Represents a compute node. """ __tablename__ = 'compute_node' __table_args__ = (schema.UniqueConstraint( 'rp_uuid', name='uniq_compute_node0rp_uuid'), table_args()) uuid = Column(String(36), primary_key=True, nullable=False) rp_uuid = Column(String(36), nullable=False) hostname = Column(String(255), nullable=False) numa_topology = Column(JSONEncodedDict, nullable=True) mem_total = Column(Integer, nullable=False, default=0) mem_free = Column(Integer, nullable=False, default=0) mem_available = Column(Integer, nullable=False, default=0) mem_used = Column(Integer, nullable=False, default=0) total_containers = Column(Integer, nullable=False, default=0) running_containers = Column(Integer, nullable=False, default=0) paused_containers = Column(Integer, nullable=False, default=0) stopped_containers = Column(Integer, nullable=False, default=0) cpus = Column(Integer, nullable=False, default=0) cpu_used = Column(Float, nullable=False, default=0.0) architecture = Column(String(32), nullable=True) os_type = Column(String(32), nullable=True) os = Column(String(64), nullable=True) kernel_version = Column(String(128), nullable=True) labels = Column(JSONEncodedDict) # Json string PCI Stats # '[{"vendor_id":"8086", "product_id":"1234", "count":3 }, ...]' pci_stats = Column(Text) disk_total = Column(Integer, nullable=False, default=0) disk_used = Column(Integer, nullable=False, default=0) disk_quota_supported = Column(Boolean, nullable=False, default=sql.false(), server_default=sql.false()) runtimes = Column(JSONEncodedList, nullable=True) enable_cpu_pinning = Column(Boolean, nullable=False, default=sql.false(), server_default=sql.false())
class ProjectUserQuota(API_BASE): """Represents a single quota override for a user with in a project.""" __tablename__ = 'project_user_quotas' uniq_name = "uniq_project_user_quotas0user_id0project_id0resource" __table_args__ = (schema.UniqueConstraint("user_id", "project_id", "resource", name=uniq_name), Index('project_user_quotas_project_id_idx', 'project_id'), Index( 'project_user_quotas_user_id_idx', 'user_id', )) id = Column(Integer, primary_key=True, nullable=False) project_id = Column(String(255), nullable=False) user_id = Column(String(255), nullable=False) resource = Column(String(255), nullable=False) hard_limit = Column(Integer)
class GroupTypeProjects(BASE, CinderBase): """Represent projects associated group_types.""" __tablename__ = "group_type_projects" __table_args__ = (schema.UniqueConstraint( "group_type_id", "project_id", "deleted", name="uniq_group_type_projects0group_type_id0project_id0deleted"), ) id = Column(Integer, primary_key=True) group_type_id = Column(String, ForeignKey('group_types.id'), nullable=False) project_id = Column(String(255)) deleted = Column(Integer, default=0) group_type = relationship( GroupTypes, backref="projects", foreign_keys=group_type_id, primaryjoin='and_(' 'GroupTypeProjects.group_type_id == GroupTypes.id,' 'GroupTypeProjects.deleted == 0)')
class FlavorExtraSpecs(API_BASE): """Represents additional specs as key/value pairs for a flavor""" __tablename__ = 'flavor_extra_specs' __table_args__ = ( Index('flavor_extra_specs_flavor_id_key_idx', 'flavor_id', 'key'), schema.UniqueConstraint('flavor_id', 'key', name='uniq_flavor_extra_specs0flavor_id0key'), { 'mysql_collate': 'utf8_bin' }, ) id = Column(Integer, primary_key=True) key = Column(String(255), nullable=False) value = Column(String(255)) flavor_id = Column(Integer, ForeignKey('flavors.id'), nullable=False) flavor = orm.relationship( Flavors, backref='extra_specs', foreign_keys=flavor_id, primaryjoin=('FlavorExtraSpecs.flavor_id == Flavors.id'))
class InstanceTypeExtraSpecs(BASE, NovaBase): """Represents additional specs as key/value pairs for an instance_type.""" __tablename__ = 'instance_type_extra_specs' __table_args__ = ( Index('instance_type_extra_specs_instance_type_id_key_idx', 'instance_type_id', 'key'), schema.UniqueConstraint( "instance_type_id", "key", "deleted", name=("uniq_instance_type_extra_specs0" "instance_type_id0key0deleted") ), ) id = Column(Integer, primary_key=True) key = Column(String(255)) value = Column(String(255)) instance_type_id = Column(Integer, ForeignKey('instance_types.id'), nullable=False) instance_type = orm.relationship(InstanceTypes, backref="extra_specs", foreign_keys=instance_type_id, primaryjoin='and_(' 'InstanceTypeExtraSpecs.instance_type_id == InstanceTypes.id,' 'InstanceTypeExtraSpecs.deleted == 0)')
class Quota(BASE, NovaBase): """Represents a single quota override for a project. If there is no row for a given project id and resource, then the default for the quota class is used. If there is no row for a given quota class and resource, then the default for the deployment is used. If the row is present but the hard limit is Null, then the resource is unlimited. """ __tablename__ = 'quotas' __table_args__ = ( schema.UniqueConstraint("project_id", "resource", "deleted", name="uniq_quotas0project_id0resource0deleted" ), ) id = Column(Integer, primary_key=True) project_id = Column(String(255)) resource = Column(String(255), nullable=False) hard_limit = Column(Integer)
class Network(BASE, NovaBase): """Represents a network.""" __tablename__ = 'networks' __table_args__ = ( schema.UniqueConstraint("vlan", "deleted", name="uniq_networks0vlan0deleted"), ) id = Column(Integer, primary_key=True) label = Column(String(255)) injected = Column(Boolean, default=False) cidr = Column(types.CIDR(), unique=True) cidr_v6 = Column(types.CIDR(), unique=True) multi_host = Column(Boolean, default=False) gateway_v6 = Column(types.IPAddress()) netmask_v6 = Column(types.IPAddress()) netmask = Column(types.IPAddress()) bridge = Column(String(255)) bridge_interface = Column(String(255)) gateway = Column(types.IPAddress()) broadcast = Column(types.IPAddress()) dns1 = Column(types.IPAddress()) dns2 = Column(types.IPAddress()) vlan = Column(Integer) vpn_public_address = Column(types.IPAddress()) vpn_public_port = Column(Integer) vpn_private_address = Column(types.IPAddress()) dhcp_start = Column(types.IPAddress()) rxtx_base = Column(Integer) project_id = Column(String(255)) priority = Column(Integer) host = Column(String(255)) # , ForeignKey('hosts.id')) uuid = Column(String(36))
def define_tables(cls, metadata): Table( 'users', metadata, Column('id', Integer, primary_key=True), Column('name', String(50)) ) class SpecialType(sqltypes.TypeDecorator): impl = String def process_bind_param(self, value, dialect): return value + " processed" Table( 'bind_targets', metadata, Column('id', Integer, primary_key=True), Column('data', SpecialType()) ) users_xtra = Table( 'users_xtra', metadata, Column('id', Integer, primary_key=True), Column('name', String(50)), Column('login_email', String(50)), Column('lets_index_this', String(50)) ) cls.unique_partial_index = schema.Index( 'idx_unique_partial_name', users_xtra.c.name, users_xtra.c.lets_index_this, unique=True, postgresql_where=users_xtra.c.lets_index_this == 'unique_name') cls.unique_constraint = schema.UniqueConstraint( users_xtra.c.login_email, name='uq_login_email') cls.bogus_index = schema.Index( 'idx_special_ops', users_xtra.c.lets_index_this, postgresql_where=users_xtra.c.lets_index_this > 'm')
class SplitResult(db.Model, ToDictMixin): """Split results (many-to-one with piece_results)""" __tablename__ = "split_results" split_result_id = db.Column(db.Integer, primary_key=True, autoincrement=True) piece_result_id = db.Column(db.Integer, db.ForeignKey("piece_results.piece_result_id"), nullable=False) ordinal = db.Column(db.Integer, nullable=False) label = db.Column(db.String(64)) time_seconds = db.Column(db.Integer) meters = db.Column(db.Integer) avg_split_seconds = db.Column(db.Integer) avg_SR = db.Column(db.Integer) avg_watts = db.Column(db.Integer) avg_HR = db.Column(db.Integer) comments = db.Column(db.UnicodeText) #one (piece result) to many (split results) piece_result = db.relationship("PieceResult", backref=db.backref("split_results", order_by="split_results.ordinal")) #this makes sure that two different splits can't be the nth split in a #given piece __table_args__ = (schema.UniqueConstraint(piece_result_id, ordinal),) def __repr__(self): """Output the object's values when it's printed""" repr_string = ("<SplitResult id: {id}, " + "piece_result_id:{piece_result_id}>" + "(split # {ordinal})>") return repr_string.format(id=self.split_result_id, piece_result_id=self.piece_result_id, ordinal=self.ordinal)