Skip to content

Commit 45062ef

Browse files
sajaganalhercot
authored andcommitted
[ignore] Fixed query a specific object logic on aci_endpoint_ip_tag, aci_endpoint_mac_tag modules
1 parent ec2104a commit 45062ef

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

plugins/modules/aci_endpoint_ip_tag.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,30 @@
9494
host: apic
9595
username: admin
9696
password: SomeSecretPassword
97+
tenant: endpoint_tenant
9798
endpoint_ip_address: "1.1.1.1"
9899
vrf: endpoint_vrf
99100
state: query
100101
register: query_one
101102
103+
- name: Query all IP Tag Objects with only VRF
104+
cisco.aci.aci_endpoint_ip_tag:
105+
host: apic
106+
username: admin
107+
password: SomeSecretPassword
108+
vrf: default
109+
state: query
110+
register: query_with_vrf
111+
112+
- name: Query all IP Tag Objects with only IP
113+
cisco.aci.aci_endpoint_ip_tag:
114+
host: apic
115+
username: admin
116+
password: SomeSecretPassword
117+
endpoint_ip_address: "1.1.1.1"
118+
state: query
119+
register: query_with_ip
120+
102121
- name: Query all IP Tags
103122
cisco.aci.aci_endpoint_ip_tag:
104123
host: apic
@@ -261,22 +280,26 @@ def main():
261280

262281
aci = ACIModule(module)
263282

283+
endpoint_ip_tag_rn = None
284+
endpoint_ip_tag_module_object = None
285+
if endpoint_ip_address and vrf:
286+
endpoint_ip_tag_rn = "eptags/epiptag-[{0}]-{1}".format(endpoint_ip_address, vrf)
287+
endpoint_ip_tag_module_object = "[{0}]-{1}".format(endpoint_ip_address, vrf)
288+
264289
aci.construct_url(
265290
root_class=dict(
266291
aci_class="fvTenant",
267292
aci_rn="tn-{0}".format(tenant),
293+
module_object=tenant,
294+
target_filter={"name": tenant},
268295
),
269296
subclass_1=dict(
270-
aci_class="fvEpTags",
271-
aci_rn="eptags",
272-
),
273-
subclass_2=dict(
274297
aci_class="fvEpIpTag",
275-
aci_rn="epiptag-[{0}]-{1}".format(endpoint_ip_address, vrf),
298+
aci_rn=endpoint_ip_tag_rn,
299+
module_object=endpoint_ip_tag_module_object,
276300
target_filter=dict(ip=endpoint_ip_address, ctxName=vrf),
277301
),
278302
)
279-
280303
aci.get_existing()
281304

282305
if state == "present":

plugins/modules/aci_endpoint_mac_tag.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@
110110
state: query
111111
register: query_one
112112
113+
- name: Query all MAC Tag Objects with only BD
114+
cisco.aci.aci_endpoint_mac_tag:
115+
host: apic
116+
username: admin
117+
password: SomeSecretPassword
118+
bd: default
119+
state: query
120+
register: query_with_bd
121+
122+
- name: Query all MAC Tag Objects with only MAC
123+
cisco.aci.aci_endpoint_mac_tag:
124+
host: apic
125+
username: admin
126+
password: SomeSecretPassword
127+
endpoint_mac_address: "AE:ED:EE:EE:AA:AA"
128+
state: query
129+
register: query_with_mac
130+
113131
- name: Query all MAC Tags
114132
cisco.aci.aci_endpoint_mac_tag:
115133
host: apic
@@ -272,18 +290,23 @@ def main():
272290

273291
aci = ACIModule(module)
274292

293+
endpoint_mac_tag_rn = None
294+
endpoint_mac_tag_module_object = None
295+
if endpoint_mac_address and bd:
296+
endpoint_mac_tag_rn = "eptags/epmactag-{0}-[{1}]".format(endpoint_mac_address, bd)
297+
endpoint_mac_tag_module_object = "{0}-[{1}]".format(endpoint_mac_address, bd)
298+
275299
aci.construct_url(
276300
root_class=dict(
277301
aci_class="fvTenant",
278302
aci_rn="tn-{0}".format(tenant),
303+
module_object=tenant,
304+
target_filter={"name": tenant},
279305
),
280306
subclass_1=dict(
281-
aci_class="fvEpTags",
282-
aci_rn="eptags",
283-
),
284-
subclass_2=dict(
285307
aci_class="fvEpMacTag",
286-
aci_rn="epmactag-{0}-[{1}]".format(endpoint_mac_address, bd),
308+
aci_rn=endpoint_mac_tag_rn,
309+
module_object=endpoint_mac_tag_module_object,
287310
target_filter=dict(mac=endpoint_mac_address, bdName=bd),
288311
),
289312
)

tests/integration/targets/aci_endpoint_ip_tag/tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
- name: Query IP Tag Object with ip and vrf
237237
cisco.aci.aci_endpoint_ip_tag:
238238
<<: *aci_info
239+
tenant: ansible_test
239240
endpoint_ip_address: "2.2.2.2"
240241
vrf: ansible_test_vrf
241242
state: query
@@ -264,6 +265,7 @@
264265
- name: Negative test - query IP Tag Object with ip and vrf
265266
cisco.aci.aci_endpoint_ip_tag:
266267
<<: *aci_info
268+
tenant: ansible_test
267269
endpoint_ip_address: "2.2.2.2"
268270
vrf: default
269271
state: query

tests/integration/targets/aci_endpoint_mac_tag/tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
- name: Query MAC Tag Object with mac and bd
244244
cisco.aci.aci_endpoint_mac_tag:
245245
<<: *aci_info
246+
tenant: ansible_test
246247
endpoint_mac_address: "AE:ED:EE:EE:AA:AB"
247248
bd: ansible_test_bd
248249
state: query
@@ -265,6 +266,7 @@
265266
- name: Negative test - query MAC Tag Object with mac and bd
266267
cisco.aci.aci_endpoint_mac_tag:
267268
<<: *aci_info
269+
tenant: ansible_test
268270
endpoint_mac_address: "AE:ED:EE:EE:AA:AB"
269271
bd: default
270272
state: query

0 commit comments

Comments
 (0)