From bf58f84167e662d5d2397884e7af44ac92a4c9e9 Mon Sep 17 00:00:00 2001 From: Maxim Babushkin Date: Thu, 7 Mar 2019 21:56:51 +0200 Subject: [PATCH] Add port_security_enabled argument to os_port module (#47715) Port security could be set during creation of the port on the network. Add port_security_enabled boolean during port creation. --- lib/ansible/modules/cloud/openstack/os_port.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_port.py b/lib/ansible/modules/cloud/openstack/os_port.py index c1020ef777..5a38fe3063 100644 --- a/lib/ansible/modules/cloud/openstack/os_port.py +++ b/lib/ansible/modules/cloud/openstack/os_port.py @@ -86,6 +86,11 @@ options: choices: [normal, direct, direct-physical, macvtap, baremetal, virtio-forwarder] default: normal version_added: "2.8" + port_security_enabled: + description: + - Whether to enable or disable the port security on the network. + type: bool + version_added: "2.8" ''' EXAMPLES = ''' @@ -202,6 +207,10 @@ vnic_type: description: Type of the created port returned: success type: str +port_security_enabled: + description: Port security state on the network. + returned: success + type: bool ''' from ansible.module_utils.basic import AnsibleModule @@ -217,7 +226,8 @@ def _needs_update(module, port, cloud): 'mac_address', 'device_owner', 'device_id', - 'binding:vnic_type'] + 'binding:vnic_type', + 'port_security_enabled'] compare_dict = ['allowed_address_pairs', 'extra_dhcp_opts'] compare_list = ['security_groups'] @@ -283,7 +293,8 @@ def _compose_port_args(module, cloud): 'extra_dhcp_opts', 'device_owner', 'device_id', - 'binding:vnic_type'] + 'binding:vnic_type', + 'port_security_enabled'] for optional_param in optional_parameters: if module.params[optional_param] is not None: port_kwargs[optional_param] = module.params[optional_param] @@ -319,6 +330,7 @@ def main(): vnic_type=dict(default='normal', choices=['normal', 'direct', 'direct-physical', 'macvtap', 'baremetal', 'virtio-forwarder']), + port_security_enabled=dict(default=None, type='bool') ) module_kwargs = openstack_module_kwargs(