Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport 2.8] Bump min openstacksdk version for os_network #67577

Merged
merged 1 commit into from Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions 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 argument.
5 changes: 5 additions & 0 deletions lib/ansible/module_utils/openstack.py
Expand Up @@ -117,6 +117,11 @@ def openstack_cloud_from_module(module, min_version='0.12.0'):
except ImportError:
module.fail_json(msg='openstacksdk is required for this module')

if min_version:
min_version = max(StrictVersion('0.12.0'), StrictVersion(min_version))
else:
min_version = StrictVersion('0.12.0')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has broken OpenStack ansible modules in 2.8.9. min_version should be a string, not a StrictVersion. We get the following error:

TypeError: expected string or buffer

This affects kolla-ansible, and probably a few other things too. https://bugs.launchpad.net/kolla-ansible/+bug/1866181


if min_version:
if StrictVersion(sdk.version.__version__) < StrictVersion(min_version):
module.fail_json(
Expand Down
16 changes: 11 additions & 5 deletions lib/ansible/modules/cloud/openstack/os_network.py
Expand Up @@ -73,7 +73,7 @@
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"
requirements:
Expand Down Expand Up @@ -179,9 +179,15 @@ def main():
provider_network_type = module.params['provider_network_type']
provider_segmentation_id = module.params['provider_segmentation_id']
project = module.params.get('project')
port_security_enabled = module.params.get('port_security_enabled')

sdk, cloud = openstack_cloud_from_module(module)
net_create_kwargs = {}
min_version = None

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']

sdk, cloud = openstack_cloud_from_module(module, min_version)
try:
if project is not None:
proj = cloud.get_project(project)
Expand All @@ -207,11 +213,11 @@ def main():
if project_id is not None:
net = cloud.create_network(name, shared, admin_state_up,
external, provider, project_id,
port_security_enabled=port_security_enabled)
**net_create_kwargs)
else:
net = cloud.create_network(name, shared, admin_state_up,
external, provider,
port_security_enabled=port_security_enabled)
**net_create_kwargs)
changed = True
else:
changed = False
Expand Down