|
578 | 578 | from ansible_collections.cisco.dcnm.plugins.module_utils.network.dcnm.dcnm import (
|
579 | 579 | dcnm_get_ip_addr_info, dcnm_get_url, dcnm_send, dcnm_version_supported,
|
580 | 580 | get_fabric_details, get_fabric_inventory_details, get_ip_sn_dict,
|
581 |
| - get_sn_fabric_dict, validate_list_of_dicts, search_nested_json) |
| 581 | + get_sn_fabric_dict, validate_list_of_dicts, search_nested_json, |
| 582 | + find_dict_in_list_by_key_value) |
582 | 583 |
|
583 | 584 | from ..module_utils.common.log_v2 import Log
|
584 | 585 |
|
@@ -1656,10 +1657,10 @@ def get_have(self):
|
1656 | 1657 | attach_list = vrf_attach["lanAttachList"]
|
1657 | 1658 | deploy_vrf = ""
|
1658 | 1659 | for attach in attach_list:
|
1659 |
| - attach_state = not attach["lanAttachState"] == "NA" |
1660 |
| - deploy = attach["isLanAttached"] |
| 1660 | + attach_state = bool(attach.get("isLanAttached", False)) |
| 1661 | + deploy = attach_state |
1661 | 1662 | deployed = False
|
1662 |
| - if deploy and ( |
| 1663 | + if attach_state and ( |
1663 | 1664 | attach["lanAttachState"] == "OUT-OF-SYNC"
|
1664 | 1665 | or attach["lanAttachState"] == "PENDING"
|
1665 | 1666 | ):
|
@@ -2064,10 +2065,17 @@ def get_diff_replace(self):
|
2064 | 2065 | self.diff_deploy = diff_deploy
|
2065 | 2066 | return
|
2066 | 2067 |
|
| 2068 | + modified_all_vrfs = copy.deepcopy(all_vrfs) |
| 2069 | + for vrf in all_vrfs: |
| 2070 | + # If the playbook sets the deploy key to False, then we need to remove the vrf from the deploy list. |
| 2071 | + want_vrf_data = find_dict_in_list_by_key_value(search=self.config, key="vrf_name", value=vrf) |
| 2072 | + if want_vrf_data['deploy'] is False: |
| 2073 | + modified_all_vrfs.remove(vrf) |
| 2074 | + |
2067 | 2075 | if not self.diff_deploy:
|
2068 |
| - diff_deploy.update({"vrfNames": ",".join(all_vrfs)}) |
| 2076 | + diff_deploy.update({"vrfNames": ",".join(modified_all_vrfs)}) |
2069 | 2077 | else:
|
2070 |
| - vrfs = self.diff_deploy["vrfNames"] + "," + ",".join(all_vrfs) |
| 2078 | + vrfs = self.diff_deploy["vrfNames"] + "," + ",".join(modified_all_vrfs) |
2071 | 2079 | diff_deploy.update({"vrfNames": vrfs})
|
2072 | 2080 |
|
2073 | 2081 | self.diff_attach = copy.deepcopy(diff_attach)
|
@@ -2368,7 +2376,14 @@ def diff_merge_attach(self, replace=False):
|
2368 | 2376 | if deploy_vrf:
|
2369 | 2377 | all_vrfs.append(deploy_vrf)
|
2370 | 2378 |
|
2371 |
| - if len(all_vrfs) != 0: |
| 2379 | + modified_all_vrfs = copy.deepcopy(all_vrfs) |
| 2380 | + for vrf in all_vrfs: |
| 2381 | + # If the playbook sets the deploy key to False, then we need to remove the vrf from the deploy list. |
| 2382 | + want_vrf_data = find_dict_in_list_by_key_value(search=self.config, key="vrf_name", value=vrf) |
| 2383 | + if want_vrf_data['deploy'] is False: |
| 2384 | + modified_all_vrfs.remove(vrf) |
| 2385 | + |
| 2386 | + if len(modified_all_vrfs) != 0: |
2372 | 2387 | diff_deploy.update({"vrfNames": ",".join(all_vrfs)})
|
2373 | 2388 |
|
2374 | 2389 | self.diff_attach = diff_attach
|
|
0 commit comments