šŸ¤– Infrastructure Automation

Model Driven Programmability & Management Approaches

šŸ¤– 5.1 Model Driven Programmability

What is Model Driven Programmability?

Model Driven Programmability uses standardized data models (YANG) to configure and manage network devices. Instead of CLI commands, you work with structured data models.

graph TD A["Model Driven Programmability"] --> B["YANG Models"] A --> C["NETCONF"] A --> D["RESTCONF"] B --> B1["IETF"] B --> B2["OpenConfig"] B --> B3["Cisco Native"] C --> C1["XML-based"] C --> C2["Port 830"] D --> D1["REST API"] D --> D2["JSON/XML"] style A fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style B fill:#66bb6a,stroke:#2e7d32,stroke-width:2px,color:#fff style C fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff style D fill:#ffa726,stroke:#e65100,stroke-width:2px,color:#fff

YANG Data Models

šŸ“„ Standardized Configuration Models

YANG is a data modeling language for network configuration and state data.

# YANG Model Example
module ietf-interfaces {
    namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
    prefix if;
    
    container interfaces {
        list interface {
            key "name";
            leaf name {
                type string;
            }
            leaf description {
                type string;
            }
            leaf enabled {
                type boolean;
                default true;
            }
        }
    }
}

NETCONF Protocol

šŸ”Œ XML-Based Configuration Protocol

NETCONF provides a standardized way to configure network devices using XML over SSH (port 830).

# Python NETCONF Example
from ncclient import manager

with manager.connect(
    host='192.168.1.1',
    port=830,
    username='admin',
    password='password',
    hostkey_verify=False
) as m:
    # Get configuration
    config = m.get_config(source='running')
    print(config)

RESTCONF Protocol

🌐 RESTful API for YANG Models

RESTCONF provides HTTP-based access to YANG data models.

# Python RESTCONF Example
import requests

url = "https://192.168.1.1/restconf/data/ietf-interfaces:interfaces"
headers = {
    "Content-Type": "application/yang-data+json",
    "Accept": "application/yang-data+json"
}

response = requests.get(url, headers=headers, auth=('admin', 'password'), verify=False)
print(response.json())

āš–ļø 5.2 Controller vs Device Management

Overview

Controller-level management uses centralized controllers, while device-level management involves direct device configuration.

graph TD A["Network Management"] --> B["Controller-Level"] A --> C["Device-Level"] B --> B1["Cisco DNA Center"] B --> B2["Meraki Dashboard"] B --> B3["ACI APIC"] C --> C1["CLI"] C --> C2["NETCONF/RESTCONF"] C --> C3["APIs"] style A fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style B fill:#66bb6a,stroke:#2e7d32,stroke-width:2px,color:#fff style C fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff

Controller-Level Management

šŸŽÆ Centralized Control

Controller-level management provides a single pane of glass for network operations.

Benefits

  • Centralized View: Single dashboard for entire network
  • Policy-Based: Define intent, controller implements
  • Automation: Bulk operations across devices
  • Simplified: Abstract complexity
# Controller API Example (DNA Center)
import requests

url = "https://dna-center.example.com/dna/intent/api/v1/network-device"
headers = {
    "X-Auth-Token": "your_token",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers, verify=False)
devices = response.json()
print(f"Found {len(devices['response'])} devices")

Device-Level Management

šŸ”§ Direct Device Control

Device-level management provides granular control over individual devices.

Use Cases

  • Troubleshooting: Direct access for debugging
  • Specific Features: Access device-specific features
  • Custom Config: Fine-grained control
  • Legacy Devices: Devices not managed by controller
# Device API Example (RESTCONF)
import requests

url = "https://192.168.1.1/restconf/data/ietf-interfaces:interfaces"
headers = {
    "Content-Type": "application/yang-data+json",
    "Accept": "application/yang-data+json"
}

response = requests.get(url, headers=headers, auth=('admin', 'password'), verify=False)
print(response.json())

Comparison Table

Aspect Controller-Level Device-Level
Scope Network-wide Per device
Complexity Simplified Detailed
Speed Bulk operations Individual config
Best For Day-to-day operations Troubleshooting

šŸ Interactive Python Interpreter

šŸ’” How to use:
  • Write Python code in the editor
  • Click "ā–¶ Run Code" to execute
  • Try sample code buttons
šŸ“ Python Code Editor
⚔ Console Output
Ready to execute Python code...