summaryrefslogtreecommitdiff
path: root/nova/db
diff options
context:
space:
mode:
authorSylvain Bauza <sbauza@redhat.com>2015-08-20 17:12:47 -0700
committerSylvain Bauza <sbauza@redhat.com>2015-08-31 15:21:21 +0200
commitf4138f69cc88a576f188ce665b2ac699ae232ad3 (patch)
treef1594a0a4073fe9d6ce67001a167d419e5182424 /nova/db
parent48d333cecbe072b340490f946138b51c75f8218d (diff)
downloadnova-f4138f69cc88a576f188ce665b2ac699ae232ad3.tar.gz
Add cpu_allocation_ratio and ram_allocation_ratio to ComputeNode
As we want to provide a per-compute allocation ratio for both CPU and RAM, we need to persist them to the compute_nodes table and add them to the ComputeNode object. Note: Since we need to provide a compatibility path for upgrades and as we don't want to ask the operators to change their config files before upgrading, we then verify the allocation ratio value to match if defaulted and then return an hardcoded value identitical to the behaviour we want. In order to know if the compute related opt values were updated, we plan to change the ratios defaults with 0.0 in a later change (I382421968d4c7989a6ff08c74c21139bf6be12e5) hence the if branch in the object. Change-Id: I83074644c35e151927c23f6d7d50c9dc32e9bd2d Partially-Implements: blueprint allocation-ratio-to-resource-tracker
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/301_add_cpu_and_ram_ratios_for_compute_nodes.py29
-rw-r--r--nova/db/sqlalchemy/models.py4
2 files changed, 33 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/301_add_cpu_and_ram_ratios_for_compute_nodes.py b/nova/db/sqlalchemy/migrate_repo/versions/301_add_cpu_and_ram_ratios_for_compute_nodes.py
new file mode 100644
index 0000000000..fc13d155b5
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/301_add_cpu_and_ram_ratios_for_compute_nodes.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2015 Red Hat, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from sqlalchemy import Float, Column, MetaData, Table
+
+
+def upgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+
+ cn = Table('compute_nodes', meta, autoload=True)
+ shadow_cn = Table('shadow_compute_nodes', meta, autoload=True)
+ cn.create_column(Column('ram_allocation_ratio', Float, nullable=True))
+ cn.create_column(Column('cpu_allocation_ratio', Float, nullable=True))
+ shadow_cn.create_column(Column('ram_allocation_ratio', Float))
+ shadow_cn.create_column(Column('cpu_allocation_ratio', Float))
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 1d4976f941..2e1d1b640e 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -172,6 +172,10 @@ class ComputeNode(BASE, NovaBase):
# objects.NUMATopoloogy._to_json()
numa_topology = Column(Text)
+ # allocation ratios provided by the RT
+ ram_allocation_ratio = Column(Float, nullable=True)
+ cpu_allocation_ratio = Column(Float, nullable=True)
+
class Certificate(BASE, NovaBase):
"""Represents a x509 certificate."""