Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to query the object using UUID (DCNE-184) #594

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions plugins/modules/ndo_dhcp_option_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
id: 1
data: data_1
state: present
register: create

- name: Query a dhcp option policy with template_name
- name: Query a dhcp option policy with name
cisco.mso.ndo_dhcp_option_policy:
host: mso_host
username: admin
Expand All @@ -98,6 +99,16 @@
state: query
register: query_one

- name: Query a dhcp option policy with UUID
cisco.mso.ndo_dhcp_option_policy:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_tenant_template
option_policy_uuid: '{{ create.current.uuid }}'
state: query
register: query_uuid

- name: Query all dhcp option policy in the template
cisco.mso.ndo_dhcp_option_policy:
host: mso_host
Expand Down Expand Up @@ -173,7 +184,7 @@ def main():

path = "/tenantPolicyTemplate/template/dhcpOptionPolicies"
existing_dhcp_option_policies = mso_template.template.get("tenantPolicyTemplate", {}).get("template", {}).get("dhcpOptionPolicies", [])
if option_policy:
if option_policy or option_policy_uuid:
object_description = "DHCP Option Policy"
if option_policy_uuid:
match = mso_template.get_object_by_uuid(object_description, existing_dhcp_option_policies, option_policy_uuid)
Expand Down
15 changes: 13 additions & 2 deletions plugins/modules/ndo_dhcp_relay_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@
epg: ansible_test_epg_1
ip: 1.1.1.1
state: present
register: create

- name: Query a dhcp relay policy with template_name
- name: Query a dhcp relay policy with name
cisco.mso.ndo_dhcp_relay_policy:
host: mso_host
username: admin
Expand All @@ -124,6 +125,16 @@
state: query
register: query_one

- name: Query a dhcp relay policy with UUID
cisco.mso.ndo_dhcp_relay_policy:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_tenant_template
relay_policy_uuid: '{{ create.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all dhcp relay policy in the template
cisco.mso.ndo_dhcp_relay_policy:
host: mso_host
Expand Down Expand Up @@ -204,7 +215,7 @@ def main():

path = "/tenantPolicyTemplate/template/dhcpRelayPolicies"
existing_dhcp_relay_policies = mso_template.template.get("tenantPolicyTemplate", {}).get("template", {}).get("dhcpRelayPolicies", [])
if relay_policy:
if relay_policy or relay_policy_uuid:
object_description = "DHCP Relay Policy"
if relay_policy_uuid:
match = mso_template.get_object_by_uuid(object_description, existing_dhcp_relay_policies, relay_policy_uuid)
Expand Down
15 changes: 13 additions & 2 deletions plugins/modules/ndo_l3_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@
l3_domain: ansible_test_l3_domain
pool: ansible_test_vlan_pool
state: present
register: create

- name: Query a L3 domain with template_name
- name: Query a L3 domain with name
cisco.mso.ndo_l3_domain:
host: mso_host
username: admin
Expand All @@ -80,6 +81,16 @@
state: query
register: query_one

- name: Query a L3 domain with UUID
cisco.mso.ndo_l3_domain:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_tenant_template
l3_domain_uuid: '{{ create.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all L3 domains in the template
cisco.mso.ndo_l3_domain:
host: mso_host
Expand Down Expand Up @@ -156,7 +167,7 @@ def main():

path = "/fabricPolicyTemplate/template/l3Domains"
existing_l3_domains = mso_template.template.get("fabricPolicyTemplate", {}).get("template", {}).get("l3Domains", [])
if l3_domain:
if l3_domain or l3_domain_uuid:
object_description = "L3 Domain"
if l3_domain_uuid:
match = mso_template.get_object_by_uuid(object_description, existing_l3_domains, l3_domain_uuid)
Expand Down
15 changes: 13 additions & 2 deletions plugins/modules/ndo_physical_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@
physical_domain: ansible_test_physical_domain
pool: ansible_test_vlan_pool
state: present
register: create

- name: Query a physical domain with template_name
- name: Query a physical domain with name
cisco.mso.ndo_physical_domain:
host: mso_host
username: admin
Expand All @@ -80,6 +81,16 @@
state: query
register: query_one

