mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-13 13:02:21 +00:00
Change network modules to work with new SDK
Change-Id: I7625d696f6462a7a955008a5c7276f1548acbc2e
This commit is contained in:
committed by
Jakob Meng
parent
a9fa496ebe
commit
9272146cf7
@@ -8,7 +8,7 @@
|
||||
|
||||
- name: Assert that public network exists
|
||||
assert:
|
||||
that: public_network.openstack_networks|length == 1
|
||||
that: public_network.networks|length == 1
|
||||
|
||||
- name: Create external network
|
||||
openstack.cloud.network:
|
||||
@@ -120,7 +120,7 @@
|
||||
- name: Check if public network has any floating ips
|
||||
set_fact:
|
||||
public_network_had_fips: "{{ fips.floating_ips|
|
||||
selectattr('floating_network_id', '==', public_network.openstack_networks.0.id)|
|
||||
selectattr('floating_network_id', '==', public_network.networks.0.id)|
|
||||
list|length > 0 }}"
|
||||
|
||||
# TODO: Replace with appropriate Ansible module once available
|
||||
@@ -371,7 +371,7 @@
|
||||
when: not public_network_had_fips
|
||||
command: >
|
||||
openstack --os-cloud={{ cloud }} floating ip delete
|
||||
{{ fips.floating_ips|selectattr('floating_network_id', '==', public_network.openstack_networks.0.id)|
|
||||
{{ fips.floating_ips|selectattr('floating_network_id', '==', public_network.networks.0.id)|
|
||||
map(attribute="floating_ip_address")|list|join(' ') }}
|
||||
|
||||
# TODO: Replace with appropriate Ansible module once available
|
||||
|
||||
@@ -1,7 +1,35 @@
|
||||
expected_fields:
|
||||
- availability_zone_hints
|
||||
- availability_zones
|
||||
- created_at
|
||||
- description
|
||||
- dns_domain
|
||||
- id
|
||||
- ipv4_address_scope_id
|
||||
- ipv6_address_scope_id
|
||||
- is_admin_state_up
|
||||
- is_default
|
||||
- is_port_security_enabled
|
||||
- is_router_external
|
||||
- is_shared
|
||||
- is_vlan_transparent
|
||||
- mtu
|
||||
- name
|
||||
- project_id
|
||||
- provider_network_type
|
||||
- provider_physical_network
|
||||
- provider_segmentation_id
|
||||
- qos_policy_id
|
||||
- revision_number
|
||||
- segments
|
||||
- status
|
||||
- subnet_ids
|
||||
- tags
|
||||
- updated_at
|
||||
dns_domain: example.opendev.org
|
||||
mtu: 1250
|
||||
network_external: false
|
||||
network_name: shade_network
|
||||
network_name_newparams: newparams_network
|
||||
network_shared: false
|
||||
network_external: false
|
||||
dns_domain: example.opendev.org
|
||||
mtu: 1250
|
||||
port_security_enabled: false
|
||||
|
||||
@@ -6,6 +6,28 @@
|
||||
state: present
|
||||
shared: "{{ network_shared }}"
|
||||
external: "{{ network_external }}"
|
||||
register: infonet
|
||||
|
||||
- name: Check output of creating network
|
||||
assert:
|
||||
that:
|
||||
- infonet.network
|
||||
- item in infonet.network
|
||||
loop: "{{ expected_fields }}"
|
||||
|
||||
- name: Gather networks info
|
||||
openstack.cloud.networks_info:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ infonet.network.id }}"
|
||||
register: result
|
||||
|
||||
- name: Check output of network info
|
||||
# TODO: Remove ignore_errors once SDK's search_networks() (re)implemented searching by id
|
||||
ignore_errors: yes
|
||||
assert:
|
||||
that:
|
||||
- result.networks|length == 1
|
||||
- infonet.network.id == result.networks[0].id
|
||||
|
||||
- name: Gather networks info - generic
|
||||
openstack.cloud.networks_info:
|
||||
@@ -15,12 +37,28 @@
|
||||
shared: "{{ network_shared|string|capitalize }}"
|
||||
register: result
|
||||
|
||||
- name: Check output of network info
|
||||
assert:
|
||||
that:
|
||||
- item in result.networks[0]
|
||||
loop: "{{ expected_fields }}"
|
||||
|
||||
- name: Gather networks info
|
||||
openstack.cloud.networks_info:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name }}"
|
||||
filters:
|
||||
shared: "False"
|
||||
register: result
|
||||
|
||||
- name: Verify networks info - generic
|
||||
assert:
|
||||
that:
|
||||
- result.openstack_networks.0.name == network_name
|
||||
- (result.openstack_networks.0.shared|lower) == (network_shared|lower)
|
||||
- result.openstack_networks[0]['router:external'] == {{ network_external }}
|
||||
- result.networks.0.name == network_name
|
||||
- "'is_shared' in result.networks.0"
|
||||
- result.networks.0['is_shared']|lower == network_shared|lower
|
||||
- "'is_router_external' in result.networks.0"
|
||||
- result.networks[0]['is_router_external'] == {{ network_external }}
|
||||
|
||||
- name: Create network - with new SDK params
|
||||
openstack.cloud.network:
|
||||
@@ -32,29 +70,21 @@
|
||||
mtu: "{{ mtu }}"
|
||||
port_security_enabled: "{{ port_security_enabled }}"
|
||||
register: result_create_nw_with_new_params
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Check errors below min sdk version - with new SDK params
|
||||
assert:
|
||||
that:
|
||||
- result_create_nw_with_new_params.failed
|
||||
- '"the installed version of the openstacksdk library MUST be >=0.18.0." in result_create_nw_with_new_params.msg'
|
||||
when: sdk_version is version('0.18', '<')
|
||||
ignore_errors: true
|
||||
|
||||
- name: Gather networks info - with new SDK params
|
||||
openstack.cloud.networks_info:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name_newparams }}"
|
||||
register: result_newparams
|
||||
when: sdk_version is version('0.18', '>=')
|
||||
|
||||
- name: Verify networks info - with new SDK params
|
||||
assert:
|
||||
that:
|
||||
- result_newparams.openstack_networks.0.name == network_name_newparams
|
||||
- result_newparams.openstack_networks.0.mtu == mtu
|
||||
- result_newparams.openstack_networks.0.port_security_enabled == port_security_enabled
|
||||
when: sdk_version is version('0.18', '>=')
|
||||
- result_newparams.networks.0.name == network_name_newparams
|
||||
- result_newparams.networks.0.mtu == mtu
|
||||
- "'is_port_security_enabled' in result_newparams.networks.0"
|
||||
- result_newparams.networks.0['is_port_security_enabled'] == port_security_enabled
|
||||
|
||||
- name: Delete network - generic and with new SDK params
|
||||
openstack.cloud.network:
|
||||
@@ -74,4 +104,4 @@
|
||||
- name: Verify networks info - deleted
|
||||
assert:
|
||||
that:
|
||||
- result_nonet.openstack_networks == []
|
||||
- result_nonet.networks == []
|
||||
|
||||
Reference in New Issue
Block a user