ControllerFeatures() class to retrieve admin and oper state of NDFC features.
FabricTypes() add FABRIC_TYPE to feature mapping.
Maps FABRIC_TYPE to the NDFC feature (e.g. "vxlan", "pmn") required to be enabled for that FABRIC_TYPE
Smart Endpoints
A standardized, shareable, extensible set of classes for retrieving NDFC REST API endpoints.
Exactly parallels NDFC REST API hierarchy.
Currently contains endpoints used by the dcnm_fabric and image_upgrade modules.
We can add more in the future.
Example NDFC REST API endpoint retrieval is below.
from ansible_collections.cisco.dcnm.plugins.module_utils.common.api.v1.rest.control.fabrics.fabrics import \
EpFabricConfigDeploy
instance = EpFabricConfigDeploy()
# fabric_name is validated by the class to conform to NDFC requirements.
try:
instance.fabric_name = "MyFabric"
except ValueError as error:
ansible_module.fail_json(error)
response = dcnm_send(module, instance.verb, instance.path)
# etc...
Review notes
Smart Endpoints
Most files in this commit have to do with Smart Endpoints; small classes which, together, construct and validate NDFC REST API endpoints. The parent class is Api() in module_utils/common/api. Below that, are subclasses which inherit from Api(); each subclass adding its portion to the final endpoint path retrieved via the leaf classes. For example Api() builds the initial path (self.api) of /appcenter/cisco/ndfc/api. Then the V1() class in api/v1/.v1.py adds self.v1 = f"{self.api}/v1"} to the path, etc, down the endpoint path hierarchy.
Each class does its own validations depending on the requirements of the endpoint. Generally, the contents of the set() self.mandatory_properties -- inherited from Api() -- are updated within a leaf subclass. For example, see the leaf class EpTemplate() in ./api/v1/configtemplate/rest/config/templates/templates.py, which mandates that template_name be set by adding "template_name" to the self.mandatory_properties set within its constructor.
dcnm_fabric has been updated to use Smart Endpoints throughput and the "legacy" endpoint class ApiEndpoints() has been removed. Most of the diffs within module_utils/fabric have to do with replacing the legacy endpoints with Smart Endpoints.
The remaining diffs in this commit are related to the addition of integration tests, and modifications to unit tests in tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py for IPFM on lines 50, 67, 123, and 134.
Commit Contents
dcnm_fabric
andimage_upgrade
modules.Review notes
Smart Endpoints
Api()
inmodule_utils/common/api
. Below that, are subclasses which inherit fromApi()
; each subclass adding its portion to the final endpoint path retrieved via the leaf classes. For exampleApi()
builds the initial path (self.api
) of/appcenter/cisco/ndfc/api
. Then the V1() class inapi/v1/.v1.py
addsself.v1 = f"{self.api}/v1"}
to the path, etc, down the endpoint path hierarchy.self.mandatory_properties
-- inherited fromApi()
-- are updated within a leaf subclass. For example, see the leaf classEpTemplate()
in./api/v1/configtemplate/rest/config/templates/templates.py
, which mandates thattemplate_name
be set by adding "template_name" to theself.mandatory_properties
set within its constructor.ApiEndpoints()
has been removed. Most of the diffs withinmodule_utils/fabric
have to do with replacing the legacy endpoints with Smart Endpoints.dcnm_fabric IPFM Support
module_utils/fabric/fabric_types.py, lines 74, 83, 94,
tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py
for IPFM on lines50, 67, 123, and 134
.