-
Notifications
You must be signed in to change notification settings - Fork 46
Commit 40d93d6
committed
Tentative fix for Issue #351
The fix entails a modification to wait_for_vrf_del_ready()
In both the legitimate case (user trying to delete a VRF after having removed all network attachments) `lanAttachState` very briefly transitions to DEPLOY before transitioning to its final state of NA. However, in this case, `isLanAttached` (in the same data structure) is False. Whereas in the illegitimate case (user hasn't removed network attachments) `isLanAttached` is True. Hence, we can leverage `isLanAttached` to differentiate between legitimate and illegitimate cases.
Adding another conditional that checks if `lanAttachState` == DEPLOY AND `isLanAttached` == True. If this is the case, then the user is trying to delete a VRF that still contains network attachments and we now fail immediately with an appropriate error message.
Other changes:
1. Add standard python logging
2. Use `ControllerVersion()` to retrieve the NDFC version and remove import for `dcnm_version_supported`
3. Use `FabricDetails()` to retrieve fabric type.
4. Modify `update_attach_params()` to improve readability by first populating the neighbor dictionary before appending it. This way, we avoid a lot of unsightly accesses to element 0 of the list. For example:
```python
if a_l["peer_vrf"]:
vrflite_con["VRF_LITE_CONN"][0]["PEER_VRF_NAME"] = a_l["peer_vrf"]
else:
vrflite_con["VRF_LITE_CONN"][0]["PEER_VRF_NAME"] = ""
```
Becomes:
```python
if a_l["peer_vrf"]:
nbr_dict["PEER_VRF_NAME"] = a_l["peer_vrf"]
else:
nbr_dict["PEER_VRF_NAME"] = ""
```
5. diff_for_attach_deploy() - Reduce indentation by reversing logic of conditional.
The following:
```python
if wlite["IF_NAME"] == hlite["IF_NAME"]:
# Lots of indented code ...
```
Becomes:
```python
if wlite["IF_NAME"] != hlite["IF_NAME"]:
continue
# unindent the above code
```
6. get_have()
- Reduce indentation levels by reversing logic (similar to #5 above)
7. Add method want_and_have_vrf_template_configs_differ(), see next item.
8. diff_for_create()
- Leverage want_and_have_vrf_template_configs_differ() to simplify.
9. Add method to_bool(), see next item
10. diff_for_attach_deploy()
- Simplify/shorten by leveraging to_bool()
11. In multiple places, ensure that a key exists before accessing it or deleting it.
12. Run though black
13. Several minor formatting changes for improved readability.1 parent 308acb6 commit 40d93d6Copy full SHA for 40d93d6
File tree
Expand file treeCollapse file tree
1 file changed
+618
-464
lines changedFilter options
- plugins/modules
Expand file treeCollapse file tree
1 file changed
+618
-464
lines changed
0 commit comments