Add proper return value for validate_node
Change-Id: I361c520e6697750137e86d32dc3890fd8af4a99c
This commit is contained in:
parent
4b5754fd5a
commit
592ac2c7d0
|
@ -9384,20 +9384,33 @@ class OpenStackCloud(
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_node(self, uuid):
|
def validate_node(self, uuid):
|
||||||
# TODO(TheJulia): There are soooooo many other interfaces
|
"""Returns node validation information
|
||||||
# that we can support validating, while these are essential,
|
|
||||||
# we should support more.
|
:param string uuid: A UUID value representing the baremetal node.
|
||||||
# TODO(TheJulia): Add a doc string :(
|
|
||||||
|
:raises: OpenStackCloudException on operation error or
|
||||||
|
if deploy and power informations are not present.
|
||||||
|
|
||||||
|
:returns: dict containing validation information for each
|
||||||
|
interface: boot, console, deploy, inspect, management,
|
||||||
|
network, power, raid, rescue, storage, ...
|
||||||
|
"""
|
||||||
msg = ("Failed to query the API for validation status of "
|
msg = ("Failed to query the API for validation status of "
|
||||||
"node {node_id}").format(node_id=uuid)
|
"node {node_id}").format(node_id=uuid)
|
||||||
url = '/nodes/{node_id}/validate'.format(node_id=uuid)
|
url = '/nodes/{node_id}/validate'.format(node_id=uuid)
|
||||||
ifaces = self._baremetal_client.get(url, error_message=msg)
|
validate_resp = self._baremetal_client.get(url, error_message=msg)
|
||||||
|
is_deploy_valid = validate_resp.get(
|
||||||
if not ifaces['deploy'] or not ifaces['power']:
|
'deploy', {'result': False}).get('result', False)
|
||||||
|
is_power_valid = validate_resp.get(
|
||||||
|
'power', {'result': False}).get('result', False)
|
||||||
|
if not is_deploy_valid or not is_power_valid:
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"ironic node %s failed to validate. "
|
"ironic node {} failed to validate. "
|
||||||
"(deploy: %s, power: %s)" % (ifaces['deploy'],
|
"(deploy: {}, power: {})".format(
|
||||||
ifaces['power']))
|
uuid,
|
||||||
|
validate_resp.get('deploy'),
|
||||||
|
validate_resp.get('power')))
|
||||||
|
return validate_resp
|
||||||
|
|
||||||
def node_set_provision_state(self,
|
def node_set_provision_state(self,
|
||||||
name_or_id,
|
name_or_id,
|
||||||
|
|
|
@ -115,40 +115,39 @@ class TestBaremetalNode(base.IronicTestCase):
|
||||||
'validate']),
|
'validate']),
|
||||||
json=validate_return),
|
json=validate_return),
|
||||||
])
|
])
|
||||||
self.op_cloud.validate_node(self.fake_baremetal_node['uuid'])
|
validate_resp = self.op_cloud.validate_node(
|
||||||
|
self.fake_baremetal_node['uuid'])
|
||||||
|
self.assertDictEqual(validate_return, validate_resp)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
# FIXME(TheJulia): So, this doesn't presently fail, but should fail.
|
def test_validate_node_raises_exception(self):
|
||||||
# Placing the test here, so we can sort out the issue in the actual
|
validate_return = {
|
||||||
# method later.
|
'deploy': {
|
||||||
# def test_validate_node_raises_exception(self):
|
'result': False,
|
||||||
# validate_return = {
|
'reason': 'error!',
|
||||||
# 'deploy': {
|
},
|
||||||
# 'result': False,
|
'power': {
|
||||||
# 'reason': 'error!',
|
'result': False,
|
||||||
# },
|
'reason': 'meow!',
|
||||||
# 'power': {
|
},
|
||||||
# 'result': False,
|
'foo': {
|
||||||
# 'reason': 'meow!',
|
'result': True
|
||||||
# },
|
}}
|
||||||
# 'foo': {
|
self.register_uris([
|
||||||
# 'result': True
|
dict(method='GET',
|
||||||
# }}
|
uri=self.get_mock_url(
|
||||||
# self.register_uris([
|
resource='nodes',
|
||||||
# dict(method='GET',
|
append=[self.fake_baremetal_node['uuid'],
|
||||||
# uri=self.get_mock_url(
|
'validate']),
|
||||||
# resource='nodes',
|
json=validate_return),
|
||||||
# append=[self.fake_baremetal_node['uuid'],
|
])
|
||||||
# 'validate']),
|
self.assertRaisesRegexp(
|
||||||
# json=validate_return),
|
exc.OpenStackCloudException,
|
||||||
# ])
|
'^ironic node .* failed to validate.*',
|
||||||
# self.assertRaises(
|
self.op_cloud.validate_node,
|
||||||
# Exception,
|
self.fake_baremetal_node['uuid'])
|
||||||
# self.op_cloud.validate_node,
|
|
||||||
# self.fake_baremetal_node['uuid'])
|
self.assert_calls()
|
||||||
#
|
|
||||||
# self.assert_calls()
|
|
||||||
|
|
||||||
def test_patch_machine(self):
|
def test_patch_machine(self):
|
||||||
test_patch = [{
|
test_patch = [{
|
||||||
|
|
Loading…
Reference in New Issue