From d8adce2e4a20915298804cff72bd60453be640d4 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sat, 8 Jun 2013 12:38:47 +0400 Subject: Fix db.models.ComputeNode description DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table There is no indexes in ComputeNode model definition. blueprint db-sync-models-with-migrations Change-Id: I13c92bdd33eede97bb7b2fc45cbedca556992060 --- nova/db/sqlalchemy/models.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'nova/db/sqlalchemy/models.py') diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 418e05cfa..d52f68740 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -59,8 +59,9 @@ class ComputeNode(BASE, NovaBase): """Represents a running compute service on a host.""" __tablename__ = 'compute_nodes' + __table_args__ = () id = Column(Integer, primary_key=True) - service_id = Column(Integer, ForeignKey('services.id'), nullable=True) + service_id = Column(Integer, ForeignKey('services.id'), nullable=False) service = relationship(Service, backref=backref('compute_node'), foreign_keys=service_id, @@ -68,23 +69,23 @@ class ComputeNode(BASE, NovaBase): 'ComputeNode.service_id == Service.id,' 'ComputeNode.deleted == 0)') - vcpus = Column(Integer) - memory_mb = Column(Integer) - local_gb = Column(Integer) - vcpus_used = Column(Integer) - memory_mb_used = Column(Integer) - local_gb_used = Column(Integer) - hypervisor_type = Column(Text) - hypervisor_version = Column(Integer) - hypervisor_hostname = Column(String(255)) + vcpus = Column(Integer, nullable=False) + memory_mb = Column(Integer, nullable=False) + local_gb = Column(Integer, nullable=False) + vcpus_used = Column(Integer, nullable=False) + memory_mb_used = Column(Integer, nullable=False) + local_gb_used = Column(Integer, nullable=False) + hypervisor_type = Column(Text, nullable=False) + hypervisor_version = Column(Integer, nullable=False) + hypervisor_hostname = Column(String(255), nullable=True) # Free Ram, amount of activity (resize, migration, boot, etc) and # the number of running VM's are a good starting point for what's # important when making scheduling decisions. - free_ram_mb = Column(Integer) - free_disk_gb = Column(Integer) - current_workload = Column(Integer) - running_vms = Column(Integer) + free_ram_mb = Column(Integer, nullable=True) + free_disk_gb = Column(Integer, nullable=True) + current_workload = Column(Integer, nullable=True) + running_vms = Column(Integer, nullable=True) # Note(masumotok): Expected Strings example: # @@ -97,7 +98,7 @@ class ComputeNode(BASE, NovaBase): # above, since it is copied from tag of getCapabilities() # (See libvirt.virtConnection). cpu_info = Column(Text, nullable=True) - disk_available_least = Column(Integer) + disk_available_least = Column(Integer, nullable=True) class ComputeNodeStat(BASE, NovaBase): -- cgit