diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-01-10 01:49:02 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-01-10 01:49:02 +0000 |
commit | 1bb49bf4fcba690808ce17a08efe144165bcd904 (patch) | |
tree | 44ba47295cf3854c2f93162c3f0675d613abaa49 | |
parent | 664ea40ebb0ee29a5fd11effeeed279ddc543f89 (diff) | |
parent | 37293192c6ae7b841ded4fbccd4d5b36cc89fbaa (diff) | |
download | nova-1bb49bf4fcba690808ce17a08efe144165bcd904.tar.gz nova-1bb49bf4fcba690808ce17a08efe144165bcd904.tar.xz nova-1bb49bf4fcba690808ce17a08efe144165bcd904.zip |
Merge "Cope better with out of sync bm data."
-rw-r--r-- | nova/virt/baremetal/driver.py | 18 |
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, |