Skip to content

Commit

Permalink
[ignore] Fixed query a specific object logic on aci_endpoint_ip_tag, …
Browse files Browse the repository at this point in the history
…aci_endpoint_mac_tag modules
  • Loading branch information
sajagana committed Feb 20, 2025
1 parent 7274fa1 commit cfd740b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
35 changes: 29 additions & 6 deletions plugins/modules/aci_endpoint_ip_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,30 @@
host: apic
username: admin
password: SomeSecretPassword
tenant: endpoint_tenant
endpoint_ip_address: "1.1.1.1"
vrf: endpoint_vrf
state: query
register: query_one
- name: Query all IP Tag Objects with only VRF
cisco.aci.aci_endpoint_ip_tag:
host: apic
username: admin
password: SomeSecretPassword
vrf: default
state: query
register: query_with_vrf
- name: Query all IP Tag Objects with only IP
cisco.aci.aci_endpoint_ip_tag:
host: apic
username: admin
password: SomeSecretPassword
endpoint_ip_address: "1.1.1.1"
state: query
register: query_with_ip
- name: Query all IP Tags
cisco.aci.aci_endpoint_ip_tag:
host: apic
Expand Down Expand Up @@ -261,22 +280,26 @@ def main():

aci = ACIModule(module)

endpoint_ip_tag_rn = None
endpoint_ip_tag_module_object = None
if endpoint_ip_address and vrf:
endpoint_ip_tag_rn = "eptags/epiptag-[{0}]-{1}".format(endpoint_ip_address, vrf)
endpoint_ip_tag_module_object = "[{0}]-{1}".format(endpoint_ip_address, vrf)

aci.construct_url(
root_class=dict(
aci_class="fvTenant",
aci_rn="tn-{0}".format(tenant),
module_object=tenant,
target_filter={"name": tenant},
),
subclass_1=dict(
aci_class="fvEpTags",
aci_rn="eptags",
),
subclass_2=dict(
aci_class="fvEpIpTag",
aci_rn="epiptag-[{0}]-{1}".format(endpoint_ip_address, vrf),
aci_rn=endpoint_ip_tag_rn,
module_object=endpoint_ip_tag_module_object,
target_filter=dict(ip=endpoint_ip_address, ctxName=vrf),
),
)

aci.get_existing()

if state == "present":
Expand Down
33 changes: 28 additions & 5 deletions plugins/modules/aci_endpoint_mac_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@
state: query
register: query_one
- name: Query all MAC Tag Objects with only BD
cisco.aci.aci_endpoint_mac_tag:
host: apic
username: admin
password: SomeSecretPassword
bd: default
state: query
register: query_with_bd
- name: Query all MAC Tag Objects with only MAC
cisco.aci.aci_endpoint_mac_tag:
host: apic
username: admin
password: SomeSecretPassword
endpoint_mac_address: "AE:ED:EE:EE:AA:AA"
state: query
register: query_with_mac
- name: Query all MAC Tags
cisco.aci.aci_endpoint_mac_tag:
host: apic
Expand Down Expand Up @@ -272,18 +290,23 @@ def main():

aci = ACIModule(module)

endpoint_mac_tag_rn = None
endpoint_mac_tag_module_object = None
if endpoint_mac_address and bd:
endpoint_mac_tag_rn = "eptags/epmactag-{0}-[{1}]".format(endpoint_mac_address, bd)
endpoint_mac_tag_module_object = "{0}-[{1}]".format(endpoint_mac_address, bd)

aci.construct_url(
root_class=dict(
aci_class="fvTenant",
aci_rn="tn-{0}".format(tenant),
module_object=tenant,
target_filter={"name": tenant},
),
subclass_1=dict(
aci_class="fvEpTags",
aci_rn="eptags",
),
subclass_2=dict(
aci_class="fvEpMacTag",
aci_rn="epmactag-{0}-[{1}]".format(endpoint_mac_address, bd),
aci_rn=endpoint_mac_tag_rn,
module_object=endpoint_mac_tag_module_object,
target_filter=dict(mac=endpoint_mac_address, bdName=bd),
),
)
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/targets/aci_endpoint_ip_tag/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

- name: Execute tasks only for ACI v5.2+ and non-cloud sites
when:
# - 1 == 1
- version.current.0.topSystem.attributes.version is version('5.2', '>=')
- query_cloud.current == [] # This condition will execute only non-cloud sites
block: # block specifies execution of tasks within, based on conditions
Expand Down Expand Up @@ -236,6 +237,7 @@
- name: Query IP Tag Object with ip and vrf
cisco.aci.aci_endpoint_ip_tag:
<<: *aci_info
tenant: ansible_test
endpoint_ip_address: "2.2.2.2"
vrf: ansible_test_vrf
state: query
Expand Down Expand Up @@ -264,6 +266,7 @@
- name: Negative test - query IP Tag Object with ip and vrf
cisco.aci.aci_endpoint_ip_tag:
<<: *aci_info
tenant: ansible_test
endpoint_ip_address: "2.2.2.2"
vrf: default
state: query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
- name: Query MAC Tag Object with mac and bd
cisco.aci.aci_endpoint_mac_tag:
<<: *aci_info
tenant: ansible_test
endpoint_mac_address: "AE:ED:EE:EE:AA:AB"
bd: ansible_test_bd
state: query
Expand Down

0 comments on commit cfd740b

Please sign in to comment.