In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
1. Useful links
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. Install yang-explorer
Prepare:
MAC, Linux (windows is not supported)
Python 2.7
Pip Software Manager
Browser with flash plugin (recommended chrome)
/ / pip install-- upgrade pip
/ / yum install python-virtualenv
/ / yum install graphviz
A. Change the pip source
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
Dependent components:
Yum install libxml2-devel libxslt-devel python-devel zlib-devel gcc git-y
Git clone https://github.com/CiscoDevNet/yang-explorer.git
B, installation
Cd yang-explorer/
Bash setup.sh
Omit.
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? (nbat N) y / / initialize the database
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
The installation is complete.
C. Modify the configuration file and run 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 = & apos;192.168.0.87'; / / modify listening address and port
Flashvars.port = & apos;8088&apos
[root@desk static] # cd..
[root@desk server] # cd..
[root@desk yang-explorer] # vi start.sh
#! / usr/bin/env bash
HOST='192.168.0.87&apos
PORT='8088&apos
# 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&apos
Starting development server at http://192.168.0.87:8088/
Quit the server with CONTROL-C.
Open the browser:
Http://192.168.0.87:8088/static/YangExplorer.html
3. Import YangModels
Click Login
Username:guest
Password:guess
Subscript
4. Configure the XE router
XE3 (config) # netconf-yang / / main configuration
Cisco-IOS-XE-native- > native- > interface-- > GigabitEthernet name
Ip---- > address-choice
Check
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
Generate a python file:
"
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 / / method to execute python
"
Import lxml.etree as ET
From argparse import ArgumentParser
From ncclient import manager
From ncclient.operations import RPCError
Payload = ""
two
10.1.1.1
255.255.255.0
"
If _ _ name__ = & apos;__main__':
Parser = ArgumentParser (description='Usage:')
# script arguments
Parser.add_argument (& apos;-a', & apos;--host', type=str, required=True
Help= "Device IP address or Hostname")
Parser.add_argument (& apos;-u', & apos;--username', type=str, required=True
Help= "Device Username (netconf agent username)")
Parser.add_argument (& apos;-p', & apos;--password', type=str, required=True
Help= "Device Password (netconf agent password)")
Parser.add_argument (& apos;--port', 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;csr'}) as m:
# execute netconf operation
Try:
Response = m.edit_config (target='running', config=payload) .xml
Data = ET.fromstring (response)
Except RPCError as e:
Data = e._raw
# beautify output
Print (ET.tostring (data, pretty_print=True))
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.