dcnm_fabric: Fix evaluation of controller features #362
+166
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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()
andReplaced.get_need()
In the above methods, we were trying to retrieve the key
"fabric_type"
from the dictself.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).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.1e12.3.1.248
-> ND 4.0 dev version 86The 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 theself.features
dictionary, for which all values are nowFalse
: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"
forVXLAN_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 theself.features
dict are now allFalse
. Hence, feature evaluation should be run only if NDFCint(version_minor)
is less than 3 (andint(version_major)
== 12).Added call to
ControllerVersion()
and updated the feature evaluation check inMerged.get_need()
andReplaced.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 andFalse
otherwise.2b. Updated docstrings in
controller_version.py
Updated accessor property docstrings in
ControllerVersion()
to mention explicitly that a string is returned forversion_major
,version_minor
, andversion_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 theControllerVersion()
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
, andRP_LB_ID
are identical between ND 3.2.1e and ND 4.0 version 86