mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-03-26 21:43:02 +00:00
Update port info
Make it compatible with new openstack sdk 1.0.0 Change-Id: I911eecd31ee69dbde1da02a74e152746c1e3edfa
This commit is contained in:
@@ -95,6 +95,7 @@
|
|||||||
object
|
object
|
||||||
object_container
|
object_container
|
||||||
port
|
port
|
||||||
|
port_info
|
||||||
project
|
project
|
||||||
project_info
|
project_info
|
||||||
recordset
|
recordset
|
||||||
|
|||||||
72
ci/roles/port_info/tasks/main.yml
Normal file
72
ci/roles/port_info/tasks/main.yml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
- name: List all ports
|
||||||
|
openstack.cloud.port_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
register: result_all
|
||||||
|
|
||||||
|
- name: Assert fields
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- item in result_all.ports.0
|
||||||
|
loop:
|
||||||
|
- allowed_address_pairs
|
||||||
|
- binding_host_id
|
||||||
|
- binding_profile
|
||||||
|
- binding_vif_details
|
||||||
|
- binding_vif_type
|
||||||
|
- binding_vnic_type
|
||||||
|
- created_at
|
||||||
|
- data_plane_status
|
||||||
|
- description
|
||||||
|
- device_id
|
||||||
|
- device_owner
|
||||||
|
- device_profile
|
||||||
|
- dns_assignment
|
||||||
|
- dns_domain
|
||||||
|
- dns_name
|
||||||
|
- extra_dhcp_opts
|
||||||
|
- fixed_ips
|
||||||
|
- id
|
||||||
|
- ip_allocation
|
||||||
|
- is_admin_state_up
|
||||||
|
- is_port_security_enabled
|
||||||
|
- mac_address
|
||||||
|
- name
|
||||||
|
- network_id
|
||||||
|
- numa_affinity_policy
|
||||||
|
- project_id
|
||||||
|
- propagate_uplink_status
|
||||||
|
- qos_network_policy_id
|
||||||
|
- qos_policy_id
|
||||||
|
- resource_request
|
||||||
|
- revision_number
|
||||||
|
- security_group_ids
|
||||||
|
- status
|
||||||
|
- tags
|
||||||
|
- tenant_id
|
||||||
|
- trunk_details
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
- name: Get port by id
|
||||||
|
openstack.cloud.port_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
port: "{{ result_all.ports[0].id }}"
|
||||||
|
register: result_id
|
||||||
|
|
||||||
|
- name: Assert results by id
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- item.id == result_all.ports[0].id
|
||||||
|
loop: "{{ result_id.ports }}"
|
||||||
|
|
||||||
|
- name: List port with device_id filter
|
||||||
|
openstack.cloud.port_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
filters:
|
||||||
|
device_id: "{{ result_all.ports[0].device_id }}"
|
||||||
|
register: result_filter
|
||||||
|
|
||||||
|
- name: Assert port was returned
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result_filter.ports | length >= 1
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
when: sdk_version is version(0.44, '>=')
|
when: sdk_version is version(0.44, '>=')
|
||||||
- { role: object, tags: object }
|
- { role: object, tags: object }
|
||||||
- { role: port, tags: port }
|
- { role: port, tags: port }
|
||||||
|
- { role: port_info, tags: port_info }
|
||||||
- { role: project, tags: project }
|
- { role: project, tags: project }
|
||||||
- { role: project_info, tags: project_info }
|
- { role: project_info, tags: project_info }
|
||||||
- { role: recordset, tags: recordset }
|
- { role: recordset, tags: recordset }
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ options:
|
|||||||
filters:
|
filters:
|
||||||
description:
|
description:
|
||||||
- A dictionary of meta data to use for further filtering. Elements
|
- A dictionary of meta data to use for further filtering. Elements
|
||||||
of this dictionary will be matched against the returned port
|
of this dictionary will be matched passed to the API as query
|
||||||
dictionaries. Matching is currently limited to strings within
|
parameter filters.
|
||||||
the port dictionary, or strings within nested dictionaries.
|
|
||||||
type: dict
|
type: dict
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
@@ -38,7 +37,7 @@ EXAMPLES = '''
|
|||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
msg: "{{ result.openstack_ports }}"
|
msg: "{{ result.ports}}"
|
||||||
|
|
||||||
# Gather information about a single port
|
# Gather information about a single port
|
||||||
- openstack.cloud.port_info:
|
- openstack.cloud.port_info:
|
||||||
@@ -55,54 +54,60 @@ EXAMPLES = '''
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
openstack_ports:
|
ports:
|
||||||
description: List of port dictionaries. A subset of the dictionary keys
|
description: List of port dictionaries. A subset of the dictionary keys
|
||||||
listed below may be returned, depending on your cloud provider.
|
listed below may be returned, depending on your cloud provider.
|
||||||
returned: always, but can be null
|
returned: always
|
||||||
type: complex
|
type: list
|
||||||
|
elements: dict
|
||||||
contains:
|
contains:
|
||||||
admin_state_up:
|
|
||||||
description: The administrative state of the router, which is
|
|
||||||
up (true) or down (false).
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
sample: true
|
|
||||||
allowed_address_pairs:
|
allowed_address_pairs:
|
||||||
description: A set of zero or more allowed address pairs. An
|
description: A set of zero or more allowed address pairs. An
|
||||||
address pair consists of an IP address and MAC address.
|
address pair consists of an IP address and MAC address.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
sample: []
|
sample: []
|
||||||
"binding:host_id":
|
binding_host_id:
|
||||||
description: The UUID of the host where the port is allocated.
|
description: The UUID of the host where the port is allocated.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "b4bd682d-234a-4091-aa5b-4b025a6a7759"
|
sample: "b4bd682d-234a-4091-aa5b-4b025a6a7759"
|
||||||
"binding:profile":
|
binding_profile:
|
||||||
description: A dictionary the enables the application running on
|
description: A dictionary the enables the application running on
|
||||||
the host to pass and receive VIF port-specific
|
the host to pass and receive VIF port-specific
|
||||||
information to the plug-in.
|
information to the plug-in.
|
||||||
returned: success
|
returned: success
|
||||||
type: dict
|
type: dict
|
||||||
sample: {}
|
sample: {}
|
||||||
"binding:vif_details":
|
binding_vif_details:
|
||||||
description: A dictionary that enables the application to pass
|
description: A dictionary that enables the application to pass
|
||||||
information about functions that the Networking API
|
information about functions that the Networking API
|
||||||
provides.
|
provides.
|
||||||
returned: success
|
returned: success
|
||||||
type: dict
|
type: dict
|
||||||
sample: {"port_filter": true}
|
binding_vif_type:
|
||||||
"binding:vif_type":
|
|
||||||
description: The VIF type for the port.
|
description: The VIF type for the port.
|
||||||
returned: success
|
returned: success
|
||||||
type: dict
|
type: dict
|
||||||
sample: "ovs"
|
binding_vnic_type:
|
||||||
"binding:vnic_type":
|
|
||||||
description: The virtual network interface card (vNIC) type that is
|
description: The virtual network interface card (vNIC) type that is
|
||||||
bound to the neutron port.
|
bound to the neutron port.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "normal"
|
sample: "normal"
|
||||||
|
created_at:
|
||||||
|
description: Date the port was created
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "2022-02-03T13:28:25Z"
|
||||||
|
data_plane_status:
|
||||||
|
description: Status of the underlying data plane of a port.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
description:
|
||||||
|
description: Description of a port
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
device_id:
|
device_id:
|
||||||
description: The UUID of the device that uses this port.
|
description: The UUID of the device that uses this port.
|
||||||
returned: success
|
returned: success
|
||||||
@@ -113,15 +118,22 @@ openstack_ports:
|
|||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "network:router_interface"
|
sample: "network:router_interface"
|
||||||
|
device_profile:
|
||||||
|
description: Device profile
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
dns_assignment:
|
dns_assignment:
|
||||||
description: DNS assignment information.
|
description: DNS assignment information.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
|
dns_domain:
|
||||||
|
description: A valid DNS domain
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
dns_name:
|
dns_name:
|
||||||
description: DNS name
|
description: DNS name
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: ""
|
|
||||||
extra_dhcp_opts:
|
extra_dhcp_opts:
|
||||||
description: A set of zero or more extra DHCP option pairs.
|
description: A set of zero or more extra DHCP option pairs.
|
||||||
An option pair consists of an option value and name.
|
An option pair consists of an option value and name.
|
||||||
@@ -138,11 +150,22 @@ openstack_ports:
|
|||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "3ec25c97-7052-4ab8-a8ba-92faf84148de"
|
sample: "3ec25c97-7052-4ab8-a8ba-92faf84148de"
|
||||||
ip_address:
|
ip_allocation:
|
||||||
description: The IP address.
|
description: Indicates when ports use either deferred, immediate
|
||||||
|
or no IP allocation (none).
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "127.0.0.1"
|
is_admin_state_up:
|
||||||
|
description: The administrative state of the router, which is
|
||||||
|
up (true) or down (false).
|
||||||
|
returned: success
|
||||||
|
type: bool
|
||||||
|
sample: true
|
||||||
|
is_port_security_enabled:
|
||||||
|
description: The port security status. The status is enabled (true) or disabled (false).
|
||||||
|
returned: success
|
||||||
|
type: bool
|
||||||
|
sample: false
|
||||||
mac_address:
|
mac_address:
|
||||||
description: The MAC address.
|
description: The MAC address.
|
||||||
returned: success
|
returned: success
|
||||||
@@ -158,12 +181,46 @@ openstack_ports:
|
|||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "dd1ede4f-3952-4131-aab6-3b8902268c7d"
|
sample: "dd1ede4f-3952-4131-aab6-3b8902268c7d"
|
||||||
port_security_enabled:
|
numa_affinity_policy:
|
||||||
description: The port security status. The status is enabled (true) or disabled (false).
|
description: The port NUMA affinity policy requested during the
|
||||||
|
virtual machine scheduling. Values are None, required,
|
||||||
|
preferred or legacy.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "required"
|
||||||
|
project_id:
|
||||||
|
description: The ID of the project.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "aa1ede4f-3952-4131-aab6-3b8902268c7d"
|
||||||
|
propagate_uplink_status:
|
||||||
|
description: The uplink status propagation of the port.
|
||||||
returned: success
|
returned: success
|
||||||
type: bool
|
type: bool
|
||||||
sample: false
|
sample: false
|
||||||
security_groups:
|
qos_network_policy_id:
|
||||||
|
description: The ID of the QoS policy of the network where this
|
||||||
|
port is plugged.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "1e4f3958-c0c9-4dec-82fa-ed2dc1c5cb34"
|
||||||
|
qos_policy_id:
|
||||||
|
description: The ID of the QoS policy associated with the port.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73"
|
||||||
|
resource_request:
|
||||||
|
description: Expose Placement resources i.e. minimum-bandwidth
|
||||||
|
and traits i.e. vnic-type, physnet requested by a
|
||||||
|
port to Nova and Placement
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
revision_number:
|
||||||
|
description: The revision number of the resource.
|
||||||
|
returned: success
|
||||||
|
type: int
|
||||||
|
sample: 0
|
||||||
|
security_group_ids:
|
||||||
description: The UUIDs of any attached security groups.
|
description: The UUIDs of any attached security groups.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
@@ -172,11 +229,26 @@ openstack_ports:
|
|||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "ACTIVE"
|
sample: "ACTIVE"
|
||||||
|
tags:
|
||||||
|
description: The list of tags on the resource.
|
||||||
|
returned: success
|
||||||
|
type: list
|
||||||
|
sample: []
|
||||||
tenant_id:
|
tenant_id:
|
||||||
description: The UUID of the tenant who owns the network.
|
description: The UUID of the tenant who owns the network. Deprecated.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: "51fce036d7984ba6af4f6c849f65ef00"
|
sample: "51fce036d7984ba6af4f6c849f65ef00"
|
||||||
|
trunk_details:
|
||||||
|
description: The details about the trunk.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
|
updated_at:
|
||||||
|
description: Last port update
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "2022-02-03T13:28:25Z"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
@@ -184,21 +256,22 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O
|
|||||||
|
|
||||||
class NetworkPortInfoModule(OpenStackModule):
|
class NetworkPortInfoModule(OpenStackModule):
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
port=dict(required=False),
|
port=dict(type='str', required=False),
|
||||||
filters=dict(type='dict', required=False),
|
filters=dict(type='dict', required=False, default={}),
|
||||||
)
|
)
|
||||||
module_kwargs = dict(
|
module_kwargs = dict(
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
deprecated_names = ('openstack.cloud.port_facts')
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
port = self.params.get('port')
|
port = self.params['port']
|
||||||
filters = self.params.get('filters')
|
filters = self.params['filters']
|
||||||
|
|
||||||
ports = self.conn.search_ports(port, filters)
|
ports = self.conn.search_ports(port, filters)
|
||||||
self.exit_json(changed=False, openstack_ports=ports)
|
|
||||||
|
ports = [p.to_dict(computed=False) for p in ports]
|
||||||
|
|
||||||
|
self.exit_json(changed=False, ports=ports)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user