Merge "Consistent normalization of Machine objects in the cloud layer" into stable/train
This commit is contained in:
commit
211bdc68d1
|
@ -68,7 +68,7 @@ class BaremetalCloudMixin(_normalize.Normalizer):
|
||||||
|
|
||||||
:returns: list of ``munch.Munch`` representing machines.
|
:returns: list of ``munch.Munch`` representing machines.
|
||||||
"""
|
"""
|
||||||
return [self._normalize_machine(node._to_munch())
|
return [self._normalize_machine(node)
|
||||||
for node in self.baremetal.nodes()]
|
for node in self.baremetal.nodes()]
|
||||||
|
|
||||||
def get_machine(self, name_or_id):
|
def get_machine(self, name_or_id):
|
||||||
|
@ -83,8 +83,7 @@ class BaremetalCloudMixin(_normalize.Normalizer):
|
||||||
nodes are found.
|
nodes are found.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self._normalize_machine(
|
return self._normalize_machine(self.baremetal.get_node(name_or_id))
|
||||||
self.baremetal.get_node(name_or_id)._to_munch())
|
|
||||||
except exc.OpenStackCloudResourceNotFound:
|
except exc.OpenStackCloudResourceNotFound:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -159,7 +158,7 @@ class BaremetalCloudMixin(_normalize.Normalizer):
|
||||||
wait=True,
|
wait=True,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
|
|
||||||
return node._to_munch()
|
return self._normalize_machine(node)
|
||||||
|
|
||||||
def register_machine(self, nics, wait=False, timeout=3600,
|
def register_machine(self, nics, wait=False, timeout=3600,
|
||||||
lock_timeout=600, **kwargs):
|
lock_timeout=600, **kwargs):
|
||||||
|
@ -477,7 +476,7 @@ class BaremetalCloudMixin(_normalize.Normalizer):
|
||||||
change_list = [change['path'] for change in patch]
|
change_list = [change['path'] for change in patch]
|
||||||
node = self.baremetal.update_node(machine, **attrs)
|
node = self.baremetal.update_node(machine, **attrs)
|
||||||
return dict(
|
return dict(
|
||||||
node=self._normalize_machine(node._to_munch()),
|
node=self._normalize_machine(node),
|
||||||
changes=change_list
|
changes=change_list
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -573,7 +572,7 @@ class BaremetalCloudMixin(_normalize.Normalizer):
|
||||||
node = self.baremetal.set_node_provision_state(
|
node = self.baremetal.set_node_provision_state(
|
||||||
name_or_id, target=state, config_drive=configdrive,
|
name_or_id, target=state, config_drive=configdrive,
|
||||||
wait=wait, timeout=timeout)
|
wait=wait, timeout=timeout)
|
||||||
return node._to_munch()
|
return self._normalize_machine(node)
|
||||||
|
|
||||||
def set_machine_maintenance_state(
|
def set_machine_maintenance_state(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -1168,13 +1168,14 @@ class Normalizer(object):
|
||||||
|
|
||||||
def _normalize_machine(self, machine):
|
def _normalize_machine(self, machine):
|
||||||
"""Normalize Ironic Machine"""
|
"""Normalize Ironic Machine"""
|
||||||
machine = machine.copy()
|
if isinstance(machine, resource.Resource):
|
||||||
|
machine = machine._to_munch()
|
||||||
|
else:
|
||||||
|
machine = machine.copy()
|
||||||
|
|
||||||
# Discard noise
|
# Discard noise
|
||||||
self._remove_novaclient_artifacts(machine)
|
self._remove_novaclient_artifacts(machine)
|
||||||
|
|
||||||
# TODO(mordred) Normalize this resource
|
|
||||||
|
|
||||||
return machine
|
return machine
|
||||||
|
|
||||||
def _normalize_roles(self, roles):
|
def _normalize_roles(self, roles):
|
||||||
|
|
|
@ -213,8 +213,9 @@ class TestBaremetalNode(base.IronicTestCase):
|
||||||
json=self.fake_baremetal_node,
|
json=self.fake_baremetal_node,
|
||||||
validate=dict(json=test_patch)),
|
validate=dict(json=test_patch)),
|
||||||
])
|
])
|
||||||
self.cloud.patch_machine(
|
result = self.cloud.patch_machine(
|
||||||
self.fake_baremetal_node['uuid'], test_patch)
|
self.fake_baremetal_node['uuid'], test_patch)
|
||||||
|
self.assertEqual(self.fake_baremetal_node['uuid'], result['uuid'])
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
|
@ -759,10 +760,11 @@ class TestBaremetalNode(base.IronicTestCase):
|
||||||
append=[self.fake_baremetal_node['uuid']]),
|
append=[self.fake_baremetal_node['uuid']]),
|
||||||
json=self.fake_baremetal_node),
|
json=self.fake_baremetal_node),
|
||||||
])
|
])
|
||||||
self.cloud.node_set_provision_state(
|
result = self.cloud.node_set_provision_state(
|
||||||
self.fake_baremetal_node['uuid'],
|
self.fake_baremetal_node['uuid'],
|
||||||
'active',
|
'active',
|
||||||
configdrive='http://host/file')
|
configdrive='http://host/file')
|
||||||
|
self.assertEqual(self.fake_baremetal_node['uuid'], result['uuid'])
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes normalization of bare metal machines in the ``patch_machine`` call.
|
Loading…
Reference in New Issue