From e9577408b626f1299b59248bceaa4e6538738777 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Tue, 5 Jul 2022 18:37:13 +0200 Subject: [PATCH] Deprecate os_ironic_node_info The OpenStack ansible collection provides baremetal_node_info. Change-Id: I1c8a28666e7e52f838423a9e4c6aa8475728069d --- bifrost/tests/unit/test_network_metadata.py | 4 +-- playbooks/library/network_metadata.py | 14 ++++---- playbooks/library/os_ironic_node_info.py | 2 ++ playbooks/redeploy-dynamic.yaml | 35 +++++++++---------- .../tasks/main.yml | 11 +++--- .../tasks/main.yml | 17 ++++----- ...-os-ironic-node-info-6ee95171162dc8f6.yaml | 5 +++ 7 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 releasenotes/notes/no-os-ironic-node-info-6ee95171162dc8f6.yaml diff --git a/bifrost/tests/unit/test_network_metadata.py b/bifrost/tests/unit/test_network_metadata.py index 000e9ff34..ea410bf14 100644 --- a/bifrost/tests/unit/test_network_metadata.py +++ b/bifrost/tests/unit/test_network_metadata.py @@ -34,7 +34,7 @@ class TestBifrostNetworkMetadata(base.TestCase): def test_simple(self): params = { - 'nics': [{'mac': TEST_MAC}], + 'nics': [{'address': TEST_MAC}], 'ipv4_address': '1.2.3.4', 'ipv4_subnet_mask': '255.255.0.0', } @@ -59,7 +59,7 @@ class TestBifrostNetworkMetadata(base.TestCase): def test_everything(self): another_mac = 'aa:aa:aa:bb:cc:dd' params = { - 'nics': [{'mac': another_mac}, {'mac': TEST_MAC}], + 'nics': [{'address': another_mac}, {'address': TEST_MAC}], 'ipv4_address': '1.2.3.4', 'ipv4_subnet_mask': '255.255.0.0', 'ipv4_interface_mac': TEST_MAC, diff --git a/playbooks/library/network_metadata.py b/playbooks/library/network_metadata.py index 6ab9b7459..377b70e11 100644 --- a/playbooks/library/network_metadata.py +++ b/playbooks/library/network_metadata.py @@ -52,7 +52,7 @@ def get_network_data(params): links.append(link) for nic in params['nics']: - if nic['mac'] == params['ipv4_interface_mac']: + if nic['address'] == params['ipv4_interface_mac']: network = { 'id': 'ipv4-%s' % nic_id, 'link': nic_id, @@ -73,22 +73,22 @@ def get_network_data(params): networks.append(network) else: for i, nic in enumerate(params['nics']): - nic_id = nic['mac'] + nic_id = nic['address'] if params.get('vlan_id'): - nic_id = 'vlan-%s' % nic['mac'] + nic_id = 'vlan-%s' % nic['address'] links.append({ 'id': nic_id, 'type': 'vlan', 'vlan_id': params['vlan_id'], - 'vlan_link': nic['mac'], - 'vlan_mac_address': nic['mac'] + 'vlan_link': nic['address'], + 'vlan_mac_address': nic['address'] }) link = { - 'id': nic['mac'], + 'id': nic['address'], 'type': 'phy', - 'ethernet_mac_address': nic['mac'], + 'ethernet_mac_address': nic['address'], } if params.get('network_mtu'): link['mtu'] = params['network_mtu'] diff --git a/playbooks/library/os_ironic_node_info.py b/playbooks/library/os_ironic_node_info.py index 47b1e96cb..74c58f00b 100644 --- a/playbooks/library/os_ironic_node_info.py +++ b/playbooks/library/os_ironic_node_info.py @@ -90,6 +90,8 @@ def main(): ) module_kwargs = openstack_module_kwargs() # noqa: F405 module = IronicModule(argument_spec, **module_kwargs) + module.deprecate('os_ironic_node_info is deprecated, please use ' + 'openstack.cloud.baremetal_node_info') if not HAS_SDK: module.fail_json(msg='openstacksdk is required for this module') diff --git a/playbooks/redeploy-dynamic.yaml b/playbooks/redeploy-dynamic.yaml index 6448445c3..4fbe48c08 100644 --- a/playbooks/redeploy-dynamic.yaml +++ b/playbooks/redeploy-dynamic.yaml @@ -30,30 +30,28 @@ connection: local pre_tasks: - name: "Pull initial ironic facts" - os_ironic_node_info: + openstack.cloud.baremetal_node_info: auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" - name: "{{ inventory_hostname }}" + node: "{{ inventory_hostname }}" ironic_url: "{{ ironic_url | default(omit) }}" - skip_items: [] register: node_info roles: - role: bifrost-unprovision-node-dynamic when: - - node_info.node.provision_state == "active" - or node_info.node.provision_state == "deploy failed" - or node_info.node.provision_state == "error" - - not node_info.node.maintenance | bool + - node_info.baremetal_nodes[0].provision_state == "active" + or node_info.baremetal_nodes[0].provision_state == "deploy failed" + or node_info.baremetal_nodes[0].provision_state == "error" + - not node_info.baremetal_nodes[0].maintenance | bool post_tasks: - name: "Pull ironic facts until provision state available" - os_ironic_node_info: + openstack.cloud.baremetal_node_info: auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" - name: "{{ inventory_hostname }}" + node: "{{ inventory_hostname }}" ironic_url: "{{ ironic_url | default(omit) }}" - skip_items: [] register: node_info - until: node_info.node.provision_state == "available" + until: node_info.baremetal_nodes[0].provision_state == "available" retries: "{{ available_state_wait_retries | default(15) }}" delay: "{{ provision_state_retry_interval | default(20) }}" - hosts: baremetal @@ -63,21 +61,20 @@ roles: - role: bifrost-configdrives-dynamic when: - - node_info.node.provision_state == "available" - - not node_info.node.maintenance | bool + - node_info.baremetal_nodes[0].provision_state == "available" + - not node_info.baremetal_nodes[0].maintenance | bool - role: bifrost-deploy-nodes-dynamic when: - - node_info.node.provision_state == "available" - - not node_info.node.maintenance | bool + - node_info.baremetal_nodes[0].provision_state == "available" + - not node_info.baremetal_nodes[0].maintenance | bool post_tasks: - name: "Pull ironic facts until provision state active" - os_ironic_node_info: + openstack.cloud.baremetal_node_info: auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" - name: "{{ inventory_hostname }}" + node: "{{ inventory_hostname }}" ironic_url: "{{ ironic_url | default(omit) }}" - skip_items: [] register: node_info - until: node_info.node.provision_state == "active" + until: node_info.baremetal_nodes[0].provision_state == "active" retries: "{{ active_state_wait_retries | default(30) }}" delay: "{{ provision_state_retry_interval | default(20) }}" diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml index a89528463..0861ab745 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml @@ -19,20 +19,17 @@ # ironic knows, that we do not know potentially, such as an UUID # should a node have been created without one. - name: "Collecting node facts" - os_ironic_node_info: + openstack.cloud.baremetal_node_info: cloud: "{{ cloud_name | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" ca_cert: "{{ tls_certificate_path | default(omit) }}" - uuid: "{{ uuid | default() }}" - name: "{{ name | default() }}" - skip_items: - - instance_info + node: "{{ uuid | default(name) }}" register: node_info - name: "Set UUID from Ironic" set_fact: - uuid: "{{ node_info.node.uuid }}" + uuid: "{{ node_info.baremetal_nodes[0].uuid }}" when: uuid is undefined - name: "Identify ssh_public_key from ssh_public_key_path" @@ -65,7 +62,7 @@ ipv4_subnet_mask: "{{ ipv4_subnet_mask | default('') }}" vlan_id: "{{ vlan_id | default(omit) }}" network_mtu: "{{ network_mtu | default(omit) }}" - nics: "{{ node_info.node.nics | default(omit) }}" + nics: "{{ node_info.baremetal_nodes[0].ports }}" node_network_data: "{{ node_network_data | default(omit) }}" when: addressing_mode is undefined or "dhcp" not in addressing_mode diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml index 25a8b93fb..5e8fc234b 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -25,22 +25,23 @@ # ironic knows, that we do not know potentially, such as an UUID # should a node have been created without one. - name: "Collecting node facts" - os_ironic_node_info: + openstack.cloud.baremetal_node_info: cloud: "{{ cloud_name | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" ca_cert: "{{ tls_certificate_path | default(omit) }}" - uuid: "{{ uuid | default() }}" - name: "{{ name | default() }}" - skip_items: - - instance_info + node: "{{ name }}" register: node_info - when: uuid is undefined + when: + - uuid is undefined + - name is defined - name: "Set UUID from Ironic" set_fact: - uuid: "{{ node_info.node.uuid }}" - when: uuid is undefined + uuid: "{{ node_info.baremetal_nodes[0].uuid }}" + when: + - uuid is undefined + - name is defined - name: "Setup DHCP for nodes." template: diff --git a/releasenotes/notes/no-os-ironic-node-info-6ee95171162dc8f6.yaml b/releasenotes/notes/no-os-ironic-node-info-6ee95171162dc8f6.yaml new file mode 100644 index 000000000..9302621ba --- /dev/null +++ b/releasenotes/notes/no-os-ironic-node-info-6ee95171162dc8f6.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + The ``os_ironic_node_info`` ansible module has been deprecated. Please use + ``openstack.cloud.baremetal_node_info`` instead.