Skip to content

Commit 0f41fa6

Browse files
akinrosslhercot
authored andcommitted
[bugfix] Fix query results for bulk query to display correct static_paths and fix replace operation for bulk present without force replace
1 parent d4d2efd commit 0f41fa6

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

plugins/modules/mso_schema_site_anp_epg_staticport.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,16 @@ def main():
528528
if len(found_static_ports) == len(static_ports):
529529
mso.existing = found_static_ports
530530
else:
531-
not_found_static_ports = [
532-
"Provided Static Port Path '{0}' not found".format(full_paths[index])
531+
configured_static_ports = [
532+
get_full_static_path(
533+
static_port.get("type"), static_port.get("pod"), static_port.get("leaf"), static_port.get("fex"), static_port.get("path")
534+
)
533535
for index, static_port in enumerate(static_ports)
534-
if full_paths[index] not in found_full_paths
536+
]
537+
not_found_static_ports = [
538+
"Provided Static Port Path '{0}' not found".format(static_port)
539+
for static_port in configured_static_ports
540+
if static_port not in found_full_paths
535541
]
536542
mso.fail_json(msg=not_found_static_ports)
537543
elif not mso.existing and full_path:
@@ -603,7 +609,7 @@ def main():
603609
ops.append(dict(op="add", path=static_port_path, value=payload))
604610
mso.proposed.append(payload)
605611
else:
606-
index = found_full_paths.index(full_path)
612+
index = full_paths.index(full_path)
607613
mso.proposed[index] = payload
608614
ops.append(dict(op="replace", path="{0}/{1}".format(static_ports_path, index), value=payload))
609615
else:

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

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,41 @@
12761276
- nm_force_replace_new_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]"
12771277
- nm_force_replace_new_static_ports.current.9.portEncapVlan == 1209
12781278

1279+
- name: Replace VLAN of existing static port with bulk
1280+
cisco.mso.mso_schema_site_anp_epg_staticport: &replace_vlan_static_ports
1281+
<<: *static_ports_append
1282+
static_ports:
1283+
- leaf: 101
1284+
pod: pod-1
1285+
path: eth2/9
1286+
type: port
1287+
vlan: 1309
1288+
register: nm_replace_vlan_static_ports
1289+
1290+
- name: Replace VLAN of existing static port with bulk again
1291+
cisco.mso.mso_schema_site_anp_epg_staticport:
1292+
<<: *replace_vlan_static_ports
1293+
static_ports:
1294+
- leaf: 101
1295+
pod: pod-1
1296+
path: eth2/9
1297+
type: port
1298+
vlan: 1309
1299+
register: nm_replace_vlan_static_ports_again
1300+
1301+
- name: Verify replacing VLAN of existing static port with bulk
1302+
ansible.builtin.assert:
1303+
that:
1304+
- nm_replace_vlan_static_ports is changed
1305+
- nm_replace_vlan_static_ports.previous.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]"
1306+
- nm_replace_vlan_static_ports.previous.9.portEncapVlan == 1209
1307+
- nm_replace_vlan_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]"
1308+
- nm_replace_vlan_static_ports.current.9.portEncapVlan == 1309
1309+
- nm_replace_vlan_static_ports_again is not changed
1310+
- nm_replace_vlan_static_ports_again.previous.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]"
1311+
- nm_replace_vlan_static_ports_again.previous.9.portEncapVlan == 1309
1312+
- nm_replace_vlan_static_ports_again.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]"
1313+
12791314
# QUERY TESTS FOR BULK
12801315

12811316
- name: Query static ports
@@ -1298,6 +1333,11 @@
12981333
cisco.mso.mso_schema_site_anp_epg_staticport:
12991334
<<: *static_ports_append
13001335
static_ports:
1336+
- leaf: 101
1337+
pod: pod-1
1338+
path: eth2/0
1339+
type: port
1340+
vlan: 1200
13011341
- leaf: 101
13021342
pod: pod-1
13031343
path: eth1/40
@@ -1324,10 +1364,10 @@
13241364
- nm_query_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth2/3]"
13251365
- nm_query_static_ports.current.3.portEncapVlan == 1203
13261366
- nm_query_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]"
1327-
- nm_query_static_ports.current.9.portEncapVlan == 1209
1367+
- nm_query_static_ports.current.9.portEncapVlan == 1309
13281368
- err_query_static_ports is failed
1329-
- err_query_static_ports.msg.0 == "Provided Static Port Path 'topology/pod-1/paths-101/pathep-[eth2/0]' not found"
1330-
- err_query_static_ports.msg.1 == "Provided Static Port Path 'topology/pod-1/paths-101/pathep-[eth2/1]' not found"
1369+
- err_query_static_ports.msg.0 == "Provided Static Port Path 'topology/pod-1/paths-101/pathep-[eth1/40]' not found"
1370+
- err_query_static_ports.msg.1 == "Provided Static Port Path 'topology/pod-1/paths-201/pathep-[eth1/41]' not found"
13311371

13321372
# FORCE REMOVE ALL CONTRACTS
13331373

0 commit comments

Comments
 (0)