Skip to content

Commit 2cca809

Browse files
Correcting IT changes and resolving useVirtualPeerLink unanimous valuing
1 parent 2d73465 commit 2cca809

File tree

7 files changed

+97
-64
lines changed

7 files changed

+97
-64
lines changed

playbooks/roles/dcnm_vpc_pair/dcnm_tests.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
ansible_switch2: 192.168.1.2
2020
ansible_peer1_ip: 192.168.1.1
2121
ansible_peer2_ip: 192.168.1.2
22-
ipAddress: 192.168.1.5
2322
ansible_vxlan_vpc_domain_id: 1000
2423

2524
config:
@@ -43,7 +42,6 @@
4342
PEER2_PCID: 2
4443

4544
# Additional required fields
46-
ipAddress: "{{ ansible_peer1_ip }}"
4745
peer1Ip: "{{ ansible_peer1_ip }}"
4846
peer2Ip: "{{ ansible_peer2_ip }}"
4947
vpcDomainId: "{{ ansible_vxlan_vpc_domain_id }}"

plugins/module_utils/network/dcnm/dcnm_vpc_pair_utils.py

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,21 @@ def dcnm_vpc_pair_compare_vpc_pair_objects(self, wobj, hobj):
393393
if "_defaulted" in key:
394394
continue
395395

396-
if str(hobj.get(key, None)).lower() != str(wobj[key]).lower():
397-
if key == "nvPairs":
398-
continue
399-
400-
# We found an object that matched all other key values, but differs in one of the params.
401-
mismatch_reasons.append(
402-
{key.upper() + "_MISMATCH": [wobj[key], hobj.get(key, None)]}
403-
)
396+
# Special handling for useVirtualPeerlink to treat None and False as equivalent
397+
if key == "useVirtualPeerlink":
398+
hval = hobj.get(key, None)
399+
wval = wobj[key]
400+
if not ((hval is None and wval is False) or (hval is False and wval is None)):
401+
if str(hval).lower() != str(wval).lower():
402+
mismatch_reasons.append(
403+
{key.upper() + "_MISMATCH": [wval, hval]}
404+
)
405+
elif key != "nvPairs": # Skip nvPairs here as it's handled separately
406+
if str(hobj.get(key, None)).lower() != str(wobj[key]).lower():
407+
# We found an object that matched all other key values, but differs in one of the params.
408+
mismatch_reasons.append(
409+
{key.upper() + "_MISMATCH": [wobj[key], hobj.get(key, None)]}
410+
)
404411

405412
if wobj.get("nvPairs", None) is not None:
406413

@@ -409,20 +416,30 @@ def dcnm_vpc_pair_compare_vpc_pair_objects(self, wobj, hobj):
409416
if "_defaulted" in key:
410417
continue
411418

412-
if (
413-
str(hobj["nvPairs"].get(key, None)).lower()
414-
!= str(wobj["nvPairs"][key]).lower()
415-
):
416-
# We found an object that matched all other key values, but differs in one of the params.
417-
mismatch_reasons.append(
418-
{
419-
key.upper()
420-
+ "_MISMATCH": [
421-
wobj["nvPairs"][key],
422-
hobj["nvPairs"].get(key, None),
423-
]
424-
}
425-
)
419+
# Special handling for useVirtualPeerlink in nvPairs to treat None and False as equivalent
420+
if key == "useVirtualPeerlink":
421+
hval = hobj["nvPairs"].get(key, None)
422+
wval = wobj["nvPairs"][key]
423+
if not ((hval is None and wval is False) or (hval is False and wval is None)):
424+
if str(hval).lower() != str(wval).lower():
425+
mismatch_reasons.append(
426+
{key.upper() + "_MISMATCH": [wval, hval]}
427+
)
428+
else:
429+
if (
430+
str(hobj["nvPairs"].get(key, None)).lower()
431+
!= str(wobj["nvPairs"][key]).lower()
432+
):
433+
# We found an object that matched all other key values, but differs in one of the params.
434+
mismatch_reasons.append(
435+
{
436+
key.upper()
437+
+ "_MISMATCH": [
438+
wobj["nvPairs"][key],
439+
hobj["nvPairs"].get(key, None),
440+
]
441+
}
442+
)
426443

427444
if mismatch_reasons != []:
428445
return "DCNM_VPC_PAIR_MERGE", mismatch_reasons, hobj

tests/integration/targets/dcnm_vpc_pair/tests/dcnm/dcnm_vpc_pair_merge.yaml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@
8484

8585
- assert:
8686
that:
87-
- 'result.changed == true'
87+
- 'result.changed == false'
8888
- '(result["diff"][0]["merged"] | length) == 0'
89-
- '(result["diff"][0]["modified"] | length) == 1'
89+
- '(result["diff"][0]["modified"] | length) == 0'
9090
- '(result["diff"][0]["deleted"] | length) == 0'
9191
- '(result["diff"][0]["query"] | length) == 0'
92-
- '(result["diff"][0]["deploy"] | length) == 1'
92+
- '(result["diff"][0]["deploy"] | length) == 0'
9393

9494
- assert:
9595
that:
@@ -163,12 +163,12 @@
163163

164164
- assert:
165165
that:
166-
- 'result.changed == true'
166+
- 'result.changed == false'
167167
- '(result["diff"][0]["merged"] | length) == 0'
168-
- '(result["diff"][0]["modified"] | length) == 1'
168+
- '(result["diff"][0]["modified"] | length) == 0'
169169
- '(result["diff"][0]["deleted"] | length) == 0'
170170
- '(result["diff"][0]["query"] | length) == 0'
171-
- '(result["diff"][0]["deploy"] | length) == 1'
171+
- '(result["diff"][0]["deploy"] | length) == 0'
172172
when: (fabric_type == "VXLANFabric")
173173

