From d33ee720850239ca1bc2f432918db0b5be107d39 Mon Sep 17 00:00:00 2001
From: Dmitry Tantsur <dtantsur@protonmail.com>
Date: Thu, 13 Jun 2019 15:08:24 +0200
Subject: [PATCH] os_ironic_node: avoid set_node_instance_info and
 purge_node_instance_info (#54463)

These openstacksdk calls are awkward special-case wrappers around
patch_machine, and I would like to deprecate them in openstacksdk change
https://review.openstack.org/647730. Use much simpler update_machine instead.
---
 .../modules/cloud/openstack/os_ironic_node.py   | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/lib/ansible/modules/cloud/openstack/os_ironic_node.py b/lib/ansible/modules/cloud/openstack/os_ironic_node.py
index 85cdc4f033a..8e80556cc26 100644
--- a/lib/ansible/modules/cloud/openstack/os_ironic_node.py
+++ b/lib/ansible/modules/cloud/openstack/os_ironic_node.py
@@ -125,18 +125,6 @@ def _choose_id_value(module):
     return None
 
 
-# TODO(TheJulia): Change this over to use the machine patch method
-# in shade once it is available.
-def _prepare_instance_info_patch(instance_info):
-    patch = []
-    patch.append({
-        'op': 'replace',
-        'path': '/instance_info',
-        'value': instance_info
-    })
-    return patch
-
-
 def _is_true(value):
     true_values = [True, 'yes', 'Yes', 'True', 'true', 'present', 'on']
     if value in true_values:
@@ -306,8 +294,7 @@ def main():
             # deployment specific. Perhaps consider adding rebuild
             # support, although there is a known desire to remove
             # rebuild support from Ironic at some point in the future.
-            patch = _prepare_instance_info_patch(instance_info)
-            cloud.set_node_instance_info(uuid, patch)
+            cloud.update_machine(uuid, instance_info=instance_info)
             cloud.validate_node(uuid)
             if not wait:
                 cloud.activate_node(uuid, module.params['config_drive'])
@@ -322,7 +309,7 @@ def main():
 
         elif _is_false(module.params['state']):
             if node['provision_state'] not in "deleted":
-                cloud.purge_node_instance_info(uuid)
+                cloud.update_machine(uuid, instance_info={})
                 if not wait:
                     cloud.deactivate_node(uuid)
                 else: