Deprecate os_ironic_node_info

The OpenStack ansible collection provides baremetal_node_info.

Change-Id: I1c8a28666e7e52f838423a9e4c6aa8475728069d
This commit is contained in:
Dmitry Tantsur 2022-07-05 18:37:13 +02:00
parent ba9ddfea6a
commit e9577408b6
7 changed files with 45 additions and 43 deletions

View File

@ -34,7 +34,7 @@ class TestBifrostNetworkMetadata(base.TestCase):
def test_simple(self): def test_simple(self):
params = { params = {
'nics': [{'mac': TEST_MAC}], 'nics': [{'address': TEST_MAC}],
'ipv4_address': '1.2.3.4', 'ipv4_address': '1.2.3.4',
'ipv4_subnet_mask': '255.255.0.0', 'ipv4_subnet_mask': '255.255.0.0',
} }
@ -59,7 +59,7 @@ class TestBifrostNetworkMetadata(base.TestCase):
def test_everything(self): def test_everything(self):
another_mac = 'aa:aa:aa:bb:cc:dd' another_mac = 'aa:aa:aa:bb:cc:dd'
params = { params = {
'nics': [{'mac': another_mac}, {'mac': TEST_MAC}], 'nics': [{'address': another_mac}, {'address': TEST_MAC}],
'ipv4_address': '1.2.3.4', 'ipv4_address': '1.2.3.4',
'ipv4_subnet_mask': '255.255.0.0', 'ipv4_subnet_mask': '255.255.0.0',
'ipv4_interface_mac': TEST_MAC, 'ipv4_interface_mac': TEST_MAC,

View File

@ -52,7 +52,7 @@ def get_network_data(params):
links.append(link) links.append(link)
for nic in params['nics']: for nic in params['nics']:
if nic['mac'] == params['ipv4_interface_mac']: if nic['address'] == params['ipv4_interface_mac']:
network = { network = {
'id': 'ipv4-%s' % nic_id, 'id': 'ipv4-%s' % nic_id,
'link': nic_id, 'link': nic_id,
@ -73,22 +73,22 @@ def get_network_data(params):
networks.append(network) networks.append(network)
else: else:
for i, nic in enumerate(params['nics']): for i, nic in enumerate(params['nics']):
nic_id = nic['mac'] nic_id = nic['address']
if params.get('vlan_id'): if params.get('vlan_id'):
nic_id = 'vlan-%s' % nic['mac'] nic_id = 'vlan-%s' % nic['address']
links.append({ links.append({
'id': nic_id, 'id': nic_id,
'type': 'vlan', 'type': 'vlan',
'vlan_id': params['vlan_id'], 'vlan_id': params['vlan_id'],
'vlan_link': nic['mac'], 'vlan_link': nic['address'],
'vlan_mac_address': nic['mac'] 'vlan_mac_address': nic['address']
}) })
link = { link = {
'id': nic['mac'], 'id': nic['address'],
'type': 'phy', 'type': 'phy',
'ethernet_mac_address': nic['mac'], 'ethernet_mac_address': nic['address'],
} }
if params.get('network_mtu'): if params.get('network_mtu'):
link['mtu'] = params['network_mtu'] link['mtu'] = params['network_mtu']

View File

@ -90,6 +90,8 @@ def main():
) )
module_kwargs = openstack_module_kwargs() # noqa: F405 module_kwargs = openstack_module_kwargs() # noqa: F405
module = IronicModule(argument_spec, **module_kwargs) 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: if not HAS_SDK:
module.fail_json(msg='openstacksdk is required for this module') module.fail_json(msg='openstacksdk is required for this module')

View File

@ -30,30 +30,28 @@
connection: local connection: local
pre_tasks: pre_tasks:
- name: "Pull initial ironic facts" - name: "Pull initial ironic facts"
os_ironic_node_info: openstack.cloud.baremetal_node_info:
auth_type: "{{ auth_type | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}" auth: "{{ auth | default(omit) }}"
name: "{{ inventory_hostname }}" node: "{{ inventory_hostname }}"
ironic_url: "{{ ironic_url | default(omit) }}" ironic_url: "{{ ironic_url | default(omit) }}"
skip_items: []
register: node_info register: node_info
roles: roles:
- role: bifrost-unprovision-node-dynamic - role: bifrost-unprovision-node-dynamic
when: when:
- node_info.node.provision_state == "active" - node_info.baremetal_nodes[0].provision_state == "active"
or node_info.node.provision_state == "deploy failed" or node_info.baremetal_nodes[0].provision_state == "deploy failed"
or node_info.node.provision_state == "error" or node_info.baremetal_nodes[0].provision_state == "error"
- not node_info.node.maintenance | bool - not node_info.baremetal_nodes[0].maintenance | bool
post_tasks: post_tasks:
- name: "Pull ironic facts until provision state available" - name: "Pull ironic facts until provision state available"
os_ironic_node_info: openstack.cloud.baremetal_node_info:
auth_type: "{{ auth_type | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}" auth: "{{ auth | default(omit) }}"
name: "{{ inventory_hostname }}" node: "{{ inventory_hostname }}"
ironic_url: "{{ ironic_url | default(omit) }}" ironic_url: "{{ ironic_url | default(omit) }}"
skip_items: []
register: node_info 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) }}" retries: "{{ available_state_wait_retries | default(15) }}"
delay: "{{ provision_state_retry_interval | default(20) }}" delay: "{{ provision_state_retry_interval | default(20) }}"
- hosts: baremetal - hosts: baremetal
@ -63,21 +61,20 @@
roles: roles:
- role: bifrost-configdrives-dynamic - role: bifrost-configdrives-dynamic
when: when:
- node_info.node.provision_state == "available" - node_info.baremetal_nodes[0].provision_state == "available"
- not node_info.node.maintenance | bool - not node_info.baremetal_nodes[0].maintenance | bool
- role: bifrost-deploy-nodes-dynamic - role: bifrost-deploy-nodes-dynamic
when: when:
- node_info.node.provision_state == "available" - node_info.baremetal_nodes[0].provision_state == "available"
- not node_info.node.maintenance | bool - not node_info.baremetal_nodes[0].maintenance | bool
post_tasks: post_tasks:
- name: "Pull ironic facts until provision state active" - name: "Pull ironic facts until provision state active"
os_ironic_node_info: openstack.cloud.baremetal_node_info:
auth_type: "{{ auth_type | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}" auth: "{{ auth | default(omit) }}"
name: "{{ inventory_hostname }}" node: "{{ inventory_hostname }}"
ironic_url: "{{ ironic_url | default(omit) }}" ironic_url: "{{ ironic_url | default(omit) }}"
skip_items: []
register: node_info 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) }}" retries: "{{ active_state_wait_retries | default(30) }}"
delay: "{{ provision_state_retry_interval | default(20) }}" delay: "{{ provision_state_retry_interval | default(20) }}"

