본문 바로가기
Networking/Network Automation

CCNP ENAUTO - 2 [Udemy]

by 포항돼지 2025. 4. 2.

Synchronous API vs Asynchronous API

 

Synchronous = We can think this is as queue. once the API call coming in, it will wait till the first request is done. once the task is completed, it will move on to next

 

Asynchoronous = can handle multiple call.

 

How the controll the Asynchrounous error

 
 

Understanding Python

 

Why Learn Python?

Interpreted Scripting Langugage

Low barrier to entry compared to other languages

can be used to write various types of python applications

python execution engine exists on most linux distributions including network operating systems, such as NX- OS

 

Tip : In Nexus OS, we can run the python code on the device.

and also, python can communicate with most of network devices == automation

 

IDE = Integrated Development Environment, is a software application that provides comprehensive facilities to computer programmers for software development.

 
 
 

3 type of htlp utilities

 

dir() = 내장 함수, 어떤 객체를 인자로 넣어주면 해당 객체가 어떤 변수와 메소드 (method)를 가지고 있는지 나열 해줌 , Supported Method 출력해줌

type() = object type 찾을때 쓰는 함수

help(int) = int 내장함수 어떤 기능 인지, 설명해줌

 

Python virtual environment benefit

we can test different version of programming code with different set up of API

 
 

Explain benefit of ansible and pupet

IOS XE platforms and other devices are supporting for automation for the management relative task

 

Most Popular tools: Puppet , Ansible, Chef, and saltstck

puppet : agent base

ansible : agentless

 

Why we are using/doing this?

To automate for recurring job & decrese human error

 

NetDevOps = Network + DevOps -> Infrastructure as code

 
 
 
 

Automate APIs and Protocols

Most likely Yang model is used for data modeling

 

Evolution of Device Management and Programmability

 

SNMP : Network device communication (was)

It is the base of the network automation

 

SNPM has been around for 20 years. it has been the de facto way to monitor networks.

SNMP uses a get-request to retrieve a MIB variable from the SNMP (show run ..etc)

v1 and v2 provide very basic and undencrypted security.

 

Problems to use SNMP (in result, it is not smart protocol)

  • Lac of writable MIBs
  • Difficult to replay/rollback configuration
  • Lacks libraries for various programming languages
  • in 2015, Google announced intent to disable SNMP for monitoring by 2017
 
 
 

따라서, 네트워크 오토메이션 devleopment는 snmp 부터 (Network layer) 부터 시작해서 Next-Gen configuration Management 까지 왔따 (Layer 7). API 도 지원하고 programmbility 도 지원하는, 스마트한 시대!!!

 

Handle the Machine to Mahcine Communication via API

 

Model Driven Network Programmability

-> Solution for managing the entrie IT structure

 

Format of Programmability (Program model)

 

what protocol it is supporting is really important

 

SD-WAN :

We manage the controller

Netconf Protocol

SSH

configure Device (CLI)

XML/JSON *****

 

JSON(JavaScript Object Notation)

Name Value : Key Value

similar as Python dictionary

 

json.dumps(var,indent=4) json function 중에,일자로 되어있으면 보기 어려우니까 indent (들여쓰기) 보기쉽게 해주는거

string 으로 type 이 바뀜

 

Cisco device is using json format for API communication

 

pipe + json 치면 jason format 으로 나옴

other example

 

show vlan br | json

-> key and value will show up

format example

 

XML

XML vs HTML -> format is quite a similar

 
 
 

Palo Alto firewall is supporting XML base API

XML 타입은, 시작할떄 무조건 <시작>, 이런 식으로 해야함, 그리고 끝낼때 </시작> 이렇게 슬러쉬 써서 끝임을 indicate 해야함.

예)

XML data 끌어오기 위해서, Python 으로 스크립트 작성해서 돌려야함

xml.sax.contenthandler쓰기 위해서 xml.sax library import 시켜야함

 
 

이렇게 만들어진 python program 돌리면, 정보 나옴

 

 

 

Data Models

 

Why we need data model??

and why don't we use CLI?

CLI doesn't have any data model on it -> not able to be automated

 

While there is a lot of focus on data models these days, they are not new. They are simply improving and becoming more focused on network devcies and next-gen APIs.

 

The industry is migrating from a world of having no framwork (no modeling) when using CLI commands and text output to world of a fully modeled device; in other words, a device that has a JSON and XML representation of its full configuration and that is fully driven from a robust model such as YANG.

 

YANG(Yet Another Next Generation) Data model object

Model-Driven API, Development kit

 

Initially built for NETCONF now also used RESTCONF as well.

Calling 1 object -> they are communicating as follow the tree

 

Have to enabled netconf ssh and netconfg-yang for using YANG data modeling

once the netconf-yang is configured on the router, router will be able to transmit data with YANG data format

 
 

Model-Driven Programming

 

vManage = using Netconf inside of data plan/control plane

WHY do we need Netconf?? -> its way developed then SNMP

 

Netconf

  • client base communication
  • XML/Json
  • SSH
 
 

Operation (get,put,pull,delete)

 

ssh - p 830 -> netconf port

step to communicate with server via SSH

 
 

RESTCONF

Functional sub-set of NETCONF

Exposes YANG models via a REST API (URL)

Uses HTTP(S) as transport

Uses XML or JSON for encoding

Developed to use HTTP tools and programming

libraries Uses common HTTP verbs in REST APIs

 
 

Simliar data type as REST API -> Post Man support??

vManage of API?? -> Cisco cManage support Rest API base data transmission

it has API doc

 

 

schema already has been created, only thing need to is just put the device information -> it will provide the query URL

 
 
 

Network Device Programmability

 

Where we have to for the automation, CB and apps.. etc

 
 

Netmiko

Type of Python library, multi-vendor networking library based on paramiko

 

Paramiko is the standard python ssh library

 

Need to download

csr1000v-universalk9.16.6.1.qcow2

i86bi-linux-l2-ipbasek9-15.1.c.bin

iosxrv-k9-demo-5.3.0.qcow2