Masaki Tagawa
Kazumasa Ikuta
2017.8.4
IOS/IOS-XE運用管理機能アップデート
CTU NMS 2017 Aug
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• 主に IOS-XE バージョン 16 以降で新しくサポートされた運用管理機能を中心に解説し、実際の設定や使用方法をご紹介いたします
• Cisco ISR/ASR および Catalyst を主な対象とします
IOS/IOS-XE 運用管理機能アップデート
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• はじめに
• Guest Shell と Python
• EEM と On-box Python
• NETCONF と データ モデル• ncclient
• YANG Explorer
アジェンダ
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
はじめに
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
UADPUnified Access Data Plane
Flexible, Programmable, High-Performance Switching Silicon
• Fully Programmable –excellent flexibility, ability to handlenew encaps (VXLAN, GPE, etc) –hardware speed, software elasticity
• Scalable – Massive recirculation bandwidth and low recirculation latency provide excellent tunneling and services support for traffic flows
• Advanced on-chip QoS –client–level granularity, sophisticated bandwidth shaping, with integrated on-chip NetFlow for visibility
• Secure – integrated on-chip support for MACsec encryption (AES-128, CBC)
• Extensible Architecture –ability to scale both up and down –the foundation for a long-lived family of high-performance, flexible switching silicon
QFPQuantumFlow Processor
Advanced, Multi-Core, Feature-Rich Routing Silicon
• Fully Programmable –leveraging the many features of IOS-XE with hardware performance
• Scalable – Massive number of CPU cores (40/64), abilityto cascade multiple QFPs = consistent high performance
• Advanced on-chip QoS –100,000+ hardware-based queues, sophisticated traffic shaping and control
• Secure – linkage to high-performance crypto capability for secure WAN transport
• Extensible Architecture –ability to scale both up and down –the foundation for a long-lived family of high-performance, flexible routing silicon
IOS-XEThe Evolution of IOS
Taking the Proven Strengthsof IOS to the Next Level
• Operational andServices Uniformity –Routing, Switching,and Wireless consistency
• Speed of Innovation Velocity – “Code once and Re-use Many” across multiple places in the network
• Foundation for Virtualization –providing for network hostingand integration of virtualized functions (VNFs, containers)
• New Foundational Capabilities – HA and operational leadership, state decoupling, net database …
• Platform for the Future –the “software stage” for thenext wave of Cisco innovation …
“People that are really serious about software should build their own hardware”
100% シスコが開発したプログラマブルシリコン– DNAの機能をハードウェアスピードで実行
ハードウェア+ソフトウェアイノベーションの基礎
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Catalyst で動作する IOS-XE の進化
共通基盤 / HA
管理インターフェース
モジュールドライバ
カーネル
IOS
IOS
共通基盤 / HA
管理インターフェイス
モジュール ドライバ
カーネル
IOS XE 3.7.x (SE)
機能群
AppホスティングIOSd
機能群
WCM
Wireshark
Open IOS XE (16.1.1)
AppホスティングIOSd
LXC
LXC
データベース
共通基盤 / HA
管理インターフェイス
モジュール ドライバ
カーネル
WCM
Wire
shark
IOSd コア
IOS Sub
SystemsIOS Sub
SystemsIOSサブシステム
操作感は変えずに、ソフトウェア アーキテクチャを刷新
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
データベースを確認 – Crimson DB
Cat3850-3#show platform software process database dbm switch active r0 summary
Database: MDT_OPER_DB
Table Name or ID Table OID (id/src) Table Type LUID Records Cur Mode
-------------------------------------------------------------------------------------------------------------------------
table repl_toc 2/0x0 tbl_toc b272aa9e1d00a82f 2 en expl
table mdt_streams 4/0x0 mdt_streams 3a5c60d8eaa1ff3f 1 en expl
table mdt_subscriptions 6/0x0 mdt_subscriptions d373c82770f2af51 1 en expl
table mdt_receivers 8/0x0 mdt_receivers da893bbd75d2811e 0 en expl
table mdt_connections 10/0x0 mdt_connections ab4329ef37096b84 0 en expl
table mdt_sub_con_statist 12/0x0 mdt_sub_con_statisti d9714fa14c7907df 0 en expl
1 16/0x0 mdt_receivers da893bbd75d2811e 1 en expl
Database: MDT_CONFIG_DB
Table Name or ID Table OID (id/src) Table Type LUID Records Cur Mode
-------------------------------------------------------------------------------------------------------------------------
table repl_toc 2/0x0 tbl_toc b272aa9e1d00a82f 1 en expl
table mdt_subscriptions_c 4/0x0 mdt_subscriptions_co d2adb9245b5e6db3 1 en expl
table mdt_receivers_confi 6/0x0 mdt_receivers_config 4c73dd83691c6b0e 0 en expl
be_cursor_table 8/0x0 be_cursor_table 4249c9626610277b 2 dis -
1 1152921504606846980/0x0 mdt_receivers_config 4c73dd83691c6b0e 1 en expl
Database: IM_CONFIG_DB
<snip>
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• x86 アーキテクチャで動作するアプリケーションを、コンテナ上でサポート
• Puppet や Chef Agent
• IoT やクラウド アプリケーションとの親和性
• MIPS アーキテクチャ プラットフォーム(Cat3650/3850)でサポートする Guest Shell ではハードウェアによる制約あり(Guest Shell Lite)
Catalyst 9K では x86 CPU を採用
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
IOS コンフィグレーション ガイドProgrammability & Data Models
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
ネットワーク プログラマビリティに対する考え方の違い
初級 中級 上級
特徴 • コマンドラインを使いこなす• プログラミングは経験が少ない
• コーディング経験が少しあるネットワーク技術者中心
• EEM, Tcl, Expect など
• コーディング経験が豊富で、自動化を推進
関心事 • 作業の自動化• エンジニア スキルセットの拡大
• Netconf, Python, Ansible などへ移行
• データ モデルの理解
• マルチベンダー環境での統一運用、相互接続
懸念事項 • 学習事項が多いが、確保できる時間が少ない
• プログラマビリティを本格的に実現するツールは何か
• 抽象化する価値は何か
• オープンスタンダード仕様
提供すべき内容 • 基本的なプログラマビリティのコンセプト理解
• スクリプティングの紹介 (Python,
Ansible など)• 少ない投資ですぐに効果が出る
ユース ケースの紹介
• Netconf トレーニング• APIを使った装置オペレーション• 利用可能なツールとその使い方
• APIドキュメントなどの情報提供、公開
• 新機能の差分アップデート
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
SiSi SiSi
SiSiSiSiSiSi SiSiSiSiSiSi SiSiSiSiSiSi
• デバイス内での監視や自動化を定義し、リモート管理システムだけでは得られないロジックを実現でき、管理品質の向上や、オペレーション コスト削減に貢献
• 任意のイベントに基づくプロアクティブな対処が可能 (EEM)
• 装置やベンダーの実装に比較的依存
Off-box + On-box プログラマビリティ
外部からの監視や自動化
• Python
• Ansible
• Netconf/YANG
• …
• DNA-Center/APIC-EM
• Prime Infrastructure
• Zabbix
• …
内部からの監視や自動化
ShellPythonEEM
ShellPythonEEM
• On-box Python
• EEM
• Guest Shell
• …
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
プロビジョニング手法 – IOS-XE 16.5 以降Pre-boot Execution
Environment (PXE) Client
Zero Touch
Provisioning
Cisco Network Plug
and Play
ブートするソフトウェアイメージ元
ネットワーク上 装置内(カスタマイズでイメージ配布)
装置内(オプションでイメージ配布)
プロトコル/
インターフェイス
オープン / 標準 オープン / 標準 シスコによる作り込み、仕様は公開「ターン キー」ソリューション
特徴 マルチベンダー環境 マルチベンダー環境スクリプト自動配布スクリプトは作成必要
• シスコ中心の LAN/WAN に最適化• セキュリティ組み込み• スケーラビリティ考慮• API 公開
PXE Booting
Router
PXE Booting
Switch
DHCP PXE
ServerZTP Booting
Router
ZTP Booting
Switch
DHCP ZTP
ServerPNP Booting
Router
PNP Booting
Switch
APIC-EM / Network
Plug and Play
Server
PNP Access
Point
option 150 ip 203.0.113.254
option 67 ascii /sample_python_dir/python_script.py
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell と Python API
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• Linux Shell … IOS XE 上 LXC コンテナで実行
• IOS-XE CLI や bootflash にアクセス可能
• Python を標準サポート(Cat3K では 2.7, Cat9K では 2.7/3.X)
• pip 組込み➡ Python パッケージの追加インストール
• yum サポート (Cat9K)➡ Linux パッケージの追加インストール
Guest Shell
IOS-XE (IOSd)
Guest Shell
オープンアプリケーションコンテナ
API
Linuxアプリケーション
様々なライブラリを活用できる Python を使ったOn-box プログラマビリティを提供
python
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell Lite と Guest ShellGuest Shell Lite (Limited LXCコンテナ) Guest Shell (LXCコンテナ)
OS Cisco IOS XE Cisco IOS XE
サポート プラットフォーム Cisco Catalyst 3650 Series Switches (all models)Cisco Catalyst 3850 Series Switches (all models)
Cisco Catalyst 9300 Series Switches (all models)Cisco ISR 4000 Series Integrated Services Routers (Models with a minimum of 8 GB RAM.)
Guest Shell環境 Montavista CGE7 CentOS 7
Python 2.7 Supported (Python V2.7.11) Supported (Python V2.7.5)
カスタム Python ライブラリ Cisco Embedded Event ManagerCisco IOS XE CLIsNcclient
Cisco Embedded Event ManagerCisco IOS XE CLIs
Supported Rootfs Busybox, SSH, and Python PIP install SSH, Yum install, and Python PIP install
GNU C Compiler Not supported Not supported
RPM Install Not supported Supported
アーキテクチャ MIPS x86
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell の起動
Cat3850-3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Cat3850-3(config)#iox
Cat3850-3(config)#exit
Cat3850-3#
Cat3850-3#guestshell enable
Management Interface will be selected if configured
Please wait for completion
guestshell is in RUNNING state
Cat3850-3#
Cat3850-3#guestshell
[guestshell@guestshell ~]$
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell の動作確認
Cat3850-3#show iox
IOx Infrastructure Summary:
---------------------------
IOx service (CAF) : Running
IOx service (HA) : Running
IOx service (IOxman) : Running
Libvirtd : Running
Cat3850-3#show app-hosting detail
State : RUNNING
Author : Cisco Systems
Application
Type : lxc
App id : guestshell
Name : guestshell
Version : 0.1
Activated profile name : custom
Description : MontaVista guestshell
Resource reservation
Memory : 256 MB
Disk : 1 MB
CPU : 800 units
VCPU : 1
Attached devices
Type Name Alias
---------------------------------------------
Serial/shell
Serial/aux
Serial/Syslog serial2
Serial/Trace serial3
Network interfaces
---------------------------------------
eth0:
MAC address : 52:54:dd:63:b1:0a
IPv4 address : 192.168.30.2
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell の環境設定
[guestshell@guestshell ~]$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 52:54:DD:63:B1:0A
inet addr:192.168.30.2 Bcast:192.168.30.7 Mask:255.255.255.248
interface GigabitEthernet0/0
vrf forwarding Mgmt-vrf
ip address <ipaddress> <mask>
!
ip route vrf Mgmt-vrf 0.0.0.0 0.0.0.0 <mgmt-gateway>
IOS-XE 側で management port を設定
自動設定される Guest Shell のネットワーク環境
[guestshell@guestshell ~]$ cat /flash/proxy_vars.sh
export http_proxy=http://proxy-wsa.example.com:80/
export https_proxy=http://proxy-wsa.example.com:80/
export HTTP_PROXY=http://proxy-wsa.example.com:80/
export HTTPS_PROXY=http://proxy-wsa.example.com:80/
[guestshell@guestshell ~]$ source /flash/proxy_vars.sh
Guest Shell 上のプロキシ設定例
[guestshell@guestshell ~]$ cat /etc/resolv.conf
nameserver 8.8.8.8
Guest Shell 上の DNS サーバ設定例
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Python インタラクティブモード
Cat3850-3#guestshell run python
Python 2.7.11 (default, May 17 2017, 05:17:57)
[GCC 5.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> msg = "Hello CTU!"
>>> print msg
Hello CTU!
>>>
>>> import cli
>>> cli.clip('show ip int brief | i Vlan1')
Vlan1 unassigned YES NVRAM up up
>>>
>>> output = cli.cli('show clock')
>>> print output
*11:11:17.345 UTC Tue Aug 1 2017
>>>
>>> cli.configure(["interface GigabitEthernet1/0/7", "no shut", "end"])
[ConfigResult(success=True, command='interface GigabitEthernet1/0/7', line=1, output='', notes=None), ConfigResult(success=True, command='no shut', line=2,
output='', notes=None), ConfigResult(success=True, command='end', line=3, output='', notes=None)]
>>>
• 組込み Python CLI ライブラリを import し、Guest Shell からIOS コマンドを実行・結果取得する例
• Netconf(ncclient ライブラリ)を使えば、内部データベースと直接やり取りできる
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell 環境Cat3850-3#guestshell
[guestshell@guestshell ~]$ uname -a
Linux guestshell 3.10.101-rt110 #1 SMP Fri Jun 30 20:16:49 PDT 2017 mips64 GNU/Linux
[guestshell@guestshell ~]$
[guestshell@guestshell ~]$ cat /proc/version
Linux version 3.10.101-rt110 (xelinux@xe-linux-bld2) (gcc version 5.3.0 (GCC) ) #1 SMP Fri Jun 30 20:16:49 PDT 2017
[guestshell@guestshell ~]$
[guestshell@guestshell ~]$ cd /
[guestshell@guestshell /]$ ls
bin data flash local proc tmp
boot dev home lost+found sbin usr
bootflash etc lib media selinux var
cisco fix_sshd.sh lib64 mnt sys
C9300-24U#guestshell
[guestshell@guestshell ~]$ uname -a
Linux guestshell 4.4.51 #1 SMP Sun Jun 4 17:58:12 PDT 2017 x86_64 x86_64 x86_64 GNU/Linux
[guestshell@guestshell ~]$
[guestshell@guestshell ~]$ cat /proc/version
Linux version 4.4.51 (xelinux@xe-linux-bld2) (gcc version 5.3.0 (GCC) ) #1 SMP Sun Jun 4 17:58:12 PDT 2017
[guestshell@guestshell ~]$
[guestshell@guestshell ~]$ cd /
[guestshell@guestshell /]$ ls
bin cisco dev flash lib64 media proc run srv unfix_sshd.sh
boot created.2016-05-31.14:23:44 etc home local mnt root sbin sys usr
bootflash data fix_sshd.sh lib lost+found opt rr_moved selinux tmp var
flash:/(IOS-XE) = /flash/(Guest Shell)自動でマウントされる
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Guest Shell 上で Python スクリプトを編集・実行[guestshell@guestshell ~]$ pwd
/home/guestshell
[guestshell@guestshell ~]$ pip list
pip (9.0.1)
setuptools (22.0.5)
[guestshell@guestshell ~]$
[guestshell@guestshell ~]$ cd /flash/
[guestshell@guestshell flash]$ ls | grep .bin
cat3k_caa-universalk9.16.06.01.SPA.bin
[guestshell@guestshell flash]$
[guestshell@guestshell flash]$ touch test.txt
[guestshell@guestshell flash]$ ls | grep test
test.txt
[guestshell@guestshell flash]$
[guestshell@guestshell flash]$ vi sho-ver.py
[guestshell@guestshell flash]$
[guestshell@guestshell flash]$ cat sho-ver.py
#!/usr/bin/python
import cli
print cli.execute('show version')
[guestshell@guestshell flash]$
[guestshell@guestshell flash]$ python ./sho-ver.py | grep bin
System image file is "flash:cat3k_caa-universalk9.16.06.01.SPA.bin"
[guestshell@guestshell flash]$
Vi エディタを実行
show version を実行して結果を表示する Python スクリプト例
スクリプト実行結果
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
EEM と On-box Python
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• 装置内で実行される On-box 監視&カスタマイズ機能
• イベント検知→アクション実行• イベント・アクションの組み合わせは自由
• 既存の IOS-XE 機能では不可能なロジックを作成
• アプレット版(CLI), Tcl 版(スクリプト), Python 版(スクリプト)
• 幅広いサポート機器• C800〜ASR1000, Cat2K, 3K, 4K, 6K, Nexus, XR…, Cat9K…
• イベント、アクションの細かなサポート内容はバージョンに依存
EEM 概要と Python サポート
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Embedded Event
Manager
Syslogemail
notification
SNMP set
Counter
CLI
Applets
SNMP
get
SNMP
notification
Application
specific
TCL
Policies
Reload or
switchover
EEM Applets
multi-event-correlation
IOS.sh
Policies
Actions
Event Detectors
Syslog
Event
Process
Scheduler
Database
Interface
Descriptor
Blocks
Syslog
ED
Watchdog
ED
Interface
Counter
ED
CLI
ED
OIR
ED
ERM
ED
EOT
ED
RF
ED
none
ED
GOLD
ED
XML
RPC
ED
SNMP
EDs
Remote:
• Notification
Local:
• Notification
• Get/Set
NetFlow
ED
IPSLA
ED
Route
ED
Timer
EDs
• Cron
• Count
down
HW
EDs
• Fan
• Temp
• Env
• ...
CDP
LLDP
ED
802.1x
ED
MAC
ED
Python
Policies
xxx
ED…
EEM アーキテクチャ
…New!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• 「〜が発生したら〜する」という判断や処理を自動化する EEM
Cisco Embedded Event Manager(EEM)
CLI ベース(EEM アプレット) Tcl ベース(EEM Tcl) Python ベース(EEM Python Module)
•強み•設定が比較的容易•余分なファイルが不要
•弱み•高度な処理には不向き
•強み•CLI より柔軟な動作を設定可能
•弱み•TCL を覚える必要がある
•強み•TCL スクリプト同様の柔軟な動作を設定可能•豊富なライブラリを活用可能
•弱み•Python を覚える必要がある
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
1. EEM アプレット(CLI)の中で Python スクリプトを実行
• Event Detector: CLI, Action: CLI で Python スクリプトを実行
• メリット:汎用的な Python スクリプトがそのまま使える
• デメリット:イベントは EEM アプレット (CLI) 相当
2. EEM スクリプト (Python) を記述
• Event Detector, Action ともに Python スクリプトで記述
• メリット:EEM 特有の高度な記述が可能(複雑なイベント検出など)
• デメリット:EEM Python ライブラリの学習が必要
EEM と Python の組み合わせ方: 2 種類
Event Detectors(〜が発生したら)
Action(〜を行う)
Event Detectors(〜が発生したら)
Action(〜を行う)
値の受け渡し・何が?・いつ?
値の受け渡し・何が?・いつ?
CLI
Python
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• 標準で 3 つのカスタムライブラリが付属
• pip を使って追加インストール可能
On-box プログラマビリティのための Python ライブラリ
ライブラリ名 読み込み 概要
Cisco IOS XE CLI import cli IOS XE の CLI に対して入出力を行うライブラリ
Cisco Embedded
Event Manager
import eem Python スクリプト内で EEM 固有の操作を実現するためのライブラリ(Event 検出,
syslog, cli, snmp, mail, reload, …)
Ncclient import
ncclient
Netconf クライアントの Python ライブラリ
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
event manager applet TEST
event none
action 100 cli command "enable"
action 200 cli command "guestshell run python /bootflash/sho-ver.py"
Cat3850-3#debug event manager action cli
Debug EEM action cli debugging is on
Cat3850-3#event manager run TEST
*Aug 2 20:40:47.987: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : CTL : cli_open called.
*Aug 2 20:40:47.990: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Cat3850-3>
*Aug 2 20:40:47.990: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : IN : Cat3850-3>enable
*Aug 2 20:40:48.103: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Cat3850-3#
*Aug 2 20:40:48.104: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : IN : Cat3850-3#guestshell run python /bootflash/sho-ver.py
*Aug 2 20:40:53.654: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Cisco IOS XE Software, Version 16.06.01
*Aug 2 20:40:53.654: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Cisco IOS Software [Everest], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.6.1, RELEASE SOFTWARE (fc2)
*Aug 2 20:40:53.655: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Technical Support: http://www.cisco.com/techsupport
*Aug 2 20:40:53.655: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Copyright (c) 1986-2017 by Cisco Systems, Inc.
*Aug 2 20:40:53.655: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Compiled Sat 22-Jul-17 03:00 by mcpre
*Aug 2 20:40:53.655: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Cisco IOS-XE software, Copyright (c) 2005-2017 by cisco Systems, Inc.
*Aug 2 20:40:53.655: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : All rights reserved. Certain components of Cisco IOS-XE software are
*Aug 2 20:40:53.656: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : licensed under the GNU General Public License ("GPL") Version 2.0. The
*Aug 2 20:40:53.656: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : software code licensed under GPL Version 2.0 is free software that comes
*Aug 2 20:40:53.656: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such
*Aug 2 20:40:53.656: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : GPL code under the terms of GPL Version 2.0. For more details, see the
*Aug 2 20:40:53.657: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : documentation or "License Notice" file accompanying the IOS-XE software,
*Aug 2 20:40:53.657: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : or the applicable URL provided on the flyer accompanying the IOS-XE
*Aug 2 20:40:53.657: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : software.
*Aug 2 20:40:53.657: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : ROM: IOS-XE ROMMON
*Aug 2 20:40:53.658: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : BOOTLDR: CAT3K_CAA Boot Loader (CAT3K_CAA-HBOOT-M) Version 3.58, RELEASE SOFTWARE (P)
*Aug 2 20:40:53.658: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Cat3850-3 uptime is 3 days, 13 hours, 13 minutes
*Aug 2 20:40:53.658: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : Uptime for this control processor is 3 days, 13 hours, 16 minutes
*Aug 2 20:40:53.658: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : System returned to ROM by reload
*Aug 2 20:40:53.658: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : System image file is "flash:cat3k_caa-universalk9.16.06.01.SPA.bin"
*Aug 2 20:40:53.658: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : CTL : 20+ lines read from cli, debug output truncated
*Aug 2 20:40:53.659: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : CTL : cli_close called.
*Aug 2 20:40:53.661:
*Aug 2 20:40:53.661: tty is now going through its death sequence
Cat3850-3#
シンプルな動作例* None event detector … Action のテスト用で多用* debug event manager action cli … EEM による CLI 実行結果を出力
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
EEM Python モジュール デモ
EEM
1. Syslog 中に%LINEPROTO-5-UPDOWN:
を見つけると Python スクリプトを実行
2. Cisco Spark の特定スペースに通知(Syslog 内容や任意のメッセージなど)
REST API (HTTPS)python
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Python パッケージの追加インストールSpark にメッセージを POST するために利用するライブラリ - Requests
[guestshell@guestshell ~]$ sudo pip list install
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in
your pip.conf under the [list] section) to disable this warning.
certifi (2017.7.27.1)
chardet (3.0.4)
idna (2.5)
pip (9.0.1)
requests (2.18.2)
setuptools (22.0.5)
urllib3 (1.22)
[guestshell@guestshell ~]$ sudo pip install requests
任意のパッケージを追加インストール・活用できる
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
event manager applet syslog
event syslog pattern "%LINEPROTO-5-UPDOWN:"
action 100 syslog msg "Syslog ## $_syslog_msg ## Detected by EEM"
action 200 cli command "enable"
action 205 cli command "guestshell run python /bootflash/kikuta/spark_post.py Interface_UpDownEvent_Detected"
action 208 cli command "guestshell run python /bootflash/kikuta/spark_post.py https://10.71.154.112/"
設定例 1EEM アプレット (CLI) + Python スクリプト
[guestshell@guestshell ~]$ cat /bootflash/kikuta/spark_post.py
import requests
import sys
ACCESS_TOKEN = "<Cisco Spark Access Token>”
ROOM_ID = "<Cisco Spark_Room Id>”
YOUR_MESSAGE = sys.argv[1]
#ヘッダー作成def setHeaders():
accessToken_hdr = 'Bearer ' + ACCESS_TOKEN
spark_header = {'Authorization': accessToken_hdr, 'Content-Type': 'application/json; charset=utf-8'}
return spark_header
#メッセージをポストdef postMsg(the_header,roomId,message):
message = '{"roomId":"' + roomId + '","text":"' + message +'"}’
uri = 'https://api.ciscospark.com/v1/messages’
resp = requests.post(uri, data=message, headers=the_header)
print resp
header=setHeaders()
postMsg(header,ROOM_ID,YOUR_MESSAGE)
汎用的なPythonスクリプトがそのまま使える
CLI で設定する引数を Spark に投稿(イベントごとに投稿する内容を変更できる)
NMS や OSS へ誘導チケットを自動発行
他装置を API で設定変更…などなど
EEM イベントは CLI で記述
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
::cisco::eem::event_register_syslog tag "1" pattern %LINEPROTO-5-UPDOWN: maxrun 200
import requests
import sys
import eem
ACCESS_TOKEN = "<Cisco Spark Access Token>”
ROOM_ID = "<Cisco Spark Room Id>”
# Make HTTP request headers with the token
def setHeaders():
accessToken_hdr = 'Bearer ' + ACCESS_TOKEN
spark_header = {'Authorization': accessToken_hdr,
'Content-Type': 'application/json; charset=utf-8’}
return spark_header
# Create a message with the matched syslog message
def makeMsg(syslogMsg):
# Remove LF on the syslog message
msg = '## Critical Syslog Message¥¥n¥¥n' + syslogMsg.replace(’¥n','')
return msg
# Post a message to the person
def postMsg(the_header, roomId, markdown):
message = '{"roomId":"' + roomId + '","markdown":"' + markdown +'"}’
uri = 'https://api.ciscospark.com/v1/messages’
resp = requests.post(uri, data=message, headers=the_header)
# Get the event information
event = eem.event_reqinfo()
header = setHeaders()
message = makeMsg(event['msg'])
postMsg(header, ROOM_ID, message)
設定例2EEM スクリプト (Python)
1. 左のファイルを/flash/syslog2spark.py として保存
2. IOS XE CLI で EEM スクリプトを登録
EEMで検出するイベントを記述
EEM パッケージを使った Syslog 情報の取得(event_reqinfo)
event manager directory user policy "flash:/"
event manager policy syslog2spark.py type user
EEM パッケージを読み込み
実行例
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
NETCONF / YANG
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• “NETwork CONFiguration Protocol”
• ネットワーク機器の設定投入や削除、情報取得
• プログラムによる自動化を想定した設計
• 標準化された通信方法と構造化されたデータ
NETCONF
⭕
構造化されたデータ
❌
構造化されていないデータ
Name : John Smith
Age : 42
Phone: +1-415-555-1212
<name>John Smith</name>
<age>42</age>
<phone>+1-415-555-1212</phone>
John Smith 42 +1-415-555-1212
Keys Values
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• “NETwork CONFiguration Protocol”
• ネットワーク機器の設定投入や削除、情報取得
• プログラムによる自動化を想定した設計
• 標準化された通信方法と構造化されたデータ
NETCONF
switch1# sh int e1/10
Ethernet1/10 is up
Hardware: 1000/10000 Ethernet, address:
0005.73d0.9331 (bia 0005.73d0.9331)
Description: To UCS-11
MTU 1500 bytes, BW 1000000 Kbit, DLY
<interface>Ethernet 0/0</interface>
<name>Switch1 to UCS1</name>
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• “NETwork CONFiguration Protocol”
• ネットワーク機器の設定投入や削除、情報取得
• プログラムによる自動化を想定した設計
• 標準化された通信方法と構造化されたデータ
NETCONF
switch1# sh int e1/10
Ethernet1/10 is up
Hardware: 1000/10000 Ethernet, address:
0005.73d0.9331 (bia 0005.73d0.9331)
Description: To UCS-11
MTU 1500 bytes, BW 1000000 Kbit, DLY
<interface>Ethernet 0/0</interface>
<name>Switch1 to UCS1</name>
<name>Ethernet 0/0</name>
<descr>Switch1 to UCS1</descr>
データ構造の定義(値の格納の仕方)が必要
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
データ モデル
• Cisco 定義
• Ciscoプラットフォーム毎にユニーク
• 例) IOS-XE のみ
• Cisco 定義
• Ciscoプラットフォーム間共通
• 例) IOS-XE / NX-OS
• 標準策定 (IETF, ITU, OpenConfig, etc)
• 標準に準拠
• 例) “Policy”
• ietf-diffserv-policy.yang,
• ietf-diffserv-classifer.yang,
• ietf-diffserv-target.yang
業界標準
Cisco
共通
Cisco
プラットフォーム
独自
マルチベンダ環境での共通データ モデルや、装置固有の機能に対応したデータモデルに対応したプログラムを記述できる
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
NETCONF/YANG の有効化と動作確認
Cat3850-3(config)#netconf-yang
Cat3850-3#show platform software yang-management process
confd : Running
nesd : Running
syncfd : Running
ncsshd : Running
dmiauthd : Running
vtyserverutild : Running
opdatamgrd : Running
nginx : Running
ndbmand : Running
pubd : Running
Cat3850-3(config)#username <user> privilege 15 secret <password>
Cat3850-3(config)#aaa new-model
Cat3850-3(config)#aaa authentication login default local
Cat3850-3(config)#aaa authorization exec default local
Cat3850-3(config)#hostname Cat3850-3
Cat3850-3(config)#ip domain name example.com
Cat3850-3(config)#crypto key generate rsa modulus 2048
Cat3850-3(config)#ip ssh version 2
SSH によるリモートアクセスの設定例
動作確認
有効化
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
装置が対応するデータ モデルを確認Capabilities Exchange
$ ssh -s [email protected] -p 830 netconf
[email protected]'s password:
<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:base:1.1</capability>
<capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability>
<capability>urn:ietf:params:netconf:capability:xpath:1.0</capability>
<capability>urn:ietf:params:netconf:capability:validate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:validate:1.1</capability>
..
<snip>
<capability>http://cisco.com/ns/yang/Cisco-IOS-XE-aaa?module=Cisco-IOS-XE-aaa&revision=2017-06-05</capability>
<capability>http://cisco.com/ns/yang/Cisco-IOS-XE-acl?module=Cisco-IOS-XE-acl&revision=2017-06-06</capability>
..
<snip>
<capability>http://openconfig.net/yang/interfaces/ip-ext?module=openconfig-if-ip-ext&revision=2016-12-22</capability>
<capability>http://openconfig.net/yang/lacp?module=openconfig-lacp&revision=2016-05-26</capability>
<capability>http://openconfig.net/yang/lldp?module=openconfig-lldp&revision=2016-05-16</capability>
<capability>http://openconfig.net/yang/lldp/types?module=openconfig-lldp-types&revision=2016-05-16</capability>
<capability>http://openconfig.net/yang/local-routing?module=openconfig-local-routing&revision=2016-05-11</capability>
..
<snip>
SSH netconf サブ システムへポート 830 に接続
Cisco Native や Openconfig によるデータ モデル(YANG モジュール)に対応していることがわかる
IETF
Cisco
Openconfig
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
実際にやってみるncclient: Netconf クライアントの Python ライブラリ
#!/usr/bin/env python3
from ncclient import manager
from xml.dom.minidom import parseString
host = '<hostname or ip_addr>’
username = '<username>’
password = '<password>’
with manager.connect(host=host, port=830,
username=username,
password=password,
device_params={'name':'iosxe'}
) as m:
c = m.get_config(source='running').data_xml
print(parseString(c).toprettyxml(indent=' '))
$ pip install ncclient 事前準備:pip を使ったライブラリのインストール
Running config をxml 形式で表示する
https://github.com/ncclient/ncclient
#!/usr/bin/env python3
from ncclient import manager
from xml.dom.minidom import parseString
host = '<hostname or ip_addr>’
username = '<username>’
password = '<password>’
payload = “””
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<version/>
</native>
</filter>
“””
with manager.connect(host=host, port=830,
username=username, password=password,
device_params={'name':'iosxe'}) as m:
c = m.get(payload).data_xml
print(parseString(c).
getElementsByTagName('version')[0].firstChild.data)
IOS のバージョンを表示する
Netconf による接続を簡単に記述できる
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• Cisco が開発・公開しているオープンソース ツール
• IETF93 のハッカソンがきっかけで開発された• https://blogs.cisco.com/getyourbuildon/yang-opensource-tools-for-data-modeling-driven-management
• Netconf/YANG 関連の動作確認やテスト、学習時に活用
• YANG モデル対応装置(NETCONF サーバ、つまりルータやスイッチなど)から YANG Explorer への対応データ モデルのダウンロード
• YANG モデル ファイルをコンパイルして見やすく表示
• RPC の生成、保存
• 装置 (NETCONF サーバ) に対して RPC を実行 (Read/Write)
• Python スクリプトの生成、保存
• YANG モデルの依存グラフの生成
実際にやってみるYANG Explorer
https://github.com/CiscoDevNet/yang-explorer
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
接続デバイス情報の登録
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
必要なデータ モデル(スキーマ)にチェックを入れて“Sync” をクリック
⬇
データ モデル(スキーマ)が装置からYang Explorer にダウンロードされる
デバイスからデータモデルを同期・ダウンロード
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Yang Explorer にダウンロードされたデータ モデルを
左の Explorer ペインにツリー表示する
YANG モデルファイルをコンパイルして見やすく表示
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
ncclient デモの「IOS のバージョンを表示する」Python スクリプトにおける変数 `payload` と
同一の内容
RPC の生成, 保存, 実行
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Python 2.x 向けのソースコードが生成される
NETCONF クライアントとしての実装にncclient ライブラリが利用されている
ncclient を使う Python スクリプトの生成, 保存
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• https://github.com/YangModels/yang
“YANG modules from standard organizations such as the IETF, open source such as Open Daylight or vendor specific modules”
• https://github.com/YangModels/yang/tree/master/vendor/cisco
Reference: GitHub レポジトリ
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
まとめ
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• プログラマビリティを推進 – IOS-XE 16.X
• オープン化、自動化を推進する多数の機能や技術
• 装置単位(On-Box/Off-Box)
• プロトコル
• 新機能多数!
• ゲストシェル
• Python
• EEM/Python
• Netconf/YANG
• Yang Explorer
まとめIOS-XE 16.X - オープンでプログラマブルなインフラストラクチャ
Automation
Abstraction and Policy Control from Core to Edge
オープン&プログラマブル | 標準ベース
オープンAPI | 開発環境
Cloud Service Management
Policy | Orchestration
Virtualization
Physical and Virtual Infrastructure | App Hosting
Analytics
Network Data, Contextual Insights
ネットワークアプリケーション
クラウド対応 | ソフトウェア
DNA構成要素、テクノロジー スタック
NW
機器
コン
トロ
ーラ
クラ
ウド
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Appendix
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• IOS-XE コンフィグレーション マニュアル
• http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst3850/software/release/16-5/configuration_guide/b-165-3850-cg/b-165-3850-cg_chapter_01.html
• http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9300/software/release/16-5/configuration_guide/b-165-9300-cg/b-165-9300-cg_chapter_010.html
• http://www.cisco.com/c/en/us/support/routers/asr-1000-series-aggregation-services-routers/products-installation-and-configuration-guides-list.html
• http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/datamodels/configuration/xe-16/data-models-xe-16-book.html
• ツール参考
• ncclient
• https://github.com/ncclient/ncclient
• Yang Explorer
• https://github.com/CiscoDevNet/yang-explorer
URLs