summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-21 00:31:58 +0000
committerGerrit Code Review <review@openstack.org>2013-02-21 00:31:58 +0000
commitb4488e3722015dd9b0475642c321ac46db4eedfc (patch)
tree8d69c568836108194c772a67c01f7145673bbf70 /nova/virt
parent65d315929d64fcf199271a21c62c4cd2649556fc (diff)
parent63285645c72d3a5dcb232b5a129cf99602f2a607 (diff)
Merge "Baremetal driver returns accurate list of instance"
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py37
-rw-r--r--nova/virt/baremetal/db/sqlalchemy/models.py1
-rwxr-xr-xnova/virt/baremetal/driver.py16
3 files changed, 41 insertions, 13 deletions
diff --git a/nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py b/nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py
new file mode 100644
index 000000000..68fbe0960
--- /dev/null
+++ b/nova/virt/baremetal/db/sqlalchemy/migrate_repo/versions/004_add_instance_name_to_bm_nodes.py
@@ -0,0 +1,37 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# 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 Column, MetaData, String, Table
+
+
+def upgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+
+ t = Table('bm_nodes', meta, autoload=True)
+ name_col = Column('instance_name', String(255))
+ t.create_column(name_col)
+
+
+def downgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+
+ t = Table('bm_nodes', meta, autoload=True)
+ name_col = Column('instance_name', String(length=255))
+
+ t.drop_column(name_col)
diff --git a/nova/virt/baremetal/db/sqlalchemy/models.py b/nova/virt/baremetal/db/sqlalchemy/models.py
index e1a8ebb3a..756376cb7 100644
--- a/nova/virt/baremetal/db/sqlalchemy/models.py
+++ b/nova/virt/baremetal/db/sqlalchemy/models.py
@@ -37,6 +37,7 @@ class BareMetalNode(BASE, models.NovaBase):
uuid = Column(String(36))
service_host = Column(String(255))
instance_uuid = Column(String(36), nullable=True)
+ instance_name = Column(String(255), nullable=True)
cpus = Column(Integer)
memory_mb = Column(Integer)
local_gb = Column(Integer)
diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py
index b95a3ad61..8dff0a785 100755
--- a/nova/virt/baremetal/driver.py
+++ b/nova/virt/baremetal/driver.py
@@ -102,6 +102,7 @@ def _update_state(context, node, instance, state):
values = {'task_state': state}
if not instance:
values['instance_uuid'] = None
+ values['instance_name'] = None
db.bm_node_update(context, node['id'], values)
@@ -170,19 +171,7 @@ class BareMetalDriver(driver.ComputeDriver):
l = []
context = nova_context.get_admin_context()
for node in db.bm_node_get_associated(context, service_host=CONF.host):
- if not node['instance_uuid']:
- # Not currently assigned to an instance.
- continue
- try:
- inst = self.virtapi.instance_get_by_uuid(
- context, node['instance_uuid'])
- except exception.InstanceNotFound:
- # Assigned to an instance that no longer exists.
- LOG.warning(_("Node %(id)r assigned to instance %(uuid)r "
- "which cannot be found."),
- dict(id=node['id'], uuid=node['instance_uuid']))
- continue
- l.append(inst['name'])
+ l.append(node['instance_name'])
return l
def _require_node(self, instance):
@@ -244,6 +233,7 @@ class BareMetalDriver(driver.ComputeDriver):
# allocates this node before we begin provisioning it.
node = db.bm_node_associate_and_update(context, node_uuid,
{'instance_uuid': instance['uuid'],
+ 'instance_name': instance['hostname'],
'task_state': baremetal_states.BUILDING})
try: