Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcnm_fabric: Fix evaluation of controller features #362

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

allenrobel
Copy link
Collaborator

@allenrobel allenrobel commented Jan 7, 2025

Summary

closes #360

The evaluation of controller features in dcnm_fabric.py was broken due to using the wrong key to access the features dictionary. This PR fixes this, and also bypasses controller feature evaluation for ND 4.x.

Changes

1. plugins/modules/dcnm_fabric.py

1a. Fix dictionary access in Merged.get_need() and Replaced.get_need()

In the above methods, we were trying to retrieve the key "fabric_type" from the dict self.features. But this dict is keyed on the fabric type (e.g. keys in this dict are "ISN", "VXLAN_EVPN", etc).

self.features == {'IPFM': False, 'ISN': True, 'LAN_CLASSIC': True, 'VXLAN_EVPN': True, 'VXLAN_EVPN_MSD': True}

The fix is to remove the quotes around "fabric_type" -> fabric_type, which is a var containing the fabric type (ISN, VXLAN_EVPN, etc).

1b. Update feature evaluation checks for ND 4.0.

The NDFC versions (as returned by ControllerVersion()) for ND 3.2.1e and ND 4.0 respectively are:

12.2.2.238 -> ND 3.2.1e
12.3.1.248 -> ND 4.0 dev version 86

The unified architecture for ND 4.0 means that it no longer includes information about controller features relevant to fabrics at the endpoint /appcenter/cisco/ndfc/api/v1/fm/features. This impacts the contents of the self.features dictionary, for which all values are now False:

self.features == {'IPFM': False, 'ISN': False, 'LAN_CLASSIC': False, 'VXLAN_EVPN': False, 'VXLAN_EVPN_MSD': False}

Previously, (in ND 3.x) the oper_state for the "vxlan" feature at endpoint /appcenter/cisco/ndfc/api/v1/fm/features was expected to be "started" for VXLAN_EVPN fabric creation/modification and, similarly, oper_state for "pmn" feature was expected to be "started" for IPFM fabric creation/modification, etc). Since these keys are no longer in the endpoint's output, the values of the self.features dict are now all False. Hence, feature evaluation should be run only if NDFC int(version_minor) is less than 3 (and int(version_major) == 12).

Added call to ControllerVersion() and updated the feature evaluation check in Merged.get_need() and Replaced.get_need() such that we skip the check if the controller version implies ND 4.x.

2. plugins/module_utils/common/controller_version.py

2a. Added a property that returns True if the controller version implies ND 4.x and False otherwise.

2b. Updated docstrings in controller_version.py

Updated accessor property docstrings in ControllerVersion() to mention explicitly that a string is returned for version_major, version_minor, and version_patch.

3. Add unit tests for ControllerVersion().is_controller_version_4x

Add two unit tests to verify that ControllerVersion().is_controller_version_4x returns correct values for ND 3.x and ND 4.x NDFC versions.

Other

At endpoint /appcenter/cisco/ndfc/api/v1/fm/about/version which is used by the ControllerVersion() class, the version string has changed format (somewhere between 12.1.x and 12.2.x). Below are the old and new formats:

Old

12.1.3b (corresponding to version_major.version_minor.version_patch)

New (as of ND 3.2.1e)

12.2.1.238

The existing regex still works for the new format for version_major ("12" in this case), version_minor ("2" in this case).

But, version_patch now returns "1" rather than e.g. "1a", "1b", etc. And the regex does not accommodate ".238" at all.

Since nothing is currently breaking, I'm inclined to leave things as they are for now. We can add an additional property for the "238" portion of the version string when/if it becomes necessary.

Unit Tests

All unit tests pass.

Integration Tests

I ran the dcnm_fabric integration tests against ND 3.2.1e and ND 4.0 (dev version 86).

All tests pass for ND 3.2.1e.

The following tests fails for ND 4.0.

dcnm_fabric_replaced_basic_vxlan

Will open a separate issue to investigate. The template entries for ANYCAST_RP_IP_RANGE, MULTICAST_GROUP_SUBNET, and RP_LB_ID are identical between ND 3.2.1e and ND 4.0 version 86

fatal: [172.22.150.244]: FAILED! => {"changed": false, "metadata": [{"action": "fabric_replace", "check_mode": false, "sequence_number": 1, "state": "replaced"}], "msg": "Module failed.", "response": [{"DATA": "Invalid JSON response: Error in validating provided name value pair: [ANYCAST_RP_IP_RANGE, MULTICAST_GROUP_SUBNET, RP_LB_ID]", "MESSAGE": "Internal Server Error", "METHOD": "PUT", "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/VXLAN_EVPN_Fabric/Easy_Fabric", "RETURN_CODE": 500, "sequence_number": 1}], "result": [{"changed": false, "sequence_number": 1, "success": false}]}

1. Fix dictionary access in Merged.get_need() and Replaced.get_need()

In the above methods, we were trying to retrieve the key "fabric_type" from the dict  self.features. But this dict is keyed on the fabric type (e.g. keys in this dict are "ISN", "VXLAN_EVPN", etc).  The fix is to remove the quotes around "fabric_type" -> fabric_type, which is a var containing the fabric type ("ISN", "VXLAN_EVPN", etc).

2. Add backward-compatible feature verification for ND 4.0.

The NDFC versions (as returned by ControllerVersion) for  ND 3.2.1e and ND 4.0 respectively are:

12.2.2.238 -> ND 3.2.1e
12.3.1.248 -> ND 4.0

The unified architecture for ND 4.0 means that it no longer includes information about controller features relevant to fabrics (e.g. that "vxlan" feature must be enabled for VXLAN_EVPN fabric creation/modification, and "pmn" feature must be enabled for IPFM fabric creation/modification, etc).  Hence, this check should be  run only for NDFC minor versions less than 3.

Added call to ControllerVersion() and updated the check in get_need() such that we skip the check if ControllerVersion().version_minor < 3.

3. Updated docstrings in controller_version.py

Updated accessor property docstrings in ControllerVersion() to explicitely mention that a string is returned for version_major, version_minor, and version_patch.
We will probably need a way to tell ND 4.0 from ND 3.x in other modules at some point.

1. Add a property to ControllerVersion() that returns True if ND 4.x and False otherwise.

2. Leverage this property in dcnm_fabric.py Merged.get_need() and Replaced.get_need()
Add two unit tests to verify correct values are returned for ND 3.x and ND 4.x NDFC versions.
@allenrobel allenrobel added the Work in Progress Code not ready for review. label Jan 7, 2025
@allenrobel allenrobel requested a review from mikewiebe January 7, 2025 21:32
@allenrobel allenrobel self-assigned this Jan 7, 2025
@allenrobel allenrobel added ready for review PR is ready to be reviewed and removed Work in Progress Code not ready for review. labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dcnm_fabric: Fix controller feature evaluation and add initial ND 4.0 support
1 participant