Skip to content

Conversation

@camschaecisco
Copy link
Contributor

MPLS Label Mode Support

Add Terraform mapping logic to translate schema's MPLS label mode configurations into the Terraform provider's iosxe_mpls resource attributes.

Schema Mappings

Device MPLS Configuration:

  • mpls.label_protocol → label_protocol
  • mpls.label_mode_all_vrfs_protocol_all_afs_per_vrf → label_mode_all_vrfs_protocol_all_afs_per_vrf
  • mpls.label_mode_all_vrfs_protocol_all_afs_per_prefix → label_mode_all_vrfs_protocol_all_afs_per_prefix
  • mpls.label_mode_all_vrfs_protocol_all_afs_per_ce → label_mode_all_vrfs_protocol_all_afs_per_ce
  • mpls.label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr → label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf → label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix → label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce → label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr → label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf → label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix → label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce → label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce
  • mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr → label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr

Changes

Add new MPLS resource module iosxe_mpls.tf:

  • label_protocol (line 5) - MPLS label distribution protocol (ldp, tdp)
  • label_mode_all_vrfs_protocol_all_afs_per_vrf (line 6) - Per-VRF label mode for all address families
  • label_mode_all_vrfs_protocol_all_afs_per_prefix (line 7) - Per-prefix label mode for all address families
  • label_mode_all_vrfs_protocol_all_afs_per_ce (line 8) - Per-CE label mode for all address families
  • label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr (line 9) - VRF connected aggregate for all address families
  • label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf (line 10) - Per-VRF label mode for BGP VPNv4
  • label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix (line 11) - Per-prefix label mode for BGP VPNv4
  • label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce (line 12) - Per-CE label mode for BGP VPNv4
  • label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr (line 13) - VRF connected aggregate for BGP VPNv4
  • label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf (line 14) - Per-VRF label mode for BGP VPNv6
  • label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix (line 15) - Per-prefix label mode for BGP VPNv6
  • label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce (line 16) - Per-CE label mode for BGP VPNv6
  • label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr (line 17) - VRF connected aggregate for BGP VPNv6
  • for_each (line 2) - Multi-device deployment support
  • Support for device-specific, default, and null configuration values
  • Three-tier fallback hierarchy: device config → global defaults → null
  • Pre-commit hooks passed: terraform fmt, tflint, terraform-docs

This Enables Declarative Configuration of:

  • MPLS label distribution protocol selection (LDP/TDP) for label-switched networks
  • Per-device MPLS label mode policies with global default fallback
  • Granular label allocation strategies across all address families (IPv4/IPv6 unicast/multicast)
  • Address-family-specific label modes for BGP VPNv4 and VPNv6 deployments
  • Per-VRF label allocation for label efficiency (single label per VRF)
  • Per-prefix label allocation for traffic engineering and granular control
  • Per-CE label allocation for customer edge differentiation
  • VRF connected aggregate mode for optimized connected route label distribution
  • Multi-device MPLS/VPN deployments from centralized YAML data models
  • Network-wide MPLS label distribution behavior consistency
  • Service provider MPLS VPN infrastructure provisioning
  • Layer 3 VPN service deployment with flexible label allocation
  • GitOps workflows for MPLS configuration management
  • Carrier supporting carrier (CSC) and inter-AS VPN scenarios
  • Label space optimization across large-scale MPLS networks

Version Requirements

IOS-XE 17.15 and later:

  • ✅ label_protocol - MPLS label distribution protocol
  • ✅ label_mode_all_vrfs_protocol_all_afs_per_vrf - Per-VRF mode for all AFs
  • ✅ label_mode_all_vrfs_protocol_all_afs_per_prefix - Per-prefix mode for all AFs
  • ✅ label_mode_all_vrfs_protocol_all_afs_per_ce - Per-CE mode for all AFs
  • ✅ label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr - VRF connected aggregate for all AFs
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf - Per-VRF mode for BGP VPNv4
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix - Per-prefix mode for BGP VPNv4
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce - Per-CE mode for BGP VPNv4
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr - VRF connected aggregate for BGP VPNv4
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf - Per-VRF mode for BGP VPNv6
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix - Per-prefix mode for BGP VPNv6
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce - Per-CE mode for BGP VPNv6
  • ✅ label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr - VRF connected aggregate for BGP VPNv6

