From c6a8e99d34eeacd84b097bb0bd2ba9a0d7fb230d Mon Sep 17 00:00:00 2001 From: Miguel Duarte Barroso <39051226+maiqueb@users.noreply.github.com> Date: Sun, 12 May 2019 10:26:27 +0200 Subject: [PATCH] Added the mtu property to the os_network module (#55881) (#54730) The networking API v2 specification, which is implemented by openstack neutron, features an optional MTU parameter that allows operators to specify the value for the maximum transmission unit value. --- ...-os-network-mtu-support-on-create-update.yml | 3 +++ .../modules/cloud/openstack/os_network.py | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/55881-os-network-mtu-support-on-create-update.yml diff --git a/changelogs/fragments/55881-os-network-mtu-support-on-create-update.yml b/changelogs/fragments/55881-os-network-mtu-support-on-create-update.yml new file mode 100644 index 0000000000..21279fe276 --- /dev/null +++ b/changelogs/fragments/55881-os-network-mtu-support-on-create-update.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - os_network - added MTU support when creating/updating a network diff --git a/lib/ansible/modules/cloud/openstack/os_network.py b/lib/ansible/modules/cloud/openstack/os_network.py index 9553e76498..d170b99746 100644 --- a/lib/ansible/modules/cloud/openstack/os_network.py +++ b/lib/ansible/modules/cloud/openstack/os_network.py @@ -76,6 +76,13 @@ options: not utilised. 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. + type: int + version_added: "2.9" requirements: - "openstacksdk" ''' @@ -164,7 +171,8 @@ def main(): provider_segmentation_id=dict(required=False, type='int'), state=dict(default='present', choices=['absent', 'present']), project=dict(default=None), - port_security_enabled=dict(type='bool') + port_security_enabled=dict(type='bool'), + mtu=dict(required=False, type='int') ) module_kwargs = openstack_module_kwargs() @@ -180,6 +188,7 @@ def main(): provider_segmentation_id = module.params['provider_segmentation_id'] project = module.params.get('project') port_security_enabled = module.params.get('port_security_enabled') + mtu = module.params.get('mtu') sdk, cloud = openstack_cloud_from_module(module) try: @@ -207,11 +216,13 @@ 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) + port_security_enabled=port_security_enabled, + mtu_size=mtu) else: net = cloud.create_network(name, shared, admin_state_up, external, provider, - port_security_enabled=port_security_enabled) + port_security_enabled=port_security_enabled, + mtu_size=mtu) changed = True else: changed = False