SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Linux on
Network Switch
and Management
Hyung-Soo Kim - Tetration CSE - Cisco Systems, Inc
• Linux on Network Switches
• Introduction to NETCONF
• Introduction to RESTCONF
• Useful information
Agenda
Linux on Network
Switch
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Open NX-OS Linux
• Kernel 3.4
• 64bit Linux 3.4 kernel
• Kernel Stack
• Move from custom-built userspace stack(NetStack) to Native Linux Networking Stack
• Physical, port-channel, vPC, VLAN and logical interface mapped to Kernel
• VRF mapped to Linux namespace
• Open Package Management
• Support RPM & custom-developed software installation
• Container Support
• Centos 7 based LXC support named GuestShell
4
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Benefit from Linux Kernel Stack
• Linux utilities for interface management
• ifconfig, ip, ethtool
• Linux tools for troubleshooting
• Leverage tools like tcpdump, ping and traceroutes
• VRF capabilities with Namespace
• Same name from VRF creation mapped to Namespace
• Linux socket communication
• Custom-developed application use standard Linux socket
5
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
Architecture of Open NXOS
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Native Bash-Shell
7
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 8
VRF and Linux Namespace (1/2)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
VRF and Linux Namespace (2/2)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell
GUEST SHELL
Open Source
Packages
Apps
Apps
NX-OS CLI
Python
enabled
CentOS 7.0
rootfs
Secure Linux Container (sLXC)
N9K / N3K
DevOps
3rd Party
Apps
bootflash:
Apps
It’s an open Linux
environment, decoupled from
NX-OS.
64-bit CentOS 7.
Cisco
Packages
10
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Richly Populated Repositories for 3rd Party Apps
11
chvrf utility used to select
VRF ( i.e. network
namespace)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Install 3rd party package via YUM
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Linux Networking Is Possible From the Guest Shell
Only read access is allowed from the guest shell.
For write access (interface configuration)
1) use the native shell.
2) use dohost utility 13
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Use dohost utility
14
# dohost “CLI command for configuration “
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
The Guest Shell is Secure
• Namespaces are separate, resource usage is controlled, access is
controlled.
• No visibility into Cisco proprietary software (cannot read, write, or
execute NX-OS binaries).
• No visibility into Cisco proprietary disk partitions.
• No access to internal, Cisco proprietary drivers.
• No ability to load kernel drivers.
15
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
CLI
L2 L3 Interfaces Platform Etc
Nexus 9K
Your Custom Applications
(Python, C++ etc.)
Existing 3rd Party
Linux Applications
Linux - Guest Shell
NX-OS
Linux Networking
Stack
Linux Apps Can Interact With the External World
16
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell Use Cases
• Monitoring
• 3rd party tools: OpenTSDB,
Ganglia, Nagios, etc.
Monitoring both standard Linux
items (CPU, memory, interface
counters) and NX-OS (buffers,
routes...)
• Custom-made (example: PTP
monitoring of a specific offset
threshold, Grandmaster
change)
• Extensibility
• IDS
• DNSFlow
• Managability
• Chef / Puppet Agents
• Automatic config backup to Git
• Use the switch as a PXE server
• Troubleshooting
• Tcpdump
17
Introduction to
Standard Device
Interfaces
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
The Network is No Longer Isolated
19
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
What about SNMP?
SNMP works
“reasonably well for
device monitoring”
RFC 3535: Overview of the 2002 IAB Network
Management Workshop – 2003
https://tools.ietf.org/html/rfc3535
• Typical config: SNMPv2 read-only
community strings
• Typical usage: interface statistics
queries and traps
• Empirical Observation: SNMP is not
used for configuration
• Lack of Writeable MIBs
• Security Concerns
• Difficult to Replay/Rollback
• Special Applications
20
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
21
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
NETCONF / YANG (RESTCONF & gRPC)
• NETCONF – 2006 – RFC 4741
(RFC 6241 in 2011)
• YANG – 2010 – RFC 6020
• RESTCONF – 2017 – RFC 8040
• gRPC – 2015 – OpenSource project
by Google
22
Introduction to
YANG Data
Models
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Three Meanings of “YANG”
• YANG Modeling Language
• YANG Data Models
• YANG Device Data
24
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Where do Models Come From?
• Standard definition
(IETF, ITU, OpenConfig, etc.)
• Compliant with standard
ietf-diffserv-policy.yang
ietf-diffserv-classifer.yang
ietf-diffserv-target.yang
• Vendor definition
(i.e. Cisco)
• Unique to Vendor Platforms
cisco-memory-stats.yang
cisco-flow-monitor
cisco-qos-action-qlimit-cfg
Industry
Standard
Vendor
Specific
https://github.com/YangModels/yang
25
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
pyang Output Review
Example edited for simplicity and brevity
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--rw link-up-down-trap-enable? enumeration {if-mib}?
+--ro interfaces-state
+--ro interface* [name]
+--ro name string
+--ro type identityref
+--ro admin-status enumeration {if-mib}?
+--ro oper-status enumeration
+--ro last-change? yang:date-and-time
+--ro if-index int32 {if-mib}?
+--ro phys-address? yang:phys-address
+--ro higher-layer-if* interface-state-ref
+--ro lower-layer-if* interface-state-ref
+--ro speed? yang:gauge64
+--ro statistics
+--ro discontinuity-time yang:date-and-time
+--ro in-octets? yang:counter64
[OUTPUT REMOVED]
Module Name
Example edited for simplicity and brevity
Leaf
Data Type
containercontainer
list
list
Key
26
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
XML Output Review
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
<name>GigabitEthernet1</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
<enabled>true</enabled>
<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
<address>
<ip>198.18.133.212</ip>
<netmask>255.255.192.0</netmask>
</address>
</ipv4>
<ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"/>
</interface>
<interface>
<name>GigabitEthernet3</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
<enabled>false</enabled>
<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"/>
<ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"/>
</interface>
</interfaces>
Example edited for simplicity and brevity
interfacescontainer
interfacenode
Leaf
Namespace = Capability = Model
27
Introduction to
NETCONF
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Introducing the NETCONF Protocol
Some key details:
• Initial standard in 2006
with RFC4741
• Latest standard is RFC6241 in 2011
• Does NOT explicitly define content
29
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
NETCONF Protocol Stack
30
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
31
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
NETCONF Data Stores
result = m.get_config('running', hostname_filter)
Data Store Key Points
• Entire or partial configuration
• "running" is the only mandatory data store
• Not all data stores are writeable
• A "URL" data store is supported by IOS to
enable <config-copy>
• Every NETCONF message must target a
data store
32
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Code Review – Part 1
#!/usr/bin/env python
from ncclient import manager
from pprint import pprint
import xmltodict
import xml.dom.minidom
HOST = ’devent.foobar.com'
PORT = 10000
USER = ’Eddie'
PASS = ‘G30rg3'
Import libraries
Set Variables
33
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Code Review – Part 2
m = manager.connect(host=HOST, port=PORT, username=USER,
password=PASS, hostkey_verify=False,
device_params={'name': 'default'},
allow_agent=False, look_for_keys=False)
Connect and say
hello
34
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Code Review – Part 3
hostname_filter = '''
<filter>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname></hostname>
<version></version>
</native>
</filter>
''’
netconf_reply = m.get_config('running', hostname_filter)
Filter the data
in the
response from
get-config
Issue a ‘get-config’ in open NETCONF session
35
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Code Review – Part 3b (Read in Filter from File)
hostname_filter = open("hostname_filter.xml").read()
netconf_reply = m.get_config('running', hostname_filter)
Opens file named ‘hostname_filter.xml and reads it
into the script
Issue a ‘get-config’ in open NETCONF session
<filter>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname></hostname>
<version></version>
</native>
</filter>
Contents of hostname_filter.xml
36
ALTERNATIVE TO PREVIOUS SLIDE
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Code Review – Part 4
print(xml.dom.minidom.parseString(netconf_reply.xml).toprettyxml())
netconf_payload = xmltodict.parse(netconf_reply.xml)
hostname = netconf_payload["rpc-reply"]["data"]["native"]["hostname"]
version = netconf_payload["rpc-reply"]["data"]["native"]["version"]
pprint("Router Hostname is: " + hostname)
pprint("Router Version is: " + version)
Print out raw XML from NETCONF reply
Print out hostname and version
Parse XML payload and convert to dictionary
Retrieve the hostname and version
from XML payload
37
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Code Review – Part 5
m.close_session() Don’t forget to close the session!
38
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Output Review
<?xml version="1.0" ?>
<rpc-reply message-id="urn:uuid:6e37f322-8537-4df3-ae4f-449a830a7ea1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<data>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<version>16.5</version>
<hostname>csr1000v</hostname>
</native>
</data>
</rpc-reply>
Identify output as XML
rpcmessage
datablock
nativecontainer
Leaf
Namespace = Capability = Model
XML Output
Print Output
'Router Hostname is: csr1000v'
'Router Version is: 16.5'
39
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 40
How to get NETCONF content (1/3) ?
# CLI show-command | xml
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 41
How to get NETCONF content (1/3)
# prepare for configuration cli command
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 42
How to get NETCONF content (3/3) ?
# command for changing name of this switch
# payload of netconf
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
NETCONF Review
43
Introduction to
RESTCONF
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
RESTCONF Details
• https://tools.ietf.org/html/rfc8040
“an HTTP-based protocol
that provides a programmatic
interface for accessing data
defined in YANG…”
• RFC 8040 - January 2017
• Uses HTTP(S) for transport
• Tightly coupled to the YANG data model
definitions
• Provides JSON or XML data formats
45
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
What about NETCONF?
46
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
RESTCONF Protocol Stack & Transport
47
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Operations - HTTP CRUD
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")
48
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Content - XML or JSON
HTTP Headers
• Content-Type: Specify the type of
data being sent from the client
• Accept: Specify the type of data
being requested by the client
RESTCONF MIME Types
• application/vnd.yang.data+json
• application/vnd.yang.data+xml
49
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Constructing RESTCONF URIs
• ADDRESS - Of the RESTCONF Agent
• ROOT - The main entry point for RESTCONF requests.
• DATA STORE - The data store being queried
• [YANG MODULE:]CONTAINER - The base model container being used
• LEAF - An individual element from within the container
• [?<OPTIONS>] - optional parameters that impact returned results.
https://<ADDRESS>/<ROOT>/<DATA STORE>/<[YANG MODULE:]CONTAINER>/<LEAF>[?<OPTIONS>]
50
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
URL Creation Review
http://192.168.27.218:8008/api/running/interfaces/interface/GigabitEthernet2?deep
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--rw link-up-down-trap-enable? enumeration {if-mib}?
Example edited for simplicity and brevity
Key:
https://<ADDRESS>/<ROOT>/<DATA STORE>/<[YANG MODULE:]CONTAINER>/<LEAF>[?<OPTIONS>]
51
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
curl command Review
$ curl -u admin:C1sco12345 
-H "Accept: application/vnd.yang.data+json" 
http://198.18.133.218:8008/api/running/interfaces/interface/GigabitEthernet2?deep URL
Example edited for simplicity and brevity
Authentication
Header to specify JSON
52
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
curl output Review
{
"ietf-interfaces:interface": {
"name": "GigabitEthernet1",
"type": "ianaift:ethernetCsmacd",
"enabled": true,
"cisco-ethernet:ethernet": {
},
"cisco-pw:pw-neighbor": {
"load-balance": {
}
},
"ietf-ip:ipv4": {
"address": [
{
"ip": "198.18.133.212",
"netmask": "255.255.192.0"
}
]
},
"ietf-ip:ipv6": {
"ietf-ipv6-unicast-routing:ipv6-router-advertisements": {
}
}
}
}
Example edited for simplicity and brevity
Leaf
interface
ipv4
list
53
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Postman Client Review
METHODS URL
Authentication
Returned Data
HTTP Status Code
Set Headers
54
Useful
Information
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Where to get information
• Cisco DevNet
• https://developer.cisco.com
• Open NXOS SDK
• https://github.com/CiscoDevNet/NX-SDK
• Open NXOS Sandbox
• https://devnetsandbox.cisco.com
• NX-OSv 9000 Guide
• https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/7-x/nx-
osv/configuration/guide/b_NX-OSv_9000/b_NX-OSv_chapter_01.html
• NX-API Developer Sandbox
• https://open-nxos-ip/
56
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7
Etsuji Nakai
 
John_Ting_Resume
John_Ting_ResumeJohn_Ting_Resume
John_Ting_Resume
John Ting
 

Was ist angesagt? (20)

Embedded Linux/ Debian with ARM64 Platform
Embedded Linux/ Debian with ARM64 PlatformEmbedded Linux/ Debian with ARM64 Platform
Embedded Linux/ Debian with ARM64 Platform
 
Fast boot
Fast bootFast boot
Fast boot
 
Intel® RDT Hands-on Lab
Intel® RDT Hands-on LabIntel® RDT Hands-on Lab
Intel® RDT Hands-on Lab
 
Long-term Maintenance Model of Embedded Industrial Linux Distribution
Long-term Maintenance Model of Embedded Industrial Linux DistributionLong-term Maintenance Model of Embedded Industrial Linux Distribution
Long-term Maintenance Model of Embedded Industrial Linux Distribution
 
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
 
Using open source software to build an industrial grade embedded linux platfo...
Using open source software to build an industrial grade embedded linux platfo...Using open source software to build an industrial grade embedded linux platfo...
Using open source software to build an industrial grade embedded linux platfo...
 
Design, Build,and Maintain the Embedded Linux Platform
Design, Build,and Maintain the Embedded Linux PlatformDesign, Build,and Maintain the Embedded Linux Platform
Design, Build,and Maintain the Embedded Linux Platform
 
Status of Embedded Linux
Status of Embedded LinuxStatus of Embedded Linux
Status of Embedded Linux
 
[若渴計畫] Black Hat 2017之過去閱讀相關整理
[若渴計畫] Black Hat 2017之過去閱讀相關整理[若渴計畫] Black Hat 2017之過去閱讀相關整理
[若渴計畫] Black Hat 2017之過去閱讀相關整理
 
"One network to rule them all" - OpenStack Summit Austin 2016
"One network to rule them all" - OpenStack Summit Austin 2016"One network to rule them all" - OpenStack Summit Austin 2016
"One network to rule them all" - OpenStack Summit Austin 2016
 
Linux firmware for iRMC controller on Fujitsu Primergy servers
Linux firmware for iRMC controller on Fujitsu Primergy serversLinux firmware for iRMC controller on Fujitsu Primergy servers
Linux firmware for iRMC controller on Fujitsu Primergy servers
 
Building, deploying and testing an industrial linux platform @ Open source su...
Building, deploying and testing an industrial linux platform @ Open source su...Building, deploying and testing an industrial linux platform @ Open source su...
Building, deploying and testing an industrial linux platform @ Open source su...
 
XPDS14: Efficient Interdomain Transmission of Performance Data - John Else, C...
XPDS14: Efficient Interdomain Transmission of Performance Data - John Else, C...XPDS14: Efficient Interdomain Transmission of Performance Data - John Else, C...
XPDS14: Efficient Interdomain Transmission of Performance Data - John Else, C...
 
LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...
LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...
LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...
 
Select, manage, and backport the long term stable kernels
Select, manage, and backport the long term stable kernelsSelect, manage, and backport the long term stable kernels
Select, manage, and backport the long term stable kernels
 
LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013
 
Control Your Network ASICs, What Benefits switchdev Can Bring Us
Control Your Network ASICs, What Benefits switchdev Can Bring UsControl Your Network ASICs, What Benefits switchdev Can Bring Us
Control Your Network ASICs, What Benefits switchdev Can Bring Us
 
How Linux Processes Your Network Packet - Elazar Leibovich
How Linux Processes Your Network Packet - Elazar LeibovichHow Linux Processes Your Network Packet - Elazar Leibovich
How Linux Processes Your Network Packet - Elazar Leibovich
 
Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7
 
John_Ting_Resume
John_Ting_ResumeJohn_Ting_Resume
John_Ting_Resume
 

Ähnlich wie Devicemgmt

BRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdfBRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdf
Heng30
 

Ähnlich wie Devicemgmt (20)

SDN and metrics from the SDOs
SDN and metrics from the SDOsSDN and metrics from the SDOs
SDN and metrics from the SDOs
 
OpenStack with OpenDaylight
OpenStack with OpenDaylightOpenStack with OpenDaylight
OpenStack with OpenDaylight
 
LSA2 - 02 Namespaces
LSA2 - 02  NamespacesLSA2 - 02  Namespaces
LSA2 - 02 Namespaces
 
PLNOG19 - Krzysztof Mazepa - Yang Development Kit – stwórz swój pierwszy prog...
PLNOG19 - Krzysztof Mazepa - Yang Development Kit – stwórz swój pierwszy prog...PLNOG19 - Krzysztof Mazepa - Yang Development Kit – stwórz swój pierwszy prog...
PLNOG19 - Krzysztof Mazepa - Yang Development Kit – stwórz swój pierwszy prog...
 
Linux io introduction-fudcon-2015-with-demo-slides
Linux io introduction-fudcon-2015-with-demo-slidesLinux io introduction-fudcon-2015-with-demo-slides
Linux io introduction-fudcon-2015-with-demo-slides
 
Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)
Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)
Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)
 
Using VPP and SRIO-V with Clear Containers
Using VPP and SRIO-V with Clear ContainersUsing VPP and SRIO-V with Clear Containers
Using VPP and SRIO-V with Clear Containers
 
Triangle Kubernetes Meetup: Container cloud networking - Contiv for K8S & Ope...
Triangle Kubernetes Meetup: Container cloud networking - Contiv for K8S & Ope...Triangle Kubernetes Meetup: Container cloud networking - Contiv for K8S & Ope...
Triangle Kubernetes Meetup: Container cloud networking - Contiv for K8S & Ope...
 
BRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdfBRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdf
 
Architecture of Cisco Container Platform: A new Enterprise Multi-Cloud Kubern...
Architecture of Cisco Container Platform: A new Enterprise Multi-Cloud Kubern...Architecture of Cisco Container Platform: A new Enterprise Multi-Cloud Kubern...
Architecture of Cisco Container Platform: A new Enterprise Multi-Cloud Kubern...
 
CCNA2 Verson6 Chapter10
CCNA2 Verson6 Chapter10CCNA2 Verson6 Chapter10
CCNA2 Verson6 Chapter10
 
CCNA (R & S) Module 03 - Routing & Switching Essentials - Chapter 10
CCNA (R & S) Module 03 - Routing & Switching Essentials - Chapter 10CCNA (R & S) Module 03 - Routing & Switching Essentials - Chapter 10
CCNA (R & S) Module 03 - Routing & Switching Essentials - Chapter 10
 
eBPF Basics
eBPF BasicseBPF Basics
eBPF Basics
 
Microservices and containers networking: Contiv, an industry leading open sou...
Microservices and containers networking: Contiv, an industry leading open sou...Microservices and containers networking: Contiv, an industry leading open sou...
Microservices and containers networking: Contiv, an industry leading open sou...
 
PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...
PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...
PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...
 
[발표자료] 오픈소스 Pacemaker 활용한 zabbix 이중화 방안(w/ Zabbix Korea Community)
[발표자료] 오픈소스 Pacemaker 활용한 zabbix 이중화 방안(w/ Zabbix Korea Community) [발표자료] 오픈소스 Pacemaker 활용한 zabbix 이중화 방안(w/ Zabbix Korea Community)
[발표자료] 오픈소스 Pacemaker 활용한 zabbix 이중화 방안(w/ Zabbix Korea Community)
 
RISC V in Spacer
RISC V in SpacerRISC V in Spacer
RISC V in Spacer
 
Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-review
 
Cisco's Open Device Programmability Strategy: Open Discussion
Cisco's Open Device Programmability Strategy: Open DiscussionCisco's Open Device Programmability Strategy: Open Discussion
Cisco's Open Device Programmability Strategy: Open Discussion
 
OFI Overview 2019 Webinar
OFI Overview 2019 WebinarOFI Overview 2019 Webinar
OFI Overview 2019 Webinar
 

Mehr von xyxz

Mehr von xyxz (20)

Optimal reception-of-digital-signals
Optimal reception-of-digital-signalsOptimal reception-of-digital-signals
Optimal reception-of-digital-signals
 
Optimal reception-of-digital-signals-2
Optimal reception-of-digital-signals-2Optimal reception-of-digital-signals-2
Optimal reception-of-digital-signals-2
 
Optimal reception-of-digital-signals
Optimal reception-of-digital-signalsOptimal reception-of-digital-signals
Optimal reception-of-digital-signals
 
Complex propagation
Complex propagationComplex propagation
Complex propagation
 
Digital class
Digital classDigital class
Digital class
 
New ways of teaching entrepreneurship
New ways of teaching entrepreneurshipNew ways of teaching entrepreneurship
New ways of teaching entrepreneurship
 
Bits and bandwidth
Bits and bandwidthBits and bandwidth
Bits and bandwidth
 
Io t system management with
Io t system management withIo t system management with
Io t system management with
 
Mpmc unit-string manipulation
Mpmc unit-string manipulationMpmc unit-string manipulation
Mpmc unit-string manipulation
 
Lp iot-iv-ece- 2019-20
Lp iot-iv-ece- 2019-20Lp iot-iv-ece- 2019-20
Lp iot-iv-ece- 2019-20
 
Jntuh b.tech 3 year ece r16 syllabus
Jntuh b.tech 3 year ece r16 syllabusJntuh b.tech 3 year ece r16 syllabus
Jntuh b.tech 3 year ece r16 syllabus
 
29fe586301a42c2d2e7279d658da178ae1e6
29fe586301a42c2d2e7279d658da178ae1e629fe586301a42c2d2e7279d658da178ae1e6
29fe586301a42c2d2e7279d658da178ae1e6
 
Lecture notes front page sample (1) copy
Lecture notes front page sample (1)   copyLecture notes front page sample (1)   copy
Lecture notes front page sample (1) copy
 
Jntua ece 3rd &amp; 4th year (r15) syllabus (1) split-merge-1-4-1-2
Jntua ece 3rd &amp; 4th year (r15) syllabus (1) split-merge-1-4-1-2Jntua ece 3rd &amp; 4th year (r15) syllabus (1) split-merge-1-4-1-2
Jntua ece 3rd &amp; 4th year (r15) syllabus (1) split-merge-1-4-1-2
 
Ilovepdf merged
Ilovepdf mergedIlovepdf merged
Ilovepdf merged
 
Dc lab manual
Dc lab manualDc lab manual
Dc lab manual
 
Adc lab
Adc labAdc lab
Adc lab
 
Dcs lesson plan 18 19
Dcs lesson plan 18 19Dcs lesson plan 18 19
Dcs lesson plan 18 19
 
04 sequential circuits
04 sequential circuits04 sequential circuits
04 sequential circuits
 
507 block 1_lesson_1
507 block 1_lesson_1507 block 1_lesson_1
507 block 1_lesson_1
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Devicemgmt

  • 1. Linux on Network Switch and Management Hyung-Soo Kim - Tetration CSE - Cisco Systems, Inc
  • 2. • Linux on Network Switches • Introduction to NETCONF • Introduction to RESTCONF • Useful information Agenda
  • 4. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Open NX-OS Linux • Kernel 3.4 • 64bit Linux 3.4 kernel • Kernel Stack • Move from custom-built userspace stack(NetStack) to Native Linux Networking Stack • Physical, port-channel, vPC, VLAN and logical interface mapped to Kernel • VRF mapped to Linux namespace • Open Package Management • Support RPM & custom-developed software installation • Container Support • Centos 7 based LXC support named GuestShell 4
  • 5. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Benefit from Linux Kernel Stack • Linux utilities for interface management • ifconfig, ip, ethtool • Linux tools for troubleshooting • Leverage tools like tcpdump, ping and traceroutes • VRF capabilities with Namespace • Same name from VRF creation mapped to Namespace • Linux socket communication • Custom-developed application use standard Linux socket 5
  • 6. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 6 Architecture of Open NXOS
  • 7. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Native Bash-Shell 7
  • 8. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 8 VRF and Linux Namespace (1/2)
  • 9. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 9 VRF and Linux Namespace (2/2)
  • 10. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Guest Shell GUEST SHELL Open Source Packages Apps Apps NX-OS CLI Python enabled CentOS 7.0 rootfs Secure Linux Container (sLXC) N9K / N3K DevOps 3rd Party Apps bootflash: Apps It’s an open Linux environment, decoupled from NX-OS. 64-bit CentOS 7. Cisco Packages 10
  • 11. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Richly Populated Repositories for 3rd Party Apps 11 chvrf utility used to select VRF ( i.e. network namespace)
  • 12. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 12 Install 3rd party package via YUM
  • 13. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Linux Networking Is Possible From the Guest Shell Only read access is allowed from the guest shell. For write access (interface configuration) 1) use the native shell. 2) use dohost utility 13
  • 14. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Use dohost utility 14 # dohost “CLI command for configuration “
  • 15. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public The Guest Shell is Secure • Namespaces are separate, resource usage is controlled, access is controlled. • No visibility into Cisco proprietary software (cannot read, write, or execute NX-OS binaries). • No visibility into Cisco proprietary disk partitions. • No access to internal, Cisco proprietary drivers. • No ability to load kernel drivers. 15
  • 16. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public CLI L2 L3 Interfaces Platform Etc Nexus 9K Your Custom Applications (Python, C++ etc.) Existing 3rd Party Linux Applications Linux - Guest Shell NX-OS Linux Networking Stack Linux Apps Can Interact With the External World 16
  • 17. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Guest Shell Use Cases • Monitoring • 3rd party tools: OpenTSDB, Ganglia, Nagios, etc. Monitoring both standard Linux items (CPU, memory, interface counters) and NX-OS (buffers, routes...) • Custom-made (example: PTP monitoring of a specific offset threshold, Grandmaster change) • Extensibility • IDS • DNSFlow • Managability • Chef / Puppet Agents • Automatic config backup to Git • Use the switch as a PXE server • Troubleshooting • Tcpdump 17
  • 19. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public The Network is No Longer Isolated 19
  • 20. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public What about SNMP? SNMP works “reasonably well for device monitoring” RFC 3535: Overview of the 2002 IAB Network Management Workshop – 2003 https://tools.ietf.org/html/rfc3535 • Typical config: SNMPv2 read-only community strings • Typical usage: interface statistics queries and traps • Empirical Observation: SNMP is not used for configuration • Lack of Writeable MIBs • Security Concerns • Difficult to Replay/Rollback • Special Applications 20
  • 21. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 21
  • 22. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public NETCONF / YANG (RESTCONF & gRPC) • NETCONF – 2006 – RFC 4741 (RFC 6241 in 2011) • YANG – 2010 – RFC 6020 • RESTCONF – 2017 – RFC 8040 • gRPC – 2015 – OpenSource project by Google 22
  • 24. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Three Meanings of “YANG” • YANG Modeling Language • YANG Data Models • YANG Device Data 24
  • 25. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Where do Models Come From? • Standard definition (IETF, ITU, OpenConfig, etc.) • Compliant with standard ietf-diffserv-policy.yang ietf-diffserv-classifer.yang ietf-diffserv-target.yang • Vendor definition (i.e. Cisco) • Unique to Vendor Platforms cisco-memory-stats.yang cisco-flow-monitor cisco-qos-action-qlimit-cfg Industry Standard Vendor Specific https://github.com/YangModels/yang 25
  • 26. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public pyang Output Review Example edited for simplicity and brevity module: ietf-interfaces +--rw interfaces | +--rw interface* [name] | +--rw name string | +--rw description? string | +--rw type identityref | +--rw enabled? boolean | +--rw link-up-down-trap-enable? enumeration {if-mib}? +--ro interfaces-state +--ro interface* [name] +--ro name string +--ro type identityref +--ro admin-status enumeration {if-mib}? +--ro oper-status enumeration +--ro last-change? yang:date-and-time +--ro if-index int32 {if-mib}? +--ro phys-address? yang:phys-address +--ro higher-layer-if* interface-state-ref +--ro lower-layer-if* interface-state-ref +--ro speed? yang:gauge64 +--ro statistics +--ro discontinuity-time yang:date-and-time +--ro in-octets? yang:counter64 [OUTPUT REMOVED] Module Name Example edited for simplicity and brevity Leaf Data Type containercontainer list list Key 26
  • 27. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public XML Output Review <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface> <name>GigabitEthernet1</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <enabled>true</enabled> <ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"> <address> <ip>198.18.133.212</ip> <netmask>255.255.192.0</netmask> </address> </ipv4> <ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"/> </interface> <interface> <name>GigabitEthernet3</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <enabled>false</enabled> <ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"/> <ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"/> </interface> </interfaces> Example edited for simplicity and brevity interfacescontainer interfacenode Leaf Namespace = Capability = Model 27
  • 29. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Introducing the NETCONF Protocol Some key details: • Initial standard in 2006 with RFC4741 • Latest standard is RFC6241 in 2011 • Does NOT explicitly define content 29
  • 30. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public NETCONF Protocol Stack 30
  • 31. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 31
  • 32. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public NETCONF Data Stores result = m.get_config('running', hostname_filter) Data Store Key Points • Entire or partial configuration • "running" is the only mandatory data store • Not all data stores are writeable • A "URL" data store is supported by IOS to enable <config-copy> • Every NETCONF message must target a data store 32
  • 33. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Code Review – Part 1 #!/usr/bin/env python from ncclient import manager from pprint import pprint import xmltodict import xml.dom.minidom HOST = ’devent.foobar.com' PORT = 10000 USER = ’Eddie' PASS = ‘G30rg3' Import libraries Set Variables 33
  • 34. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Code Review – Part 2 m = manager.connect(host=HOST, port=PORT, username=USER, password=PASS, hostkey_verify=False, device_params={'name': 'default'}, allow_agent=False, look_for_keys=False) Connect and say hello 34
  • 35. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Code Review – Part 3 hostname_filter = ''' <filter> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <hostname></hostname> <version></version> </native> </filter> ''’ netconf_reply = m.get_config('running', hostname_filter) Filter the data in the response from get-config Issue a ‘get-config’ in open NETCONF session 35
  • 36. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Code Review – Part 3b (Read in Filter from File) hostname_filter = open("hostname_filter.xml").read() netconf_reply = m.get_config('running', hostname_filter) Opens file named ‘hostname_filter.xml and reads it into the script Issue a ‘get-config’ in open NETCONF session <filter> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <hostname></hostname> <version></version> </native> </filter> Contents of hostname_filter.xml 36 ALTERNATIVE TO PREVIOUS SLIDE
  • 37. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Code Review – Part 4 print(xml.dom.minidom.parseString(netconf_reply.xml).toprettyxml()) netconf_payload = xmltodict.parse(netconf_reply.xml) hostname = netconf_payload["rpc-reply"]["data"]["native"]["hostname"] version = netconf_payload["rpc-reply"]["data"]["native"]["version"] pprint("Router Hostname is: " + hostname) pprint("Router Version is: " + version) Print out raw XML from NETCONF reply Print out hostname and version Parse XML payload and convert to dictionary Retrieve the hostname and version from XML payload 37
  • 38. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Code Review – Part 5 m.close_session() Don’t forget to close the session! 38
  • 39. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Output Review <?xml version="1.0" ?> <rpc-reply message-id="urn:uuid:6e37f322-8537-4df3-ae4f-449a830a7ea1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"> <data> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <version>16.5</version> <hostname>csr1000v</hostname> </native> </data> </rpc-reply> Identify output as XML rpcmessage datablock nativecontainer Leaf Namespace = Capability = Model XML Output Print Output 'Router Hostname is: csr1000v' 'Router Version is: 16.5' 39
  • 40. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 40 How to get NETCONF content (1/3) ? # CLI show-command | xml
  • 41. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 41 How to get NETCONF content (1/3) # prepare for configuration cli command
  • 42. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 42 How to get NETCONF content (3/3) ? # command for changing name of this switch # payload of netconf
  • 43. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public NETCONF Review 43
  • 45. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public RESTCONF Details • https://tools.ietf.org/html/rfc8040 “an HTTP-based protocol that provides a programmatic interface for accessing data defined in YANG…” • RFC 8040 - January 2017 • Uses HTTP(S) for transport • Tightly coupled to the YANG data model definitions • Provides JSON or XML data formats 45
  • 46. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public What about NETCONF? 46
  • 47. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public RESTCONF Protocol Stack & Transport 47
  • 48. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Operations - HTTP CRUD 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") 48
  • 49. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Content - XML or JSON HTTP Headers • Content-Type: Specify the type of data being sent from the client • Accept: Specify the type of data being requested by the client RESTCONF MIME Types • application/vnd.yang.data+json • application/vnd.yang.data+xml 49
  • 50. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Constructing RESTCONF URIs • ADDRESS - Of the RESTCONF Agent • ROOT - The main entry point for RESTCONF requests. • DATA STORE - The data store being queried • [YANG MODULE:]CONTAINER - The base model container being used • LEAF - An individual element from within the container • [?<OPTIONS>] - optional parameters that impact returned results. https://<ADDRESS>/<ROOT>/<DATA STORE>/<[YANG MODULE:]CONTAINER>/<LEAF>[?<OPTIONS>] 50
  • 51. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public URL Creation Review http://192.168.27.218:8008/api/running/interfaces/interface/GigabitEthernet2?deep module: ietf-interfaces +--rw interfaces | +--rw interface* [name] | +--rw name string | +--rw description? string | +--rw type identityref | +--rw enabled? boolean | +--rw link-up-down-trap-enable? enumeration {if-mib}? Example edited for simplicity and brevity Key: https://<ADDRESS>/<ROOT>/<DATA STORE>/<[YANG MODULE:]CONTAINER>/<LEAF>[?<OPTIONS>] 51
  • 52. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public curl command Review $ curl -u admin:C1sco12345 -H "Accept: application/vnd.yang.data+json" http://198.18.133.218:8008/api/running/interfaces/interface/GigabitEthernet2?deep URL Example edited for simplicity and brevity Authentication Header to specify JSON 52
  • 53. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public curl output Review { "ietf-interfaces:interface": { "name": "GigabitEthernet1", "type": "ianaift:ethernetCsmacd", "enabled": true, "cisco-ethernet:ethernet": { }, "cisco-pw:pw-neighbor": { "load-balance": { } }, "ietf-ip:ipv4": { "address": [ { "ip": "198.18.133.212", "netmask": "255.255.192.0" } ] }, "ietf-ip:ipv6": { "ietf-ipv6-unicast-routing:ipv6-router-advertisements": { } } } } Example edited for simplicity and brevity Leaf interface ipv4 list 53
  • 54. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Postman Client Review METHODS URL Authentication Returned Data HTTP Status Code Set Headers 54
  • 56. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Where to get information • Cisco DevNet • https://developer.cisco.com • Open NXOS SDK • https://github.com/CiscoDevNet/NX-SDK • Open NXOS Sandbox • https://devnetsandbox.cisco.com • NX-OSv 9000 Guide • https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/7-x/nx- osv/configuration/guide/b_NX-OSv_9000/b_NX-OSv_chapter_01.html • NX-API Developer Sandbox • https://open-nxos-ip/ 56