- name: Query a physical domain with UUID
cisco.mso.ndo_physical_domain:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_tenant_template
physical_domain_uuid: '{{ create.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all physical domains in the template
cisco.mso.ndo_physical_domain:
host: mso_host
Expand Down Expand Up @@ -156,7 +167,7 @@ def main():

path = "/fabricPolicyTemplate/template/domains"
existing_physical_domains = mso_template.template.get("fabricPolicyTemplate", {}).get("template", {}).get("domains", [])
if physical_domain:
if physical_domain or physical_domain_uuid:
object_description = "Physical Domain"
if physical_domain_uuid:
match = mso_template.get_object_by_uuid(object_description, existing_physical_domains, physical_domain_uuid)
Expand Down
19 changes: 15 additions & 4 deletions plugins/modules/ndo_route_map_policy_multicast.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"""

EXAMPLES = r"""
- name: Create a new multicast route map policy policy
- name: Create a new multicast route map policy
cisco.mso.ndo_route_map_policy_multicast:
host: mso_host
username: admin
Expand All @@ -101,8 +101,9 @@
rp: 1.1.1.2
action: permit
state: present
register: create

- name: Query a multicast route map policy policy with template_name
- name: Query a multicast route map policy with name
cisco.mso.ndo_route_map_policy_multicast:
host: mso_host
username: admin
Expand All @@ -112,7 +113,17 @@
state: query
register: query_one

- name: Query all multicast route map policy policy in the template
- name: Query a multicast route map policy with UUID
cisco.mso.ndo_route_map_policy_multicast:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_tenant_template
route_map_policy_uuid: '{{ create.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all multicast route map policy in the template
cisco.mso.ndo_route_map_policy_multicast:
host: mso_host
username: admin
Expand All @@ -121,7 +132,7 @@
state: query
register: query_all

- name: Delete a multicast route map policy policy
- name: Delete a multicast route map policy
cisco.mso.ndo_route_map_policy_multicast:
host: mso_host
username: admin
Expand Down
7 changes: 4 additions & 3 deletions plugins/modules/ndo_synce_interface_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
src_priority: 100
wait_to_restore: 5
state: present
register: create

- name: Query a syncE interface policy with interface_policy name
cisco.mso.ndo_synce_interface_policy:
Expand All @@ -117,13 +118,13 @@
state: query
register: query_all

- name: Query a syncE interface policy with interface_policy uuid
- name: Query a syncE interface policy with interface_policy UUID
cisco.mso.ndo_synce_interface_policy:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_fabric_policy_template
interface_policy_uuid: uuid
interface_policy_uuid: '{{ create.current.uuid }}'
state: query
register: query_one_by_uuid

Expand Down Expand Up @@ -197,7 +198,7 @@ def main():

existing_interface_policies = mso_template.template.get("fabricPolicyTemplate", {}).get("template", {}).get("syncEthIntfPolicies", [])

if interface_policy:
if interface_policy or interface_policy_uuid:
object_description = "SyncE Interface Policy"
if interface_policy_uuid:
match = mso_template.get_object_by_uuid(object_description, existing_interface_policies, interface_policy_uuid)
Expand Down
15 changes: 13 additions & 2 deletions plugins/modules/ndo_vlan_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
- from_vlan: 300
to_vlan: 400
state: present
register: create

- name: Query a vlan pool with template_name
- name: Query a vlan pool with name
cisco.mso.ndo_vlan_pool:
host: mso_host
username: admin
Expand All @@ -98,6 +99,16 @@
state: query
register: query_one

- name: Query a vlan pool with UUID
cisco.mso.ndo_vlan_pool:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_tenant_template
vlan_pool_uuid: '{{ create.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all vlan pools in the template
cisco.mso.ndo_vlan_pool:
host: mso_host
Expand Down Expand Up @@ -171,7 +182,7 @@ def main():

