Skip to content

Commit

Permalink
Bump min openstacksdk version for os_network/{port_security_enabled,mtu}
Browse files Browse the repository at this point in the history
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] ansible/ansible@eaf238b
[b] ansible/ansible@c6a8e99
[c] openstack/openstacksdk@8eb788a
[d] openstack/openstacksdk@a1fc820

Fixes: ansible/ansible#62062
Change-Id: I2b80dc721a08bbdb530af3705ae99cf1b579d9f0
  • Loading branch information
odyssey4me committed Feb 18, 2020
1 parent b455295 commit 0f19686
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/62062-os_network-openstacksdk-min.yml
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions changelogs/fragments/64495-os_network-openstacksdk-min.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bugfixes:
- bump the minimum openstacksdk version when os_network
uses the dns_domain argument
- Bump the minimum openstacksdk version to 0.29.0 when os_network
uses the dns_domain argument.
24 changes: 15 additions & 9 deletions plugins/modules/os_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@
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
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
dns_domain:
description:
Expand Down Expand Up @@ -195,16 +195,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)
Expand Down

0 comments on commit 0f19686

Please sign in to comment.