1、有用的链接

Model Driven Network Automation with IOS-XE

https://www.ciscolive.com/c/dam/r/ciscolive/emea/docs/2018/pdf/LTRCRT-2700.pdf

Configure NETCONF/YANG and Validate Example for Cisco IOS XE 16.x Platforms

https://www.cisco.com/c/en/us/support/docs/storage-networking/management/200933-YANG-NETCONF-Configuration-Validation.html

Programmability Configuration Guide, Cisco IOS XE Everest 16.6.x

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/166/b_166_programmability_cg/configuring_yang_datamodel.html

yang-explorer

https://github.com/CiscoDevNet/yang-explorer

YangModels

https://github.com/YangModels

2、安装yang-explorer

准备:

MAC、Linux(不支持windows)

python 2.7

pip软件管理器

浏览器带flash plugin(推荐chrome)

//pip install --upgrade pip

//yum install python-virtualenv

//yum install graphviz

a、更改pip源

mkdir ~/.pip

vi ~/.pip/pip.conf

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host = mirrors.aliyun.com

yum install python2-pip  python-virtualenv  graphviz      -y

依赖组件:

yum install  libxml2-devel libxslt-devel  python-devel zlib-devel gcc git  -y

git clone  https://github.com/CiscoDevNet/yang-explorer.git

b、安装

cd yang-explorer/

bash  setup.sh

省略。。。。。。。

Successfully built ydk-models-cisco-ios-xr

Installing collected packages: ydk-models-cisco-ios-xr

Successfully installed ydk-models-cisco-ios-xr-6.2.1

Installing dependencies .. done

Setting up initial database ..

Warning: Setting up database as root, this is not recommended.

Alternatively you can re-run this script as non-root

to setup database without root privilege.

Do you want to continue as root ? (n/N) //初始化数据库

Creating data directories ..

Creating database ..

Operations to perform:

Synchronize unmigrated apps: staticfiles, messages, explorer

Apply all migrations: admin, contenttypes, auth, sessions

Synchronizing apps without migrations:

Creating tables...

Creating table explorer_collection

Creating table explorer_userprofile

Creating table explorer_deviceprofile

Running deferred SQL...

Installing custom SQL...

Running migrations:

Rendering model states... DONE

Applying contenttypes.0001_initial... OK

Applying auth.0001_initial... OK

Applying admin.0001_initial... OK

Applying contenttypes.0002_remove_content_type_name... OK

Applying auth.0002_alter_permission_name_max_length... OK

Applying auth.0003_alter_user_email_max_length... OK

Applying auth.0004_alter_user_username_opts... OK

Applying auth.0005_alter_user_last_login_null... OK

Applying auth.0006_require_contenttypes_0002... OK

Applying sessions.0001_initial... OK

Creating default users ..

Copying default models ..

Setup completed..

Use start.sh to start yang-explorer server

安装完成。

c、修改配置文件并运行yang-exporer

[root@desk yang-explorer]# cd server/static/

[root@desk static]# vi YangExplorer.html

var swfVersionStr = "16.0.0";

// To use express install, set to playerProductInstall.swf, otherwise the empty string.

var xiSwfUrlStr = "expressInstall.swf";

var flashvars = {};

flashvars.host = '192.168.0.87';        //修改监听地址和端口

flashvars.port = '8088';

[root@desk static]# cd ..

[root@desk server]# cd ..

[root@desk yang-explorer]# vi start.sh

#!/usr/bin/env bash

HOST='192.168.0.87'

PORT='8088'

# set timeout value for ncclient

export NCCLIENT_TIMEOUT=90

[root@desk yang-explorer]# ls

default-models  docs  env.sh  LICENSE  README.md  requirements.txt  server  setup.sh  start.sh  v  YangExplorer

[root@desk yang-explorer]# ./start.sh

Activating virtualenv ..

Starting YangExplorer server ..

Use http://192.168.0.87:8088/static/YangExplorer.html

Performing system checks...

System check identified no issues (0 silenced).

July 17, 2019 - 15:22:46

Django version 1.8.3, using settings 'server.settings'

