networking_generic_switch.devices.ndfc_devices package¶
Submodules¶
networking_generic_switch.devices.ndfc_devices.cisco module¶
Cisco NDFC (Nexus Dashboard Fabric Controller) REST API Driver.
EXPERIMENTAL: This driver is experimental and based on publicly available NDFC API documentation. It manages Cisco NX-OS switches through the NDFC REST API. NDFC provides centralized fabric management with audit trails, templating, and policy-based configuration.
- API Documentation:
- Primary: https://developer.cisco.com/docs/
nexus-dashboard-fabric-controller/latest/
- Getting Started: https://developer.cisco.com/docs/
nexus-dashboard-fabric-controller/latest/ getting-started/
- Reference Implementation:
https://opendev.org/x/networking-cisco (ML2 driver)
The NDFC REST API follows OpenAPI 3.0 specification. API documentation is also embedded in the NDFC UI (accessible via Swagger UI).
- Authentication:
POST /login - Returns JWT token used in Authorization header
- Key API Endpoints Used (Modern NDFC API):
Based on Cisco networking-cisco ML2 driver implementation. Uses modern
/api/v1/manage/*paths (not legacy/appcenter/cisco/ndfc/*).- Switches/Inventory:
GET …/fabrics/{fabric}/switches
- Networks (VLANs and VXLANs):
POST …/fabrics/{fabric}/networks DELETE …/fabrics/{fabric}/networks/{network} POST …/fabrics/{fabric}/networkAttachments POST …/fabrics/{fabric}/networkActions/deploy
- Interfaces (legacy LAN Fabric REST API):
PUT /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/interface POST /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/interface/deploy
- Configuration Deployment:
- POST /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/
fabrics/{fabricName}/config-deploy/{switchId}
- class networking_generic_switch.devices.ndfc_devices.cisco.CiscoNDFC(device_cfg, device_name='')¶
Bases:
GenericSwitchDeviceCisco NDFC REST API-based switch driver.
Manages Cisco NX-OS switches through Nexus Dashboard Fabric Controller (NDFC) REST API. Supports VLAN provisioning, port configuration, trunk management, and VXLAN L2VNI configuration via NDFC fabric controller.
Port can be disabled: True
Configuration Parameters¶
- Required:
host: NDFC hostname or IP address
username: NDFC authentication username
password: NDFC authentication password
ndfc_fabric_name: NDFC fabric name (default: ‘default’)
ngs_network_name_format: Must contain
{segmentation_id}. Additional static text is permitted (e.g.neutron-{segmentation_id}). The value{segmentation_id}is appropriate for most deployments.
- Switch identification:
The config section name (e.g.
[genericswitch:leaf01]) must match the switch hostname in NDFC. This aligns with Ironicswitch_info.Optional overrides: - ndfc_switch_serial: Explicit serial number (skips hostname lookup). - ndfc_switch_hostname: Override if hostname differs from section name.
- Optional NDFC Templates and Policies:
ndfc_network_template: Network template name (default: ‘Default_Network_Universal’)
ndfc_network_extension_template: Network extension template name (default: ‘Default_Network_Extension_Universal’)
ndfc_vrf: VRF name for network creation (default: ‘default’)
ndfc_interface_policy: Interface policy template name for trunk (uplink) ports configured via
ngs_trunk_ports(default: ‘int_trunk_host’). Host-facing ports configured viaplug_port_to_networkalways useint_access_host.
- Optional Connection Settings:
port: NDFC HTTPS port (default: 443)
ngs_verify_tls: Verify the NDFC TLS certificate (default: True)
ndfc_timeout: Request timeout in seconds (default: 30)
ngs_max_connections: Session connection pool size, per NDFC controller (default: 1).
NDFC Instance Sharing¶
Multiple switch configurations pointing to the same NDFC instance automatically share a single authenticated session, pooled by hashed credentials. Token expiration is handled automatically with retry logic.
VXLAN L2VNI Support¶
Supports hierarchical port binding with VXLAN L2VNI. NDFC handles NVE interface configuration, BGP EVPN control plane, and VXLAN data plane based on the fabric template.
Security Group Implementation¶
Security groups are not currently implemented.
- PLUG_SWITCH_TO_NETWORK = True¶
- UNPLUG_SWITCH_FROM_NETWORK = True¶
- add_network(segmentation_id, network_id)¶
Create pure VLAN network in NDFC fabric.
For VXLAN L2VNI networks, use plug_switch_to_network() instead.
- Parameters:
segmentation_id – VLAN ID
network_id – Neutron network UUID
- add_security_group(sg_id, rules)¶
Create security group policy in NDFC.
- add_subports_on_trunk(binding_profile, port, subports)¶
Add subports to a trunk port via interface policy.
Fetches the current ALLOWED_VLANS, appends all subport VLANs, and writes the updated list in a single PUT. Bond ports are not supported (support_trunk_on_bond_ports is False).
- LAN Fabric REST API:
GET /lan-fabric/rest/interface - Fetch current ALLOWED_VLANS
PUT /lan-fabric/rest/interface - Set updated ALLOWED_VLANS
POST /lan-fabric/rest/interface/deploy - Push to device
POST /lan-fabric/rest/control/fabrics/{f}/config-deploy/{s}
- Parameters:
binding_profile – Neutron binding profile (unused — bond ports are blocked upstream by support_trunk_on_bond_ports)
port – Switch port identifier (e.g. ‘Ethernet1/1’)
subports – List of subport dicts with ‘segmentation_id’
- bind_security_group(sg_id, port)¶
Bind security group to port.
- del_network(segmentation_id, network_id)¶
Delete VLAN network from NDFC fabric.
For VXLAN L2VNI networks, use unplug_switch_from_network() instead.
- Parameters:
segmentation_id – VLAN ID
network_id – Neutron network UUID
- del_security_group(sg_id)¶
Delete security group policy.
- del_subports_on_trunk(binding_profile, port, subports)¶
Remove subports from a trunk port via interface policy.
Fetches the current ALLOWED_VLANS, removes all subport VLANs, and writes the updated list in a single PUT. If no VLANs remain, reverts the port to int_access_host on the default VLAN.
- LAN Fabric REST API:
GET /lan-fabric/rest/interface - Fetch current ALLOWED_VLANS
PUT /lan-fabric/rest/interface - Set updated ALLOWED_VLANS
POST /lan-fabric/rest/interface/deploy - Push to device
POST /lan-fabric/rest/control/fabrics/{f}/config-deploy/{s}
- Parameters:
binding_profile – Neutron binding profile (unused — bond ports are blocked upstream by support_trunk_on_bond_ports)
port – Switch port identifier (e.g. ‘Ethernet1/1’)
subports – List of subport dicts with ‘segmentation_id’
- delete_port(port, segmentation_id, trunk_details=None, default_vlan=None)¶
Remove port from network.
Access ports: moves to default VLAN. Trunk ports: removes VLANs; reverts to access mode if no VLANs remain.
- Parameters:
port – Port identifier
segmentation_id – VLAN ID
trunk_details – Dict with ‘sub_ports’ list for trunk mode
default_vlan – Default VLAN override (access mode only)
- plug_port_to_network(port, segmentation_id, trunk_details=None, default_vlan=None)¶
Configure switch port for network access.
Configures access ports with int_access_host policy or trunk ports with int_trunk_host policy, setting VLANs appropriately.
- Parameters:
port – Port identifier (e.g., ‘Ethernet1/1’)
segmentation_id – VLAN ID (native VLAN for trunk ports)
trunk_details – Dict with ‘sub_ports’ list for trunk config
default_vlan – Native VLAN override (access mode only)
- plug_switch_to_network(vni, segmentation_id, physnet=None)¶
Configure L2VNI mapping in NDFC fabric.
Creates VXLAN network with VNI-to-VLAN mapping. NDFC handles NVE interface configuration and BGP EVPN control plane setup.
- Parameters:
vni – VXLAN Network Identifier
segmentation_id – VLAN ID to map to the VNI
physnet – Physical network name (unused)
- property support_trunk_on_bond_ports¶
- property support_trunk_on_ports¶
- unbind_security_group(sg_id, port)¶
Unbind security group from port.
- unplug_switch_from_network(vni, segmentation_id, physnet=None)¶
Remove L2VNI mapping from NDFC fabric.
Clears vn-segment configuration on the VLAN.
- Parameters:
vni – VXLAN Network Identifier to remove
segmentation_id – VLAN ID
physnet – Physical network name (unused)
- update_security_group(sg_id, rules)¶
Update security group policy.
- vlan_has_ports(segmentation_id)¶
Check if VLAN has ports assigned in NDFC.
Queries all interfaces on this switch and checks ACCESS_VLAN and ALLOWED_VLANS nvPairs to determine if any port carries the VLAN.
LAN Fabric REST API:
- GET /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/interface
?serialNumber={serial}
Response: [{‘policy’: …, ‘interfaces’: [{‘nvPairs’: {…}}]}]
- Parameters:
segmentation_id – VLAN ID to check
- Returns:
True if VLAN has ports, False if empty
- vlan_has_vni(segmentation_id, vni)¶
Check if VLAN has VNI mapping configured in NDFC.
Queries NDFC to check if a network with the given VNI exists and is attached to this switch with the specified VLAN.
- Parameters:
segmentation_id – VLAN ID
vni – VNI to check for
- Returns:
True if VNI is configured, False otherwise