0% found this document useful (0 votes)
11 views

Spanish - Automatización de Redes

Uploaded by

pedropablobm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Spanish - Automatización de Redes

Uploaded by

pedropablobm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

YANG, NETCONF, and RESTCONF

Oscar Ramírez
Systems Engineer
May 2019
Agenda
• The Road to Model Driven Programmability
• Introduction to YANG Data Models
• Introduction to NETCONF
• Introduction to RESTCONF
• Conclusion and Q/A

© 2018 Cisco and/or its affiliates. All rights reserved.

2
Why Network Programmability

Automation Integration Innovation

© 2018 Cisco and/or its affiliates. All rights reserved.


Programmability Benefits
• Innovation and business agility
• Highly skilled architects and engineers focus on business
• Service delivery optimization
• Cost reduction and increased efficiencies
• Service level improvements
• Improved network availability due to reduced human error

© 2018 Cisco and/or its affiliates. All rights reserved.


What Are Data Models
• Data models are conceptual representations of data
• Define what data is required
• Define the format to represent data
• Enable access by multiple applications, or protocols
• Do not contain any data

© 2018 Cisco and/or its affiliates. All rights reserved.


• Typical config: SNMPv2 read-only
What about SNMP? community strings
• Typical usage: interface statistics
SNMP works queries and traps
• Empirical Observation: SNMP is not
“reasonably well for used for configuration
device monitoring” • Lack of Writeable MIBs
• Security Concerns
• Difficult to Replay/Rollback
• Special Applications

© 2018 Cisco and/or its affiliates. All rights reserved.

6
RFC 3535: What is Needed?
• A programmatic interface for device
configuration
• Separation of Configuration and
State Data
• Ability to configure "services" NOT
"devices"
• Integrated error checking and
recovery

© 2018 Cisco and/or its affiliates. All rights reserved.

7
Model Driven Programmability
• NETCONF – 2006 – RFC 4741
(RFC 6241 in 2011)
• YANG – 2010 – RFC 6020
• RESTCONF – 2017 – RFC 8040
• gRPC – 2015 – OpenSource project
by Google
• Not covered in today’s session

© 2018 Cisco and/or its affiliates. All rights reserved.

8
What is YANG?
YANG Modeling Language
• Yet Another Next Generation (YANG) data modeling
language – RFC 6020
• Language for describing network devices data models
• YANG data models are composed of modules which represent
individual YANG files
• YANG modules are hierarchical tree structures for organizing
data

© 2018 Cisco and/or its affiliates. All rights reserved.

10
YANG Characteristics module ietf-interfaces {
import ietf-yang-types {
• Module that is a self-contained top- prefix yang;
level hierarchy of nodes }
container interfaces {
• Uses containers to group related nodes list interface {
• Lists to identify nodes that are stored key "name";
in sequence leaf name {
type string;
• Each individual attribute of a node is }
represented by a leaf leaf enabled {
type boolean;
• Every leaf must have an
default "true";
associated type }
© 2018 Cisco and/or its affiliates. All rights reserved.
}
YANG Variables

© 2018 Cisco and/or its affiliates. All rights reserved.


Get to know YANG 
NETCONF RESTCONF gRPC

YANG Data Models

Open Native

Configuration and Operation

Device Features
SNMP
Interface BGP QoS ACL …

Where can I find the YANG data models?


Network devices
https://github.com/YangModels/yang
© 2018 Cisco and/or its affiliates. All rights reserved.
YANG Tools
YANG Validator
Fetch, extract, and validate YANG modules by RFC
number, IETF draft name, or by uploading files.
http://www.yangvalidator.com

pyang
An extensible YANG validator and converter in
Python.
https://github.com/mbj4668/pyang

ydk-gen
Extensions to pyang for generating code from
YANG models.
https://github.com/CiscoDevNet/ydk-gen

yang-explorer
An open-source YANG browser and RPC builder
application.
https://github.com/CiscoDevNet/yang-explorer

© 2018 Cisco and/or its affiliates. All rights reserved.


YANG Tools

• YANG Explorer

• Pyang – Python library

• YANG Catalog

Help searching the


YANG Data Models
© 2018 Cisco and/or its affiliates. All rights reserved.
NETCONF
NETCONF - Network Configuration Protocol
• Rich functionality to manage configuration and operational
(state) data
• Client (application) initiates connection (using SSH) towards
server (network device)
• Capability exchange during session initiation, XML encoding
• Supports running, candidate and startup configurations
• Methods: <get-config>, <edit-config>, <get>, …
• Operations defined as RPCs

© 2018 Cisco and/or its affiliates. All rights reserved.

17
NETCONF Protocol Stack

© 2018 Cisco and/or its affiliates. All rights reserved.


Operations - NETCONF Actions
Operation Description
<get> Retrieve running configuration and device state information
<get-config> Retrieve all or part of specified configuration data store
<edit-config> Loads all or part of a configuration to the specified configuration data store

<copy-config> Replace an entire configuration data store with another


<delete-config> Delete a configuration data store
<commit> Copy candidate data store to running data store
<lock> / <unlock> Lock or unlock the entire configuration data store system
<close-session> Graceful termination of NETCONF session
<kill-session> Forced termination of NETCONF session

© 2018 Cisco and/or its affiliates. All rights reserved.


NETCONF Data Stores
Name Description

This datastore holds the complete configuration currently active on the


network device. Only one running configuration datastore exists on
running
the device, and it is always present. This datastore is referenced by
using the <running> element. See RFC 6241, Section 5.1.

This datastore holds configuration data that serves as a workplace for


creating and manipulating configuration data. A <commit> operation
causes the device's running configuration to be set to the value of the
candidate
candidate configuration. Any uncommitted changes to the candidate
configuration can be removed by executing the <discard-changes>
operation. See RFC 6241, Section 8.3.

Configuration loaded by the device when it boots. Operations that


affect the running configuration will not be automatically copied to
the startup configuration. An explicit <copy-config> operation from
startup
the <running> to the <startup> is used to update the startup
configuration to the current contents of the running configuration.
Referred to using the <startup> element. RFC6241 section 8.7.

© 2018 Cisco and/or its affiliates. All rights reserved.


NETCONF Communications

Have you seen


something similar?
© 2018 Cisco and/or its affiliates. All rights reserved.
NETCONF vs SNMP

© 2018 Cisco and/or its affiliates. All rights reserved.


NETCONF RPC Request
from ncclient import manager
import xml
import xml.dom.minidom SSH Connection Info:
network device
with manager.connect(host=RW_HOST, port=PORT, username=USER, username/password
password=PASS, hostkey_verify=False,
device_params={'name': 'default'},
TCP Port
allow_agent=False, look_for_keys=False) as m: (default 830)
# XML filter to issue with the get operation
# IOS-XE 16.6.2+ YANG model called "ietf-interfaces"

interface_filter = '''
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
Filter<interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
<name>GigabitEthernet1</name>
</interface>
</interfaces-state>
</filter>
''' Method

result = m.get(interface_filter)
© 2018 Cisco and/or its affiliates. All rights reserved.
xml_doc = xml.dom.minidom.parseString(result.xml) Parsing XML
NETCONF Response
<rpc-reply message-id="urn:uuid:50bf9d6e-7e5c-4182-ae6b-972a055ceef7" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<data>
<interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
<name>GigabitEthernet1</name>
<admin-status>up</admin-status>
<oper-status>up</oper-status>
<phys-address>00:0c:29:6c:81:06</phys-address>
<speed>1024000000</speed>
<statistics>
<in-octets>5432293472</in-octets>
<in-unicast-pkts>28518075</in-unicast-pkts>
……………
<out-octets>2901845514</out-octets>
<out-unicast-pkts>18850398</out-unicast-pkts>
</statistics>
</interface>
</interfaces-state>
</data></rpc-reply>

© 2018 Cisco and/or its affiliates. All rights reserved.


NETCONF vs Yang

© 2018 Cisco and/or its affiliates. All rights reserved.


RESTCONF
RESCONF Protocol
• RESTful like API to manage configuration and operational data “an HTTP-based
• RESTCONF is a REST-like protocol that provides a mechanism protocol that provides a
over HTTP for accessing data that is defined in NETCONF programmatic interface
datastores and modeled in YANG. for accessing data
• Uses HTTP(S) as transport defined in YANG…”
• Client-Server connection, stateless on the server side
• Uses XML or JSON for encoding https://tools.ietf.org/html/rf
• Common REST APIs methods:
c8040
• GET, POST, PUT, DELETE, PATCH

© 2018 Cisco and/or its affiliates. All rights reserved.


What about NETCONF?

© 2018 Cisco and/or its affiliates. All rights reserved.


RESTCONF Protocol Stack & Transport

© 2018 Cisco and/or its affiliates. All rights reserved.


Operations – HTTP CRUD (Create, Retrieve, Update,
and Delete)

RESTCONF NETCONF
GET <get> , <get-config>
POST <edit-config> (operation="create")
PUT <edit-config> (operation="create/replace")
PATCH <edit-config> (operation="merge")
DELETE <edit-config> (operation="delete")

© 2018 Cisco and/or its affiliates. All rights reserved.


RESTCONF Request

URL API Resource

url = 'https://RO_HOST/restconf/data/interfaces-state/interface=GigabitEthernet1'
Device
Headers
header = {'Content-type': 'application/yang-data+json',

'accept': 'application/yang-data+json'}
Method Authentication
response = requests.get(url, headers=header, verify=False, auth=ROUTER_AUTH)

interface_info = response.json() Parsing JSON


oper_data = interface_info['ietf-interfaces:interface']

© 2018 Cisco and/or its affiliates. All rights reserved.


RESTCONF Response
{
"ietf-interfaces:interface": {
"name": "GigabitEthernet1",
"admin-status": "up",
"oper-status": "up",
"last-change": "2018-01-17T21:49:17.000387+00:00",
"phys-address": "00:0c:29:6c:81:06",
"speed": 1024000000,
"statistics": {
"in-octets": 5425386232,
"in-unicast-pkts": 28489134,
……………
"out-octets": 2899535736,
"out-unicast-pkts": 18844784
}
}
}

© 2018 Cisco and/or its affiliates. All rights reserved.


Summary
Protocol Summary
NETCONF RESTCONF

Standardization RFC 6241 RFC 8040

Encoding XML XML / JSON

Session-layer Service
(RPC) Support ✓ ✓

Connection Oriented ✓ ✗

Session Security SSH HTTPS


© 2018 Cisco and/or its affiliates. All rights reserved.
Transport (Protocol) vs Data (Model)

• NETCONF • YANG
• RESTCONF

© 2018 Cisco and/or its affiliates. All rights reserved.

35
The Network As It Could Be…In a ‘Hybrid SDN’
A Controller is centralized and separated from the Physical Device, but devices still retain
localized Control plane intelligence.

© 2018 Cisco and/or its affiliates. All rights reserved.


Q&A

© 2018 Cisco and/or its affiliates. All rights reserved.

You might also like