summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/virt/baremetal/driver.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py
index bb76954e1..428f87735 100644
--- a/nova/virt/baremetal/driver.py
+++ b/nova/virt/baremetal/driver.py
@@ -169,11 +169,19 @@ class BareMetalDriver(driver.ComputeDriver):
l = []
ctx = nova_context.get_admin_context()
for node in _get_baremetal_nodes(ctx):
- if node['instance_uuid']:
- inst = self.virtapi.instance_get_by_uuid(ctx,
- node['instance_uuid'])
- if inst:
- l.append(inst['name'])
+ if not node['instance_uuid']:
+ # Not currently assigned to an instance.
+ continue
+ try:
+ inst = self.virtapi.instance_get_by_uuid(
+ ctx, 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'])
return l
def spawn(self, context, instance, image_meta, injected_files,