summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-10-11 12:18:09 -0500
committerJosh Kearney <josh@jk0.org>2011-10-11 13:46:32 -0500
commitd6b6cc516232f8306df5c4527c7e12ac7b5fd785 (patch)
tree97df8af6a633aa27cb4fcf55b019a8880c5def40
parent56be39aedb195576179e73c859db2271a9585496 (diff)
Adds vcpu_weight column to instance_types table and uses this value when building XenServer instances.
Fixes bug 861776. Change-Id: I88b22b6959164e21a7150580d5f8da6920ed8610
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py32
-rw-r--r--nova/virt/xenapi/vm_utils.py6
2 files changed, 37 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py b/nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py
new file mode 100644
index 000000000..a9aa0b137
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py
@@ -0,0 +1,32 @@
+# Copyright 2011 OpenStack LLC.
+#
+# 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 Column, Integer, MetaData, Table, Boolean
+
+meta = MetaData()
+
+instance_types = Table("instance_types", meta, Column("id", Integer(),
+ primary_key=True, nullable=False))
+
+vcpu_weight = Column("vcpu_weight", Integer())
+
+
+def upgrade(migrate_engine):
+ meta.bind = migrate_engine
+ instance_types.create_column(vcpu_weight)
+
+
+def downgrade(migrate_engine):
+ meta.bind = migrate_engine
+ instance_types.drop_column(vcpu_weight)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 51f102689..8230afbf6 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -126,11 +126,11 @@ class VMHelper(HelperBase):
3. Using hardware virtualization
"""
-
inst_type_id = instance.instance_type_id
instance_type = instance_types.get_instance_type(inst_type_id)
mem = str(long(instance_type['memory_mb']) * 1024 * 1024)
vcpus = str(instance_type['vcpus'])
+
rec = {
'actions_after_crash': 'destroy',
'actions_after_reboot': 'restart',
@@ -167,6 +167,10 @@ class VMHelper(HelperBase):
'VCPUs_max': vcpus,
'VCPUs_params': {},
'xenstore_data': {}}
+
+ if instance_type.get("vcpu_weight"):
+ rec["VCPUs_params"]["weight"] = instance_type["vcpu_weight"]
+
# Complete VM configuration record according to the image type
# non-raw/raw with PV kernel/raw in HVM mode
if use_pv_kernel: