mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-06 13:23:06 +00:00
Add binding profile to port module
Neutron port is able to configure binding profile during creation. Add support of the binding profile to module Change-Id: I7a36fb05065cbd559cd7a00842070f97e7afbc13
This commit is contained in:
@@ -119,6 +119,10 @@ options:
|
||||
description:
|
||||
- Whether to enable or disable the port security on the network.
|
||||
type: bool
|
||||
binding_profile:
|
||||
description:
|
||||
- Binding profile dict that the port should be created with.
|
||||
type: dict
|
||||
requirements:
|
||||
- "python >= 3.6"
|
||||
- "openstacksdk"
|
||||
@@ -199,6 +203,20 @@ EXAMPLES = '''
|
||||
name: port1
|
||||
network: foo
|
||||
vnic_type: direct
|
||||
|
||||
# Create a port with binding profile
|
||||
- openstack.cloud.port:
|
||||
state: present
|
||||
auth:
|
||||
auth_url: https://identity.example.com
|
||||
username: admin
|
||||
password: admin
|
||||
project_name: admin
|
||||
name: port1
|
||||
network: foo
|
||||
binding_profile:
|
||||
"pci_slot": "0000:03:11.1"
|
||||
"physical_network": "provider"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
@@ -246,6 +264,10 @@ port_security_enabled:
|
||||
description: Port security state on the network.
|
||||
returned: success
|
||||
type: bool
|
||||
binding:profile:
|
||||
description: Port binded profile
|
||||
returned: success
|
||||
type: dict
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
@@ -274,7 +296,8 @@ def _needs_update(module, port, cloud):
|
||||
'device_owner',
|
||||
'device_id',
|
||||
'binding:vnic_type',
|
||||
'port_security_enabled']
|
||||
'port_security_enabled',
|
||||
'binding:profile']
|
||||
compare_list_dict = ['allowed_address_pairs',
|
||||
'extra_dhcp_opts']
|
||||
compare_list = ['security_groups']
|
||||
@@ -357,7 +380,8 @@ def _compose_port_args(module, cloud):
|
||||
'device_owner',
|
||||
'device_id',
|
||||
'binding:vnic_type',
|
||||
'port_security_enabled']
|
||||
'port_security_enabled',
|
||||
'binding:profile']
|
||||
for optional_param in optional_parameters:
|
||||
if module.params[optional_param] is not None:
|
||||
port_kwargs[optional_param] = module.params[optional_param]
|
||||
@@ -393,7 +417,8 @@ def main():
|
||||
vnic_type=dict(default=None,
|
||||
choices=['normal', 'direct', 'direct-physical',
|
||||
'macvtap', 'baremetal', 'virtio-forwarder']),
|
||||
port_security_enabled=dict(default=None, type='bool')
|
||||
port_security_enabled=dict(default=None, type='bool'),
|
||||
binding_profile=dict(default=None, type='dict')
|
||||
)
|
||||
|
||||
module_kwargs = openstack_module_kwargs(
|
||||
@@ -424,6 +449,9 @@ def main():
|
||||
# Neutron API accept 'binding:vnic_type' as an argument
|
||||
# for the port type.
|
||||
module.params['binding:vnic_type'] = module.params.pop('vnic_type')
|
||||
# Neutron API accept 'binding:profile' as an argument
|
||||
# for the port binding profile type.
|
||||
module.params['binding:profile'] = module.params.pop('binding_profile')
|
||||
|
||||
port = None
|
||||
network_id = None
|
||||
|
||||
Reference in New Issue
Block a user