Hinweis der Redaktion

  1. Our philosophy: it’s your switch, you bought it, you should be able to do whatever you want with it. Extend its capabilities via Linux.
  2. Linux is foundation of Nexus 9K. NX-OS is actually a set of Linux process running on top of the Linux kernel. We provide access to Linux on N9K via the Guest Shell. It’s a container that is running CentOS 7. It’s decoupled from NX-OS.
  3. This is how to enter the Guest Shell. From there, there’s no difference with a container running on a Linux server. We chose CentOS 7 distribution because it’s widely deployed. So there’s a lot of Linux packages already. Here can see that the default yum repositories are in place. It gives us 9000 packages available by default.
  4. This means we can support any 3rd party application which relies on networking data from Linux. … Read access only for security reasons. For write access, use the native shell. It’s not a container, it’s a shell of the actual Linux that runs the switch. Unless you really need to, we recommend that you don’t use the native shell and use the guest shell instead, for security reasons.
  5. Safe environment: Namespace separation, resource usage is controlled, access is controlled No visibility into Cisco proprietary software (cannot read, write, or execute NXOS binaries). This is of no value to an application developer unless he has access to Cisco proprietary code base. No visibility into Cisco proprietary disk partitions. No ability to view, start and stop Cisco proprietary processes. This is of no value an application developer. Cisco software may have complex interdependencies that can change from release to release. No access to internal, Cisco proprietary drivers. This is of no value to application developer unless he has access to Cisco source code and understands software interdependencies. No ability to load kernel drivers. Kernel drivers are highly dependent on Kernel version of a specific release. For Linux user space application development, there is no need to export this capability.
  6. 3rd party monitoring is especially useful when it’s monitoring the servers as well.
  7. Network Engineers leveraging CLI are no longer the only parties and methods interested in configuring and monitoring the network.  DevOps as an approach to development and operations has proven successful for many organizations, and these teams are quickly looking at how they can expand their reach into the network.  New Web Applications leveraging Micro-Service architectures are building overlay container networks, but as the model matures, these applications look to integration with the underlying network for performance and segmentation.  And the "Cloud" is no longer a destination, but rather a complete approach to delivering IT Services and Applications. This approach demands fully programmatic (ie through APIs) access to services. Consumers aren't interested in individual devices and feature configuraiton, but rather the capabilites that the network can provide.
  8. Needing an alternative to CLI for configuration and management isn't a new requirement. SNMPv1 was originally proposed in 1988 (RFC 1098 in 1990 when it was just called SNMP). It was designed to provide a standard interface for network management systems to configure and retrieve monitoring information.  Over time SNMP has been updated several times bringing in SNMPv2 and SNMPv3. These updates targeted increasing performance and security among other topics. However...
  9. Working groups within the IETF approached the need for a new standard programmatic interface for Network Configuration. This isn't to say that individual vendors haven't worked to address the need individually. Many vendors, including Cisco, saw the need and began offering new APIs leveraging interfaces models such as:  - SOAP - REST - JSON-RPC - XML However, most customers, partners, software developers, and even vendors agree that having a Standard Device Interface approach is better than disparate proprietary ones. This isn't a new concept in networking, that's how many of the most widely adopted technologies began.
  10. Building on RFC 3535, the IETF developed NETCONF and YANG to offer a standard protocol and data modeling language for programmatic network management.  NETCONF was originally proposed in RFC 4741 in 2006, and YANG in RFC 6020 in 2010. Both are new technologies that continue to evolve and gain acceptance from customers and vendors.  While the NETCONF protocol provides a programmatic interface tackling many of the challenges of SNMP, as developers have begun leveraging it there has been interest in providing interface options that align closer with REST APIs and other programmatic standards. RESTCONF and gRPC are alternative protocols to NETCONF that look to address some of these goals.  RESTCONF achieved standardization in January 2017 with RFC 8040.  gRPC is an OpenSource project begun by Google to provide a modern RPC framework that can be used in any environment for multiple purposes, not just network configuration. Details can be found at grpc.io.  Though all the technologies are rapidly being adopted by many vendors and organizations, NETCONF and YANG are the most widely available Standard Interfaces on networking devices today, and having a solid understanding of their use and implementation is the best place to start.  And that will be the focus of this module.
  11. Wait... I'm sure you're asking yourself, "Who writes YANG Models?". Well that is a great question. Technically anyone can write a YANG Model, all it takes is an idea and a knowledge of the YANG Language. However for practical purposed, the most used models come from one of two places. Debating the pros and cons of individual models, and the different sources is beyond the scope of this presentation ;-)
  12. Some things to note about the output The "module" ietf-interfaces provides two "containers" interfaces interfaces-state Within each "container" is a "list" called "interface" A single instance of an interface is identified by a unique "key" of [name] Every "leaf" attribute (ex name, description, type, etc) has the following details Either read-write (rw) or read-only (ro) Some are optional (?) Explicitly defined data types
  13. In the next section we will dive deeper into NETCONF and how to make requests and process data leveraging the Python libraries ncclient and xml. For now know that this script has made a request for the list of interfaces using the ietf-interfaces model that we explored previously.  You should recognize the YANG Model elements represented:  container interfaces  <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">...</interfaces> The attribute xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"identifies the particular YANG Model list of individual interfaces <interface>..</interface> leaf attributes <name>..</name> <type>..</type>> <enabled>..</enabled
  14. NETCONF is the primary transport protocol used with YANG data models today. It is the NETwork CONFiguration protocol, and defines how a Manager and Agent will communicate in a standard fashion.  Some key details: Initially standardized in 2006 with RFC4741 Latest standard is RFC6241 in 2011 Does NOT explicitly define content. That is what YANG provides.
  15. As a Transport Protocol, NETCONF has a layered approach that defines how the Manager (client) and Agent (server) will communicate. Starting from the bottom:
  16. When making a request of an Agent, there are several possible actions you can take with NETCONF. The action is indicated using an XML tag. They are:
  17. One of the key requirements identified when the IETF was considering a replacement for SNMP was an integrated method for configuration validation, error checking/handling, and rollback.  As part of addressing this need, NETCONF includes "Data Stores" to provide targets of individual operation events. Each container will hold a copy of the configuration data that can be pre-validated before committing to active configuration.  We will target the "running" data store in this code line: Another benefit of data stores, is that network management systems can verify configurations across all devices in a network are consistent in a data store, than commit an entire change network wide at once. Data Store Key Points A container may hold an entire or partial configuration Not all data stores are supported on all devices  "running" is the only mandatory data store Not all data stores are writeable A "URL" data store is supported by IOS to enable <config-copy> Every NETCONF message must target a data store
  18. First, we import the ncclient and sys library. If you are working on your own machine, you will need to install the NCClient Library before you can run this code. Recall that we need to use ncclient version 0.5.2 minimum to ensure compatibility with Python3. The next lines create various names that we can update as needed to fit the appropriate environment. If you are using the CSR1000V in the lab environment, you do not need to change anything. Be sure to connect to your environment prior to running this code. Review the steps in Module 03 as needed.
  19. First, we import the ncclient and sys library. If you are working on your own machine, you will need to install the NCClient Library before you can run this code. Recall that we need to use ncclient version 0.5.2 minimum to ensure compatibility with Python3. The next lines create various names that we can update as needed to fit the appropriate environment. If you are using the CSR1000V in the lab environment, you do not need to change anything. Be sure to connect to your environment prior to running this code. Review the steps in Module 03 as needed.
  20. This code snippet creates the NETCONF over SSH session with the required arguments (white space added for readability): host = the IP address or hostname of the remote device. port = the NETCONF port for the SSH session username = the username to authenticate the SSH session password = the password to authenticate the SSH session hostkey_verify = disables hostkey verification from ~/.ssh/known_hosts device_params = allows for vendor specific operations (nothing special in this case) look_for_keys = disables public key authentication since we are using username/password allow_agent = disables public key authentication since we are using username/password Note that the with ... as expression ensures that our session is gracefully closed if we run into any exceptions in runtime After connecting, the variable m represents out NETCONF session. The session has a property called m.server_capabilities that contains the details of the capabilities that were returned during the connection steps.  We print out the list using a basic for ... in loop
  21. This code snippet creates the NETCONF over SSH session with the required arguments (white space added for readability): host = the IP address or hostname of the remote device. port = the NETCONF port for the SSH session username = the username to authenticate the SSH session password = the password to authenticate the SSH session hostkey_verify = disables hostkey verification from ~/.ssh/known_hosts device_params = allows for vendor specific operations (nothing special in this case) look_for_keys = disables public key authentication since we are using username/password allow_agent = disables public key authentication since we are using username/password Note that the with ... as expression ensures that our session is gracefully closed if we run into any exceptions in runtime After connecting, the variable m represents out NETCONF session. The session has a property called m.server_capabilities that contains the details of the capabilities that were returned during the connection steps.  We print out the list using a basic for ... in loop
  22. This code snippet creates the NETCONF over SSH session with the required arguments (white space added for readability): host = the IP address or hostname of the remote device. port = the NETCONF port for the SSH session username = the username to authenticate the SSH session password = the password to authenticate the SSH session hostkey_verify = disables hostkey verification from ~/.ssh/known_hosts device_params = allows for vendor specific operations (nothing special in this case) look_for_keys = disables public key authentication since we are using username/password allow_agent = disables public key authentication since we are using username/password Note that the with ... as expression ensures that our session is gracefully closed if we run into any exceptions in runtime After connecting, the variable m represents out NETCONF session. The session has a property called m.server_capabilities that contains the details of the capabilities that were returned during the connection steps.  We print out the list using a basic for ... in loop
  23. This code snippet creates the NETCONF over SSH session with the required arguments (white space added for readability): host = the IP address or hostname of the remote device. port = the NETCONF port for the SSH session username = the username to authenticate the SSH session password = the password to authenticate the SSH session hostkey_verify = disables hostkey verification from ~/.ssh/known_hosts device_params = allows for vendor specific operations (nothing special in this case) look_for_keys = disables public key authentication since we are using username/password allow_agent = disables public key authentication since we are using username/password Note that the with ... as expression ensures that our session is gracefully closed if we run into any exceptions in runtime After connecting, the variable m represents out NETCONF session. The session has a property called m.server_capabilities that contains the details of the capabilities that were returned during the connection steps.  We print out the list using a basic for ... in loop
  24. Exploring NETCONF Output We'll look at the script itself in a moment, but first let's look at the data that is returned, as we are presented with the full XML payload of the response.  The first line indicates that it is indeed XML and using version 1.0. As we learned, NETCONF uses RPC messages throughout, and here in the second and last lines we can see that we are reviewing an <rpc-reply> ... </rpc-reply> Within the rpc-reply we find <data> ... </data> tags that contain the actual bits of information that we are interested in. Returning the discussion of Namespaces, note the line <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> that opens the block of details. This tells you is that everything between the opening <interfaces> and closing </interface> tags is formated based on the namespace of urn:ietf:params:xml:ns:yang:ietf-interface. That long string identifies the specific data model used by this output. It can be loosely read as the Universal Resource Name provided by the IETF for a YANG model called ietf-interface. Data Models (namespaces) can be nested within each other. Look at the line <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>.  Here we see the interface type has it's own namespace (and YANG Data Model)
  25. With our solid understanding of the key elements of NETCONF, let's walk through the process a developer will take when using it.  Using a NETCONF Manager, connect to the Agent on a device and say <hello> The Agent replies with a list of <capabilities> The developer investigates the available data models provided as capabilities and selects the one that best meets their need. Compose the XML data that will be sent using an avaialble operation (ex: <get-config>) Send the message as a Remote Procedure Call <rpc> from the Manager The Agent sends an <rcp-reply> back Process the <data> that was included in the reply. Also, by leveraging tools like ncclient for Python, the developer can focus more on their application elements, than the intricacies of the protocol.
  26. RESTCONF is NOT a replacement for NETCONF. RESTCONF provides an API that aligns with other Web Application APIs to provide an easy entry point for developers. Though the gaps maybe eventually be filled, today RESTCONF lacks complete feature parity with NETCONF. More likely we will see both NETCONF and RESTCONF leveraged sumulataneiously by different clients.
  27. Transport - HTTP Like other REST APIs, RESTCONF leverages the HTTP protocol to encapsulate and send messages. Authentication is accomplished using typical HTTP Authentication models such as Basic Authentication where usernames and passwords are encoded in BASE64 and transmitted in a Header.
  28. REST APIs typically implement CRUD (Create, Retrieve, Update, and Delete) operations leveraging HTTP available methods. RESTCONF maps the NETCONF operations into these HTTP methods as shown in this table.
  29. One of the major advantages RESTCONF has over NETCONF is it's ability to leverage JSON as a data format. Many developers prefer JSON over XML due to easier readability and lower overhead.  When crafting a RESTCONF request, you must specify the data format being sent, and requested by the Agent. This is done in the typical HTTP way, using request headers.  Content-Type: Specify the type of data being sent from the client Accept: Specify the type of data being requested by the client RESTCONF describes the following MIME types to be used in these headers to indicate the format being requested.  application/vnd.yang.data+json application/vnd.yang.data+xml
  30. One aspect true of all REST APIs is the importance of the URI in identifying the data being requested or configured, and RESTCONF is no exception. One thing unique about RESTCONF is that it lacks any true "API Documentation" that a developer would use to learn about leveraging it. Rather, the YANG Models themselves ARE the API documentation.  All RESTCONF URIs follow this format: ADDRESS - The IP (or DNS Name) and Port where the RESTCONF Agent is available ROOT - The main entry point for RESTCONF requests. Before connecting to a RESTCONF server, you must determine the root Per the RESTCONF standard, devices should expose a resources called /.well-known/host-meta to enable discovery of root programmaticly  However with many devices still operating on DRAFT RESTCONF specs, this may not be fully implemented.  Device documentation should also specify the root path On the Cisco CSR, this is api DATA STORE - The data store being queried  [YANG MODULE:]CONTAINER - The base model container being used Inclusion of the module name is optional LEAF - An individual element from within the container [?<OPTIONS>] - Some network devices may support options sent as query parameters that impact returned results. These options are NOT required and can be omitted  Check device documentation for details on supported parameters To make the RESTCONF calls, you can use any client application that supports any REST call. A common tool is the Chrome Application Postman. The Linux command line utility "curl" is another great tool for working with REST APIs. We'll show how to use both in these examples.
  31. In this first example we're going to use RESTCONF to investigate the same ietf-interfaces model we've used in the previous labs.  As we learned, the URI is determined by looking at the underlying YANG model. Here is a partial ietf-interfaces Model.  This can be created by pyang -f tree ietf-interfaces.yang
  32. The Linux command line utility "curl" is a great tool for working with REST APIs. -H "Accept: application/vnd.yang.data+json" sets the HTTP "Accept" header to indicate our preference for JSON data -u admin:C1sco12345 provides the credentials for the device
  33. JSON Output from curl command. Notice how the underlying YANG Model is represented in the output.
  34. Let’s review the key elements of working with POSTMAN Provide the URL of the API call you are looking to make Indicate the HTTP Method being used Input any HEADERS needed. RESTCONF requries setting the Content-Type: and Accept: Headers to the proper MIME type Provide the Authentication Information Review the returned data And verify the Status Code matches expectations