Skip to content

Commit

Permalink
Enable useVirtualPeerlink for state merged
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewiebe committed Nov 14, 2024
1 parent 43d5ca5 commit 671ab98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions plugins/module_utils/network/dcnm/dcnm_vpc_pair_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"VPC_PAIR_DELETE_PATH": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/vpcpair?serialNumber={}",
"VPC_PAIR_DEPLOY_PATH": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{}/config-deploy/{}?forceShowRun=false",
"VPC_PAIR_CFG_SAVE_PATH": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{}/config-save",
"VPC_PEER_LINK_GET_PATH": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/vpcpair/recommendation?serialNumber={}&useVirtualPeerlink=true",
"FABRIC_ACCESS_MODE": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{}/accessmode",
},
}
Expand Down Expand Up @@ -209,6 +210,21 @@ def dcnm_vpc_pair_utils_get_vpc_pair_info_from_dcnm(self, swid):
else:
return []

# Get useVirtualPeerlink information
path = self.paths["VPC_PEER_LINK_GET_PATH"]
path = path.format(peerOneId)
resp = dcnm_send(self.module, "GET", path)

if (
resp
and (resp["RETURN_CODE"] == 200)
and (resp["MESSAGE"] == "OK")
and resp["DATA"]
):
useVirtualPeerlink = resp["DATA"][0].get("useVirtualPeerlink", None)
else:
return []

# Get the Profile information now and combine both the first response data and the current one to
# form the 'have' object. There is no direct call to get this combined information.
path = self.paths["VPC_PAIR_GET_POLICY_PATH"]
Expand All @@ -226,6 +242,7 @@ def dcnm_vpc_pair_utils_get_vpc_pair_info_from_dcnm(self, swid):
resp["DATA"]["peerTwoId"] = peerTwoId
resp["DATA"]["peerOneDbId"] = peerOneDbId
resp["DATA"]["peerTwoDbId"] = peerTwoDbId
resp["DATA"]["useVirtualPeerlink"] = useVirtualPeerlink

# Some of the fields in 'have' may be different than what is sent in CREATE/UPDATE/DELETE payloads to DCNM. Update these
# fields,if any, so that all keys are consistent between 'want' and 'have'. This will be necessary for compare function to
Expand Down Expand Up @@ -634,6 +651,9 @@ def dcnm_vpc_pair_utils_process_modify_payloads(self):
path = self.paths["VPC_PAIR_UPDATE_PATH"]

json_payload = json.dumps(elem)
# Sample json_payload
# '{"useVirtualPeerlink":true,"peerOneId":"FDO24020JMB","peerTwoId":"FDO24020JMT"}'

resp = dcnm_send(self.module, "PUT", path, json_payload)

if resp != []:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/dcnm_vpc_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def dcnm_vpc_pair_validate_input(self, cfg):
"peerOneId": {"required": "True", "type": "ipv4"},
"peerTwoId": {"required": "True", "type": "ipv4"},
"templateName": {"type": "str"},
"useVirtualPeerLink": {"type": "bool"},
"useVirtualPeerlink": {"type": "bool"},
"profile": {"type": "dict"},
}

Expand Down

0 comments on commit 671ab98

Please sign in to comment.