Platform Notes:

  • Both Cat8k routers and Cat9k switches support MPLS label mode features
  • Label mode choices are mutually exclusive within each protocol/address-family scope
  • YANG model contains implicit case nodes requiring element name duplication in provider
  • Feature validated on IOS-XE 17.15.1

Example Configuration

Per-VRF Label Mode (Recommended for Label Efficiency):

iosxe:
  devices:
    - name: Cat8k-Router
      configuration:
        mpls:
          label_protocol: ldp
          label_mode_all_vrfs_protocol_all_afs_per_vrf: true

Per-Prefix Label Mode for Traffic Engineering:
iosxe:
  devices:
    - name: Cat9k-Switch
      configuration:
        mpls:
          label_protocol: ldp
          label_mode_all_vrfs_protocol_all_afs_per_prefix: true

BGP VPNv4-Specific Label Mode:
iosxe:
  devices:
    - name: PE-Router
      configuration:
        mpls:
          label_protocol: ldp
          label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf: true

Comprehensive Multi-AF Configuration:
iosxe:
  devices:
    - name: Core-Router
      configuration:
        mpls:
          label_protocol: ldp
          label_mode_all_vrfs_protocol_all_afs_per_vrf: true
          label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf: true
          label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf: true

Global Defaults:
iosxe:
  defaults:
    configuration:
      mpls:
        label_protocol: ldp
        label_mode_all_vrfs_protocol_all_afs_per_vrf: true

Testing

Multi-Platform Validation
- ✅ Catalyst 8000V (Router, IOS-XE 17.15): MPLS deployed successfully
  - LDP protocol with per-VRF label mode for all address families
- ✅ Catalyst 9000 (Switch, IOS-XE 17.15): MPLS deployed successfully
  - LDP protocol with per-prefix label mode for all address families

Terraform Operations Verified
- ✅ terraform plan - Correctly identifies MPLS configuration changes
- ✅ terraform apply - Successfully creates MPLS configuration
- ✅ terraform destroy - Cleanly removes MPLS configuration
- ✅ Device verification - All MPLS settings present in running-config
- ✅ State management - Proper resource state tracking across lifecycle
- ✅ Idempotency - No changes on second apply
- ✅ Multi-device deployment - Tested with both router and switch simultaneously

Robot Framework Integration Tests
- ✅ Router tests passed (1/1) - Per-VRF mode validated via RESTCONF
- ✅ Switch tests passed (1/1) - Per-prefix mode validated via RESTCONF
- ✅ RESTCONF validation - JSONPath queries validate all 13 parameters
- ✅ Schema validation - nac-validate passes for all test data
- ✅ Overall result: 2 tests, 2 passed, 0 failed, 0 skipped

Pre-commit Quality Checks
- ✅ Terraform fmt............................................................Passed
- ✅ Terraform validate with tflint...........................................Passed
- ✅ terraform-docs...........................................................Passed
- ✅ terraform-docs...........................................................Passed
- ✅ terraform-docs...........................................................Passed
- ✅ terraform-docs...........................................................Passed

This commit adds Terraform mapping logic to translate MPLS label mode
configurations from the NaC schema into the terraform-provider-iosxe
iosxe_mpls resource attributes.

Features:
- MPLS label protocol configuration mapping
- Label mode configuration for all address families
- Label mode configuration for BGP VPNv4 address family
- Label mode configuration for BGP VPNv6 address family
- Multi-device deployment support with for_each iteration
- Three-tier fallback hierarchy: device config → global defaults → null

Changes:
- Added iosxe_mpls.tf module with 13 attribute mappings
- Updated README.md with iosxe_mpls resource reference
- Validated with pre-commit hooks (terraform fmt, tflint, terraform-docs)
- Tested on Cat8kv router and Cat9kv switch platforms (IOS-XE 17.15)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants