Add super basic machine normalization

In prep for ironic_client conversion to REST, make sure we're
removing the novaclient artifacts.

Change-Id: I8ef1c5e87492310821c1a0e8ab7e2144c6a10dbc
This commit is contained in:
Monty Taylor 2017-05-11 21:08:38 -04:00
parent fcaf06c3f2
commit ef35f02ea6
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 23 additions and 3 deletions

View File

@ -1014,3 +1014,21 @@ class Normalizer(object):
name=ret['name'], id=ret['id'])
ret['properties'] = stack
return ret
def _normalize_machines(self, machines):
"""Normalize Ironic Machines"""
ret = []
for machine in machines:
ret.append(self._normalize_machine(machine))
return ret
def _normalize_machine(self, machine):
"""Normalize Ironic Machine"""
machine = machine.copy()
# Discard noise
self._remove_novaclient_artifacts(machine)
# TODO(mordred) Normalize this resource
return machine

View File

@ -76,7 +76,8 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
return None
def list_machines(self):
return self.manager.submit_task(_tasks.MachineNodeList())
return self._normalize_machines(
self.manager.submit_task(_tasks.MachineNodeList()))
def get_machine(self, name_or_id):
"""Get Machine by name or uuid
@ -90,8 +91,9 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
nodes are found.
"""
try:
return self.manager.submit_task(
_tasks.MachineNodeGet(node_id=name_or_id))
return self._normalize_machine(
self.manager.submit_task(
_tasks.MachineNodeGet(node_id=name_or_id)))
except ironic_exceptions.ClientException:
return None