cloud: rename with deprecation validate_node -> validate_machine

Most of other cloud methods call nodes "machines". The new call also
has an ability to only validate the power interface.

Change-Id: I35f0521a57342dc888c00790935f20de230d6de5
This commit is contained in:
Dmitry Tantsur 2018-10-10 15:07:15 +02:00
parent 9db8bae0a1
commit 7b8a2e0cd2
3 changed files with 83 additions and 11 deletions

View File

@ -9941,9 +9941,25 @@ class OpenStackCloud(_normalize.Normalizer):
vif_ids = self.baremetal.list_node_vifs(machine)
return [self.get_port(vif) for vif in vif_ids]
def validate_machine(self, name_or_id, for_deploy=True):
"""Validate parameters of the machine.
:param string name_or_id: The Name or UUID value representing the
baremetal node.
:param bool for_deploy: If ``True``, validate readiness for deployment,
otherwise validate only the power management
properties.
:raises: :exc:`~openstack.exceptions.ValidationException`
"""
if for_deploy:
ifaces = ('boot', 'deploy', 'management', 'power')
else:
ifaces = ('power',)
self.baremetal.validate_node(name_or_id, required=ifaces)
def validate_node(self, uuid):
# TODO(dtantsur): deprecate this short method in favor of a fully
# written validate_machine call.
warnings.warn('validate_node is deprecated, please use '
'validate_machine instead', DeprecationWarning)
self.baremetal.validate_node(uuid)
def node_set_provision_state(self,

View File

@ -92,13 +92,64 @@ class TestBaremetalNode(base.IronicTestCase):
self.fake_baremetal_node['uuid'])
self.assert_calls()
def test_validate_node(self):
def test_validate_machine(self):
# NOTE(TheJulia): Note: These are only the interfaces
# that are validated, and both must be true for an
# that are validated, and all must be true for an
# exception to not be raised.
# This should be fixed at some point, as some interfaces
# are important in some cases and should be validated,
# such as storage.
validate_return = {
'boot': {
'result': True,
},
'deploy': {
'result': True,
},
'management': {
'result': True,
},
'power': {
'result': True,
},
'foo': {
'result': False,
}}
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
resource='nodes',
append=[self.fake_baremetal_node['uuid'],
'validate']),
json=validate_return),
])
self.cloud.validate_machine(self.fake_baremetal_node['uuid'])
self.assert_calls()
def test_validate_machine_not_for_deploy(self):
validate_return = {
'deploy': {
'result': False,
'reason': 'Not ready',
},
'power': {
'result': True,
},
'foo': {
'result': False,
}}
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
resource='nodes',
append=[self.fake_baremetal_node['uuid'],
'validate']),
json=validate_return),
])
self.cloud.validate_machine(self.fake_baremetal_node['uuid'],
for_deploy=False)
self.assert_calls()
def test_deprecated_validate_node(self):
validate_return = {
'deploy': {
'result': True,
@ -121,15 +172,15 @@ class TestBaremetalNode(base.IronicTestCase):
self.assert_calls()
def test_validate_node_raises_exception(self):
def test_validate_machine_raises_exception(self):
validate_return = {
'deploy': {
'result': False,
'reason': 'error!',
},
'power': {
'result': False,
'reason': 'meow!',
'result': True,
'reason': None,
},
'foo': {
'result': True
@ -144,7 +195,7 @@ class TestBaremetalNode(base.IronicTestCase):
])
self.assertRaises(
exceptions.ValidationException,
self.cloud.validate_node,
self.cloud.validate_machine,
self.fake_baremetal_node['uuid'])
self.assert_calls()

View File

@ -0,0 +1,5 @@
---
deprecations:
- |
The ``OpenStackCloud.validate_node`` call was deprecated in favor of
``OpenStackCloud.validate_machine``.