174174
- assert:
@@ -269,7 +269,7 @@
269269
- '(result["diff"][0]["modified"] | length) == 0'
270270
- '(result["diff"][0]["deleted"] | length) == 1'
271271
- '(result["diff"][0]["query"] | length) == 0'
272-
- '(result["diff"][0]["deploy"] | length) == 1'
272+
- '(result["diff"][0]["deploy"] | length) == 0'
273273
when: (fabric_type == "LANClassic")
274274

275275
- assert:
@@ -285,8 +285,6 @@
285285
- name: Create VPC switch pair without state and deploy flag
286286
cisco.dcnm.dcnm_vpc_pair:
287287
src_fabric: "{{ ansible_it_fabric }}"
288-
deploy: true
289-
state: merged
290288
config:
291289
- peerOneId: "{{ ansible_switch1 }}" # IP Address/Host Name of Peer1 of VPC switch pair, Mandatory: True, Type: str
292290
peerTwoId: "{{ ansible_switch2 }}" # IP Address/Host Name of Peer2 of VPC switch pair, Mandatory: True, Type: str
@@ -353,7 +351,7 @@
353351
cisco.dcnm.dcnm_vpc_pair:
354352
src_fabric: "{{ ansible_it_fabric }}"
355353
state: merged # only choose form [merged, replaced, deleted, overridden, query. fetch]
356-
deploy: true # Flag indicating whether changes are to be deployed, Mandatory: False, Type: bool, default: True
354+
deploy: false # Flag indicating whether changes are to be deployed, Mandatory: False, Type: bool, default: True
357355
config:
358356
- peerOneId: "{{ ansible_switch1 }}" # IP Address/Host Name of Peer1 of VPC switch pair, Mandatory: True, Type: str
359357
peerTwoId: "{{ ansible_switch2 }}" # IP Address/Host Name of Peer2 of VPC switch pair, Mandatory: True, Type: str
@@ -377,7 +375,7 @@
377375
- '(result["diff"][0]["modified"] | length) == 0'
378376
- '(result["diff"][0]["deleted"] | length) == 0'
379377
- '(result["diff"][0]["query"] | length) == 0'
380-
- '(result["diff"][0]["deploy"] | length) == 1'
378+
- '(result["diff"][0]["deploy"] | length) == 0'
381379

382380
- assert:
383381
that:

tests/integration/targets/dcnm_vpc_pair/tests/dcnm/dcnm_vpc_pair_override.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,17 @@
111111
- '(result["diff"][0]["deleted"] | length) == 0'
112112
- '(result["diff"][0]["query"] | length) == 0'
113113
- '(result["diff"][0]["deploy"] | length) == 1'
114-
when: (fabric_type == "LANClassic" or fabric_type == "VXLANFabric")
114+
when: (fabric_type == "LANClassic")
115+
116+
- assert:
117+
that:
118+
- 'result.changed == false'
119+
- '(result["diff"][0]["merged"] | length) == 0'
120+
- '(result["diff"][0]["modified"] | length) == 0'
121+
- '(result["diff"][0]["deleted"] | length) == 0'
122+
- '(result["diff"][0]["query"] | length) == 0'
123+
- '(result["diff"][0]["deploy"] | length) == 0'
124+
when: (fabric_type == "VXLANFabric")
115125

116126
- assert:
117127
that:
@@ -128,12 +138,12 @@
128138

129139
- assert:
130140
that:
131-
- 'result.changed == true'
141+
- 'result.changed == false'
132142
- '(result["diff"][0]["merged"] | length) == 0'
133-
- '(result["diff"][0]["modified"] | length) == 1'
143+
- '(result["diff"][0]["modified"] | length) == 0'
134144
- '(result["diff"][0]["deleted"] | length) == 0'
135145
- '(result["diff"][0]["query"] | length) == 0'
136-
- '(result["diff"][0]["deploy"] | length) == 1'
146+
- '(result["diff"][0]["deploy"] | length) == 0'
137147

138148
- assert:
139149
that:

tests/integration/targets/dcnm_vpc_pair/tests/dcnm/dcnm_vpc_pair_replace.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,17 @@
119119
- '(result["diff"][0]["deleted"] | length) == 0'
120120
- '(result["diff"][0]["query"] | length) == 0'
121121
- '(result["diff"][0]["deploy"] | length) == 1'
122-
when: (fabric_type == "LANClassic" or fabric_type == "VXLANFabric")
122+
when: (fabric_type == "LANClassic")
123+
124+
- assert:
125+
that:
126+
- 'result.changed == false'
127+
- '(result["diff"][0]["merged"] | length) == 0'
128+
- '(result["diff"][0]["modified"] | length) == 0'
129+
- '(result["diff"][0]["deleted"] | length) == 0'
130+
- '(result["diff"][0]["query"] | length) == 0'
131+
- '(result["diff"][0]["deploy"] | length) == 0'
132+
when: (fabric_type == "VXLANFabric")
123133

124134
- assert:
125135
that:
@@ -136,12 +146,12 @@
136146

137147
- assert:
138148
that:
139-
- 'result.changed == true'
149+
- 'result.changed == false'
140150
- '(result["diff"][0]["merged"] | length) == 0'
141-
- '(result["diff"][0]["modified"] | length) == 1'
151+
- '(result["diff"][0]["modified"] | length) == 0'
142152
- '(result["diff"][0]["deleted"] | length) == 0'
143153
- '(result["diff"][0]["query"] | length) == 0'
144-
- '(result["diff"][0]["deploy"] | length) == 1'
154+
- '(result["diff"][0]["deploy"] | length) == 0'
145155

146156
- assert:
147157
that:

0 commit comments

Comments
 (0)