Convert ironicclient node.update() call to Task
Changes the node.update() calls to Task calls. Also adds missing test cases. Change-Id: Iaa97aef01b14c348b8cf9045b928a972151b0614
This commit is contained in:
@@ -3382,7 +3382,9 @@ class OperatorCloud(OpenStackCloud):
|
||||
def set_node_instance_info(self, uuid, patch):
|
||||
try:
|
||||
return meta.obj_to_dict(
|
||||
self.ironic_client.node.update(uuid, patch))
|
||||
self.manager.submitTask(
|
||||
_tasks.MachineNodeUpdate(node_id=uuid, patch=patch))
|
||||
)
|
||||
except Exception as e:
|
||||
self.log.debug(
|
||||
"Failed to update instance_info", exc_info=True)
|
||||
@@ -3393,7 +3395,9 @@ class OperatorCloud(OpenStackCloud):
|
||||
patch.append({'op': 'remove', 'path': '/instance_info'})
|
||||
try:
|
||||
return meta.obj_to_dict(
|
||||
self.ironic_client.node.update(uuid, patch))
|
||||
self.manager.submitTask(
|
||||
_tasks.MachineNodeUpdate(node_id=uuid, patch=patch))
|
||||
)
|
||||
except Exception as e:
|
||||
self.log.debug(
|
||||
"Failed to delete instance_info", exc_info=True)
|
||||
|
||||
@@ -422,6 +422,11 @@ class MachineNodePortList(task_manager.Task):
|
||||
return client.ironic_client.node.list_ports(**self.args)
|
||||
|
||||
|
||||
class MachineNodeUpdate(task_manager.Task):
|
||||
def main(self, client):
|
||||
return client.ironic_client.node.update(**self.args)
|
||||
|
||||
|
||||
class MachineNodeValidate(task_manager.Task):
|
||||
def main(self, client):
|
||||
return client.ironic_client.node.validate(**self.args)
|
||||
|
||||
@@ -506,6 +506,24 @@ class TestShadeOperator(base.TestCase):
|
||||
state='deleted',
|
||||
configdrive=None)
|
||||
|
||||
@mock.patch.object(shade.OperatorCloud, 'ironic_client')
|
||||
def test_set_node_instance_info(self, mock_client):
|
||||
uuid = 'aaa'
|
||||
patch = [{'op': 'add', 'foo': 'bar'}]
|
||||
self.cloud.set_node_instance_info(uuid, patch)
|
||||
mock_client.node.update.assert_called_with(
|
||||
node_id=uuid, patch=patch
|
||||
)
|
||||
|
||||
@mock.patch.object(shade.OperatorCloud, 'ironic_client')
|
||||
def test_purge_node_instance_info(self, mock_client):
|
||||
uuid = 'aaa'
|
||||
expected_patch = [{'op': 'remove', 'path': '/instance_info'}]
|
||||
self.cloud.purge_node_instance_info(uuid)
|
||||
mock_client.node.update.assert_called_with(
|
||||
node_id=uuid, patch=expected_patch
|
||||
)
|
||||
|
||||
@mock.patch.object(shade.OpenStackCloud, 'glance_client')
|
||||
def test_get_image_name(self, glance_mock):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user