Starting development server at http://192.168.0.87:8088/

Quit the server with CONTROL-C.

打开浏览器:

http://192.168.0.87:8088/static/YangExplorer.html

3、导入YangModels

点击Login

username:guest

password:guess

Subscript

4、配置XE路由器

XE3(config)#netconf-yang      //主要配置

Cisco-IOS-XE-native----->native --->interface --->GigabitEthernet          name

ip---->address-choice

<rpc-reply message-id="urn:uuid:79b79a13-844a-4248-aac5-c47401b15745" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">

<ok/>

</rpc-reply>

检查

XE3#sh ip inter b

Interface              IP-Address      OK? Method Status                Protocol

GigabitEthernet1       192.168.0.29    YES DHCP   up                    up

GigabitEthernet2      10.1.1.1        YES other  administratively down down

GigabitEthernet3       unassigned      YES unset  administratively down down

XE3#sh ip inter b

Interface              IP-Address      OK? Method Status                Protocol

GigabitEthernet1       192.168.0.29    YES DHCP   up                    up

GigabitEthernet2       10.1.1.1        YES other  up                    up

GigabitEthernet3       unassigned      YES unset  administratively down down

产生python文件:

"""

Netconf python example by yang-explorer (https://github.com/CiscoDevNet/yang-explorer)

Installing python dependencies:

> pip install lxml ncclient

Running script: (save as example.py)

> python example.py -a 192.168.0.29 -u yoyoo -p yoyoo123 --port 830         //执行python的方法

"""

import lxml.etree as ET

from argparse import ArgumentParser

from ncclient import manager

from ncclient.operations import RPCError

payload = """

<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">

<interface>

<GigabitEthernet>

<name>2</name>

<ip>

<address>

<primary>

<address>10.1.1.1</address>

<mask>255.255.255.0</mask>

</primary>

</address>

</ip>

</GigabitEthernet>

</interface>

</native>

</config>

"""

if __name__ == &apos;__main__&apos;:

parser = ArgumentParser(description=&apos;Usage:&apos;)

# script arguments

parser.add_argument(&apos;-a&apos;, &apos;--host&apos;, type=str, required=True,

help="Device IP address or Hostname")

parser.add_argument(&apos;-u&apos;, &apos;--username&apos;, type=str, required=True,

help="Device Username (netconf agent username)")

parser.add_argument(&apos;-p&apos;, &apos;--password&apos;, type=str, required=True,

help="Device Password (netconf agent password)")

parser.add_argument(&apos;--port&apos;, type=int, default=830,

help="Netconf agent port")

args = parser.parse_args()

# connect to netconf agent

with manager.connect(host=args.host,

port=args.port,

username=args.username,

password=args.password,

timeout=90,

hostkey_verify=False,

device_params={&apos;name&apos;: &apos;csr&apos;}) as m:

# execute netconf operation

try:

response = m.edit_config(target=&apos;running&apos;, config=payload).xml

data = ET.fromstring(response)

except RPCError as e:

data = e._raw

# beautify output

print(ET.tostring(data, pretty_print=True))

