From 6d4d8d4b0cfd0c0ef73ea592ef3f2738e315377a Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Sat, 9 Jan 2021 13:01:43 +0100 Subject: [PATCH] ironic: deprecate sub-options of driver_info This structure does not reflect the actual ironic API and is mostly meaningless nowadays. Just let people populate driver_info directly. Change-Id: I04d168dc86e8c0115b7183b14499fe1812af7343 --- plugins/modules/baremetal_node.py | 44 +++++++++---------------------- tests/sanity/ignore-2.10.txt | 1 + tests/sanity/ignore-2.11.txt | 1 + 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/plugins/modules/baremetal_node.py b/plugins/modules/baremetal_node.py index 9145d54e..1a644654 100644 --- a/plugins/modules/baremetal_node.py +++ b/plugins/modules/baremetal_node.py @@ -47,25 +47,10 @@ options: description: - Information for this server's driver. Will vary based on which driver is in use. Any sub-field which is populated will be validated - during creation. + during creation. For compatibility reasons sub-fields `power`, + `deploy`, `management` and `console` are flattened. required: true type: dict - suboptions: - power: - description: - - Information necessary to turn this server on / off. - This often includes such things as IPMI username, password, and IP address. - required: true - deploy: - description: - - Information necessary to deploy this server directly, without using Nova. THIS IS NOT RECOMMENDED. - console: - description: - - Information necessary to connect to this server's serial console. Not all drivers support this. - management: - description: - - Information necessary to interact with this server's management interface. May be shared by power_info in some cases. - required: true nics: description: - 'A list of network interface cards, eg, " - mac: aa:bb:cc:aa:bb:cc"' @@ -149,10 +134,9 @@ EXAMPLES = ''' - mac: "aa:bb:cc:aa:bb:cc" - mac: "dd:ee:ff:dd:ee:ff" driver_info: - power: - ipmi_address: "1.2.3.4" - ipmi_username: "admin" - ipmi_password: "adminpass" + ipmi_address: "1.2.3.4" + ipmi_username: "admin" + ipmi_password: "adminpass" chassis_uuid: "00000000-0000-0000-0000-000000000001" ''' @@ -188,17 +172,13 @@ def _parse_properties(module): def _parse_driver_info(sdk, module): - p = module.params['driver_info'] - info = p.get('power') - if not info: - raise sdk.exceptions.OpenStackCloudException( - "driver_info['power'] is required") - if p.get('console'): - info.update(p.get('console')) - if p.get('management'): - info.update(p.get('management')) - if p.get('deploy'): - info.update(p.get('deploy')) + info = module.params['driver_info'].copy() + for deprecated in ('power', 'console', 'management', 'deploy'): + if deprecated in info: + info.update(info.pop(deprecated)) + module.deprecate("Suboption %s of the driver_info parameter of " + "'openstack.cloud.baremetal_node' is deprecated" + % deprecated, version='2.0.0') return info diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index bda55f5f..a6591cdc 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -1,3 +1,4 @@ +plugins/modules/baremetal_node.py pylint:ansible-deprecated-no-collection-name plugins/modules/compute_flavor_info.py pylint:ansible-deprecated-no-collection-name plugins/modules/identity_domain_info.py pylint:ansible-deprecated-no-collection-name plugins/modules/identity_user_info.py pylint:ansible-deprecated-no-collection-name diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index bda55f5f..a6591cdc 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -1,3 +1,4 @@ +plugins/modules/baremetal_node.py pylint:ansible-deprecated-no-collection-name plugins/modules/compute_flavor_info.py pylint:ansible-deprecated-no-collection-name plugins/modules/identity_domain_info.py pylint:ansible-deprecated-no-collection-name plugins/modules/identity_user_info.py pylint:ansible-deprecated-no-collection-name