path = "/fabricPolicyTemplate/template/vlanPools"
existing_vlan_pools = mso_template.template.get("fabricPolicyTemplate", {}).get("template", {}).get("vlanPools", [])
if vlan_pool:
if vlan_pool or vlan_pool_uuid:
object_description = "VLAN Pool"
if vlan_pool_uuid:
match = mso_template.get_object_by_uuid(object_description, existing_vlan_pools, vlan_pool_uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@
state: query
register: query_one

- name: Query a dhcp option policy with uuid
cisco.mso.ndo_dhcp_option_policy:
<<: *mso_info
template: ansible_tenant_template
option_policy_uuid: '{{ query_one.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all dhcp option policy in the template
cisco.mso.ndo_dhcp_option_policy:
<<: *mso_info
Expand All @@ -272,7 +280,9 @@
assert:
that:
- query_one is not changed
- query_one.current.name == "ansible_test_option_policy_2"
- query_with_uuid is not changed
- query_one.current.name == query_with_uuid.current.name == "ansible_test_option_policy_2"
- query_one.current.uuid == query_with_uuid.current.uuid
- query_all is not changed
- query_all.current | length == 2

Expand Down
12 changes: 11 additions & 1 deletion tests/integration/targets/ndo_dhcp_relay_policy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,14 @@
state: query
register: query_one

- name: Query a dhcp relay policy with uuid
cisco.mso.ndo_dhcp_relay_policy:
<<: *mso_info
template: ansible_tenant_template
relay_policy_uuid: "{{ query_one.current.uuid }}"
state: query
register: query_with_uuid

- name: Query all dhcp relay policy in the template
cisco.mso.ndo_dhcp_relay_policy:
<<: *mso_info
Expand All @@ -362,7 +370,9 @@
assert:
that:
- query_one is not changed
- query_one.current.name == "ansible_test_relay_policy_2"
- query_with_uuid is not changed
- query_one.current.name == query_with_uuid.current.name =="ansible_test_relay_policy_2"
- query_one.current.uuid == query_with_uuid.current.uuid
- query_all is not changed
- query_all.current | length == 2

Expand Down
12 changes: 11 additions & 1 deletion tests/integration/targets/ndo_l3_domain/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@
state: query
register: query_one

- name: Query a l3 domain with UUID
cisco.mso.ndo_l3_domain:
<<: *mso_info
template: ansible_fabric_policy_template
l3_domain_uuid: '{{ query_one.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all l3 domain in the template
cisco.mso.ndo_l3_domain:
<<: *mso_info
Expand All @@ -190,7 +198,9 @@
assert:
that:
- query_one is not changed
- query_one.current.name == "ansible_test_l3_domain_2"
- query_with_uuid is not changed
- query_one.current.name == query_with_uuid.current.name == "ansible_test_l3_domain_2"
- query_one.current.uuid == query_with_uuid.current.uuid
- query_all is not changed
- query_all.current | length == 2

Expand Down
12 changes: 11 additions & 1 deletion tests/integration/targets/ndo_physical_domain/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@
state: query
register: query_one

- name: Query a physical domain with uuid
cisco.mso.ndo_physical_domain:
<<: *mso_info
template: ansible_fabric_policy_template
physical_domain_uuid: '{{ query_one.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all physical domain in the template
cisco.mso.ndo_physical_domain:
<<: *mso_info
Expand All @@ -190,7 +198,9 @@
assert:
that:
- query_one is not changed
- query_one.current.name == "ansible_test_physical_domain_2"
- query_with_uuid is not changed
- query_one.current.name == query_with_uuid.current.name == "ansible_test_physical_domain_2"
- query_one.current.uuid == query_with_uuid.current.uuid
- query_all is not changed
- query_all.current | length == 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@
state: query
register: query_one

- name: Query a route map policy multicast with uuid
cisco.mso.ndo_route_map_policy_multicast:
<<: *mso_info
template: ansible_tenant_template
route_map_policy_uuid: '{{ query_one.current.uuid }}'
state: query
register: query_with_uuid

- name: Query all route map policy multicast in the template
cisco.mso.ndo_route_map_policy_multicast:
<<: *mso_info
Expand All @@ -311,7 +319,9 @@
assert:
that:
- query_one is not changed
- query_one.current.name == "ansible_test_route_map_policy_2"
- query_with_uuid is not changed
- query_one.current.name == query_with_uuid.current.name == "ansible_test_route_map_policy_2"
- query_one.current.uuid == query_with_uuid.current.uuid
- query_all is not changed
- query_all.current | length == 2

Expand Down
Loading
Loading