Add resource DB model definition
Add models: 1.Host 2.HostResourceUsage 3.VM 4.VmResourceUsage 5.VmMigration 6.HostState 7.HostOverload Change-Id: Icfa44e9eb74961e0db12d46b5907f7126d22abf2
This commit is contained in:
parent
219d6c1b23
commit
7fb1df7d04
@ -48,21 +48,22 @@ class TerracottaBase(models.TimestampMixin,
|
|||||||
class Host(BASE, TerracottaBase):
|
class Host(BASE, TerracottaBase):
|
||||||
__tablename__ = 'hosts'
|
__tablename__ = 'hosts'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
host_name = Column(String(255))
|
host_name = Column(String(255), nullable=False)
|
||||||
cpu_mhz = Column(String(255))
|
cpu_mhz = Column(String(255), nullable=False)
|
||||||
cpu_cores = Column(String(255))
|
cpu_cores = Column(String(255), nullable=False)
|
||||||
cpu_vendor = Column(String(255))
|
cpu_vendor = Column(String(255), nullable=True)
|
||||||
ram = Column(Integer, nullable=False, default=0)
|
ram = Column(Integer, nullable=False, default=0)
|
||||||
disabled = Column(Boolean, default=False)
|
disabled = Column(Boolean, default=False)
|
||||||
disabled_reason = Column(String(255))
|
disabled_reason = Column(String(255), nullable=True)
|
||||||
|
|
||||||
|
|
||||||
class HostResourceUsage(BASE, TerracottaBase):
|
class HostResourceUsage(BASE, TerracottaBase):
|
||||||
__tablename__ = 'host_resource_usage'
|
__tablename__ = 'host_resource_usage'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
host_id = Column(String(255))
|
host_id = Column(String(255), nullable=False)
|
||||||
cpu_mhz = Column(String(255))
|
cpu_mhz = Column(String(255), nullable=False)
|
||||||
|
time_stamp = Column(DateTime)
|
||||||
|
|
||||||
host = relationship(Host, backref="host_resource_usage",
|
host = relationship(Host, backref="host_resource_usage",
|
||||||
foreign_keys=host_id,
|
foreign_keys=host_id,
|
||||||
primaryjoin='HostResourceUsage.host_id == Host.id')
|
primaryjoin='HostResourceUsage.host_id == Host.id')
|
||||||
@ -76,9 +77,50 @@ class VM(BASE, TerracottaBase):
|
|||||||
class VmResourceUsage(BASE, TerracottaBase):
|
class VmResourceUsage(BASE, TerracottaBase):
|
||||||
__tablename__ = 'vm_resource_usage'
|
__tablename__ = 'vm_resource_usage'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
vm_id = Column(String(255))
|
vm_id = Column(String(255), nullable=False)
|
||||||
cpu_mhz = Column(String(255))
|
cpu_mhz = Column(String(255))
|
||||||
|
time_stamp = Column(DateTime)
|
||||||
host = relationship(Host, backref="vm_resource_usage",
|
|
||||||
|
host = relationship(VM, backref="vm_resource_usage",
|
||||||
foreign_keys=vm_id,
|
foreign_keys=vm_id,
|
||||||
primaryjoin='VmResourceUsage.vm_id == VM.id')
|
primaryjoin='VmResourceUsage.vm_id == VM.id')
|
||||||
|
|
||||||
|
|
||||||
|
class VmMigration(BASE, TerracottaBase):
|
||||||
|
__tablename__ = 'vm_migrations'
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
vm_id = Column(String(255), nullable=False)
|
||||||
|
host_id = Column(String(255), nullable=False)
|
||||||
|
time_stamp = Column(DateTime)
|
||||||
|
|
||||||
|
vm = relationship(VM, backref="vm_migrations",
|
||||||
|
foreign_keys=vm_id,
|
||||||
|
primaryjoin='vm_migrations.vm_id == VM.id')
|
||||||
|
|
||||||
|
host = relationship(Host, backref="vm_migrations",
|
||||||
|
foreign_keys=host_id,
|
||||||
|
primaryjoin='vm_migrations.host_id == Host.id')
|
||||||
|
|
||||||
|
|
||||||
|
class HostState(BASE, TerracottaBase):
|
||||||
|
__tablename__ = 'host_states'
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
state = Column(Integer, nullable=False)
|
||||||
|
host_id = Column(String(255), nullable=False)
|
||||||
|
time_stamp = Column(DateTime)
|
||||||
|
|
||||||
|
host = relationship(Host, backref="host_states",
|
||||||
|
foreign_keys=host_id,
|
||||||
|
primaryjoin='host_states.host_id == Host.id')
|
||||||
|
|
||||||
|
|
||||||
|
class HostOverload(BASE, TerracottaBase):
|
||||||
|
__tablename__ = 'host_overload'
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
host_id = Column(String(255), nullable=False)
|
||||||
|
time_stamp = Column(DateTime)
|
||||||
|
state = Column(Integer, nullable=False)
|
||||||
|
|
||||||
|
host = relationship(Host, backref="host_overload",
|
||||||
|
foreign_keys=host_id,
|
||||||
|
primaryjoin='host_overload.host_id == Host.id')
|
Loading…
x
Reference in New Issue
Block a user