diff options
author | Jesse Pretorius (odyssey4me) <jesse@odyssey4.me> | 2020-02-18 20:41:31 +0000 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2020-03-02 15:54:22 -0800 |
commit | 1e8bebb20be0deb185f2287a1e930915fddab5eb (patch) | |
tree | 880c91975521f30149c31840530567732b88063d | |
parent | f90c7411e81734aa37844c618829aa736d47854f (diff) | |
download | ansible-1e8bebb20be0deb185f2287a1e930915fddab5eb.tar.gz |
Bump min openstacksdk version for os_network/{port_security_enabled,mtu}
To make use of the port_security_enabled [a] and mtu [b] parameters,
[c] and [d] need to be present in the openstacksdk or the os_network
module with return an error like:
TypeError: create_network() got an unexpected keyword argument 'port_security_enabled'
or:
TypeError: create_network() got an unexpected keyword argument 'mtu'
To handle this, we fail the module if one of the arguments are used
and the minimum openstacksdk version for that argument is not met.
[a] https://github.com/ansible/ansible/commit/eaf238b033a0504c48440cf85982a2b89851059d
[b] https://github.com/ansible/ansible/commit/c6a8e99d34eeacd84b097bb0bd2ba9a0d7fb230d
[c] https://github.com/openstack/openstacksdk/commit/8eb788af07ed88166db7b8a58ce1fecacd7a29b1
[d] https://github.com/openstack/openstacksdk/commit/a1fc820a2f3669f64d222506c17be99c4d6be7b7
Backport-of: https://review.opendev.org/708119
Fixes: https://github.com/ansible/ansible/issues/62062
Change-Id: I2b80dc721a08bbdb530af3705ae99cf1b579d9f0
3 files changed, 19 insertions, 10 deletions
diff --git a/changelogs/fragments/62062-os_network-openstacksdk-min.yml b/changelogs/fragments/62062-os_network-openstacksdk-min.yml new file mode 100644 index 0000000000..e450ec7463 --- /dev/null +++ b/changelogs/fragments/62062-os_network-openstacksdk-min.yml @@ -0,0 +1,3 @@ +bugfixes: + - Bump the minimum openstacksdk version to 0.18.0 when os_network + uses the port_security_enabled or mtu arguments. diff --git a/changelogs/fragments/64495-os_network-openstacksdk-min.yml b/changelogs/fragments/64495-os_network-openstacksdk-min.yml index 7fd35acb78..0761b38df9 100644 --- a/changelogs/fragments/64495-os_network-openstacksdk-min.yml +++ b/changelogs/fragments/64495-os_network-openstacksdk-min.yml @@ -1,3 +1,3 @@ bugfixes: - - bump the minimum openstacksdk version when os_network + - Bump the minimum openstacksdk version to 0.29.0 when os_network uses the dns_domain argument diff --git a/lib/ansible/modules/cloud/openstack/os_network.py b/lib/ansible/modules/cloud/openstack/os_network.py index 3e036b5eec..120f9923af 100644 --- a/lib/ansible/modules/cloud/openstack/os_network.py +++ b/lib/ansible/modules/cloud/openstack/os_network.py @@ -73,14 +73,14 @@ options: description: - Whether port security is enabled on the network or not. Network will use OpenStack defaults if this option is - not utilised. + not utilised. Requires openstacksdk>=0.18. type: bool version_added: "2.8" mtu: description: - The maximum transmission unit (MTU) value to address fragmentation. Network will use OpenStack defaults if this option is - not provided. + not provided. Requires openstacksdk>=0.18. type: int version_added: "2.9" dns_domain: @@ -199,16 +199,22 @@ def main(): provider_segmentation_id = module.params['provider_segmentation_id'] project = module.params['project'] - net_create_kwargs = { - 'port_security_enabled': module.params['port_security_enabled'], - 'mtu_size': module.params['mtu'] - } + net_create_kwargs = {} + min_version = None + + if module.params['mtu'] is not None: + min_version = '0.18.0' + net_create_kwargs['mtu_size'] = module.params['mtu'] + + if module.params['port_security_enabled'] is not None: + min_version = '0.18.0' + net_create_kwargs['port_security_enabled'] = module.params['port_security_enabled'] if module.params['dns_domain'] is not None: - sdk, cloud = openstack_cloud_from_module(module, min_version='0.29.0') + min_version = '0.29.0' net_create_kwargs['dns_domain'] = module.params['dns_domain'] - else: - sdk, cloud = openstack_cloud_from_module(module) + + sdk, cloud = openstack_cloud_from_module(module, min_version) try: if project is not None: proj = cloud.get_project(project) |