NETCONF配置CISCO XE(csr1000v)初体验相关推荐

  1. 香蕉派(or 皮?)上手初体验 -- 外观鉴赏,安装,配置amp;总结

    一.前言及简单介绍 听到"派"或者是看到这幅图片.难免让你想到眼下大名鼎鼎的"树莓派". 而香蕉派(Banana Pi. 论坛上也有人称它香蕉皮)是一款国产的比 ...

  2. 我的Go+语言初体验——【四、版本更新环境变量配置】

    欢迎大家参与[我的Go+语言初体验]活动: 活动地址:[https://bbs.csdn.net/topics/603464006?utm_source=1594742339] 目录 拉取最新包[gi ...

  3. 【云原生】 初体验阿里云Serverless应用引擎SAE(三),挂载配置文件使应用的配置和运行的镜像解耦

    目录 一.前言 二.SAE配置 1.创建配置项 2.配置SAE Nginx服务 效果 1.[云原生] 初体验阿里云Serverless应用引擎SAE(一),部署Nginx服务 2.[云原生] 初体验阿 ...

  4. 【Flask框架】一. Flask框架初体验(配置环境 + 简单demo样例)

    文章目录 一. Flask框架初体验(配置环境 + 简单demo样例) 虚拟环境 新建项目 将Pycharm改为FLASK_DEBUG模式 修改FLASK_DEBUG模式的步骤 配置文件 简单用法 U ...

  5. ue编辑器c语言语法高亮文件,再见UE之VS Code初体验---实现远端Linux C开发配置,ue初体验...

    再见UE之VS Code初体验---实现远端Linux C开发配置,ue初体验 一.引言 笔者以前使用的远端开发工具为 Xshell5 + Xftp5 + Source Insight4++Uedit ...

  6. 小程序 缩放_缩放流星应用程序的初体验

    小程序 缩放 by Elie Steinbock 埃莉·斯坦博克(Elie Steinbock) 缩放流星应用程序的初体验 (First Experiences Scaling a Meteor Ap ...

  7. wxWidgets刚開始学习的人导引(3)——wxWidgets应用程序初体验

    wxWidgets刚開始学习的人导引全文件夹   PDF版及附件下载 1 前言 2 下载.安装wxWidgets 3 wxWidgets应用程序初体验 4 wxWidgets学习资料及利用方法指导 5 ...

  8. 深度探索Hyperledger技术与应用之超级账本初体验(附部署代码)

    2019独角兽企业重金招聘Python工程师标准>>> 本章零基础地介绍了如何快速体验超级账本搭建的区块链网络,我们先绕过了比较复杂的初始化配置,用官方提供的fabric-sampl ...

  9. Spring环境搭建,IoC容器初体验~

    由于最近的任务是关于IoC配置文件格式的转换,所以需要从Spring的IoC容器开始学起,今天根据网上的介绍搭建了Spring环境,并对其IoC容器进行了初体验.文章中涉及到的软件以及推荐的一本关于S ...

最新文章

  1. 人人都能学会的python编程教程3:字符串和编码
  2. 腾讯再次海选AI项目,1500进40,医疗零售机器人成新风向
  3. 聊聊LettucePoolingConnectionProvider
  4. devc 无法编译循环语句_鸡生蛋还是蛋生鸡?详解第一个编译器是怎么来的~
  5. 树莓派使用STEP5:安装samba文件共享服务器
  6. 【转载】图片 CSS:怎样才能 “响应式 + 固定宽高比例”?
  7. android listview item按钮,android-listview适配器中的按钮
  8. python不属于字符串的是_【python cookbook】python过滤字符串中不属于指定集合的字符...
  9. 如何在windows 2008 server 新建用户
  10. delphi接口带上请求头是什么意思_Gin框架中使用JWT进行接口验证
  11. ztree的select设置,完笔
  12. 世界观的内涵是认识论模型
  13. 2020双十一,阿里云GRTN拉开直播和RTC技术下半场的序幕
  14. A4纸张两面打印、每面打印2页的打印机设置
  15. 一篇文章,只用看三遍,终生不忘网络分层
  16. 软件测试实战(微软技术专家经验总结)--第九、十章(团队工作、个人管理)读书笔记
  17. 5G推动下,XR的需求“爆发”会来自B端还是C端?...
  18. 微软官方的精简版Windows 7——Windows Thin PC
  19. 低成本2.4G SOC(NYA054E)灯控遥控芯片方案-CI2454/CI2451
  20. 基于U-Net 的图像分割(使用Crack 500数据集)

热门文章

  1. mysql sql 备份表_SQL语句之备份表
  2. Android 使用 okhttp3和retrofit2 进行单文件和多文件上传
  3. 【SpringBoot】:springboot整合FTP文件上传与下载功能
  4. url去重的几种方式
  5. FX1S控制步进电机的实例(图与程序)
  6. Point Cloud Transformer的pytorch代码实现
  7. 电脑重装Win10如何选择32位和64位的系统
  8. bean login not found within scope
  9. Alignment trap
  10. 基于matlab的车牌识别系统设计,基于MATLAB的车牌识别系统设计