Merge "Ironic nodes with instance_uuid are not available"

This commit is contained in:
Jenkins 2016-05-31 02:20:26 +00:00 committed by Gerrit Code Review
commit f9a9158db5
2 changed files with 11 additions and 3 deletions

View File

@ -665,14 +665,20 @@ class IronicDriverTestCase(test.NoDBTestCase):
# a node in deleted
{'uuid': uuidutils.generate_uuid(),
'power_state': ironic_states.POWER_ON,
'provision_state': ironic_states.DELETED}
'provision_state': ironic_states.DELETED},
# a node in AVAILABLE with an instance uuid
{'uuid': uuidutils.generate_uuid(),
'instance_uuid': uuidutils.generate_uuid(),
'power_state': ironic_states.POWER_OFF,
'provision_state': ironic_states.AVAILABLE}
]
for n in node_dicts:
node = ironic_utils.get_test_node(**n)
self.assertTrue(self.driver._node_resources_unavailable(node))
for ok_state in (ironic_states.AVAILABLE, ironic_states.NOSTATE):
# these are both ok and should present as available
# these are both ok and should present as available as they
# have no instance_uuid
avail_node = ironic_utils.get_test_node(
power_state=ironic_states.POWER_OFF,
provision_state=ok_state)

View File

@ -179,7 +179,9 @@ class IronicDriver(virt_driver.ComputeDriver):
ironic_states.AVAILABLE, ironic_states.NOSTATE]
return (node_obj.maintenance or
node_obj.power_state in bad_power_states or
node_obj.provision_state not in good_provision_states)
node_obj.provision_state not in good_provision_states or
(node_obj.provision_state in good_provision_states and
node_obj.instance_uuid is not None))
def _node_resources_used(self, node_obj):
"""Determine whether the node's resources are currently used.