View File

@ -19,20 +19,17 @@
# ironic knows, that we do not know potentially, such as an UUID # ironic knows, that we do not know potentially, such as an UUID
# should a node have been created without one. # should a node have been created without one.
- name: "Collecting node facts" - name: "Collecting node facts"
os_ironic_node_info: openstack.cloud.baremetal_node_info:
cloud: "{{ cloud_name | default(omit) }}" cloud: "{{ cloud_name | default(omit) }}"
auth_type: "{{ auth_type | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}" auth: "{{ auth | default(omit) }}"
ca_cert: "{{ tls_certificate_path | default(omit) }}" ca_cert: "{{ tls_certificate_path | default(omit) }}"
uuid: "{{ uuid | default() }}" node: "{{ uuid | default(name) }}"
name: "{{ name | default() }}"
skip_items:
- instance_info
register: node_info register: node_info
- name: "Set UUID from Ironic" - name: "Set UUID from Ironic"
set_fact: set_fact:
uuid: "{{ node_info.node.uuid }}" uuid: "{{ node_info.baremetal_nodes[0].uuid }}"
when: uuid is undefined when: uuid is undefined
- name: "Identify ssh_public_key from ssh_public_key_path" - name: "Identify ssh_public_key from ssh_public_key_path"
@ -65,7 +62,7 @@
ipv4_subnet_mask: "{{ ipv4_subnet_mask | default('') }}" ipv4_subnet_mask: "{{ ipv4_subnet_mask | default('') }}"
vlan_id: "{{ vlan_id | default(omit) }}" vlan_id: "{{ vlan_id | default(omit) }}"
network_mtu: "{{ network_mtu | 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) }}" node_network_data: "{{ node_network_data | default(omit) }}"
when: addressing_mode is undefined or "dhcp" not in addressing_mode when: addressing_mode is undefined or "dhcp" not in addressing_mode

View File

@ -25,22 +25,23 @@
# ironic knows, that we do not know potentially, such as an UUID # ironic knows, that we do not know potentially, such as an UUID
# should a node have been created without one. # should a node have been created without one.
- name: "Collecting node facts" - name: "Collecting node facts"
os_ironic_node_info: openstack.cloud.baremetal_node_info:
cloud: "{{ cloud_name | default(omit) }}" cloud: "{{ cloud_name | default(omit) }}"
auth_type: "{{ auth_type | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}" auth: "{{ auth | default(omit) }}"
ca_cert: "{{ tls_certificate_path | default(omit) }}" ca_cert: "{{ tls_certificate_path | default(omit) }}"
uuid: "{{ uuid | default() }}" node: "{{ name }}"
name: "{{ name | default() }}"
skip_items:
- instance_info
register: node_info register: node_info
when: uuid is undefined when:
- uuid is undefined
- name is defined
- name: "Set UUID from Ironic" - name: "Set UUID from Ironic"
set_fact: set_fact:
uuid: "{{ node_info.node.uuid }}" uuid: "{{ node_info.baremetal_nodes[0].uuid }}"
when: uuid is undefined when:
- uuid is undefined
- name is defined
- name: "Setup DHCP for nodes." - name: "Setup DHCP for nodes."
template: template:

View File

@ -0,0 +1,5 @@
---
deprecations:
- |
The ``os_ironic_node_info`` ansible module has been deprecated. Please use
``openstack.cloud.baremetal_node_info`` instead.