SlideShare a Scribd company logo
1 of 14
Download to read offline
On-box programmability
Kazumasa Ikuta
2017.10.10
NetOpsCoding#5 × ネットワークプログラマビリティ勉強会#13
2010年1月21日木曜日。新潟某所にて…
https://www.janog.gr.jp/meeting/janog25/program/rscript.html
20171010 on-box programmability
• Ciscoさん EEM(2003頃〜) … CLI or Tcl
• YAMAHAさん Luaスクリプト(2009/10) … Lua
• Juniperさん JUNOScript2.0 … XSLT/SLAX
あれから、
7年と8ヶ月…
Junos で On-box Python
Arista EoS Event Manager (Condition à Action)
Catalyst までも…
#! /bin/bash
LXC
&&
参考:Catalyst 3850 IOS-XE 16.6.1
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 ~]$
[guestshell@guestshell flash]$ 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.6)
pip (9.0.1)
requests (2.18.4)
setuptools (22.0.5)
urllib3 (1.22)
[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]$
Catalyst で bash
vi, Python
pip
cat3850(config-applet)#event ?
application Application specific event
cli CLI event
config Configuration policy event
counter Counter event
env Environmental event
gold GOLD event
identity Identity event
interface Interface event
ioswdsysmon IOS WDSysMon event
ipsla IPSLA Event
mat MAC address table event
neighbor-discovery Neighbor Discovery event
nf NF Event
none Manually run policy event
oir OIR event
rf Redundancy Facility event
routing Routing event
rpc Remote Procedure Call event
snmp SNMP event
snmp-notification SNMP Notification Event
snmp-object SNMP object event
syslog Syslog event
tag event tag identifier
timer Timer event
cat3850(config-applet)#action 100 ?
add Add
append Append to a variable
break Break out of a conditional loop
cli Execute a CLI command
cns-event Send a CNS event
comment add comment
context Save or retrieve context information
continue Continue to next loop iteration
counter Modify a counter value
decrement Decrement a variable
divide Divide
else else conditional
elseif elseif conditional
end end conditional block
exit Exit from applet run
file file operations
force-switchover Force a software switchover
foreach foreach loop
gets get line of input from active tty
handle-error On error action
help Read/Set parser help buffer
if if conditional
increment Increment a variable
info Obtain system specific information
mail Send an e-mail
multiply Multiply
policy Run a pre-registered policy
publish-event Publish an application specific event
puts print data to active tty
regexp regular expression match
reload Reload system
set Set a variable
snmp-object-value Specify value for the SNMP get request
snmp-trap Send an SNMP trap
string string commands
subtract Subtract
syslog Log a syslog message
track Read/Set a tracking object
wait Wait for a specified amount of time
while while loop
内部イベント検出
アクション
&&
Demo
https://www.youtube.com/watch?v=7Hla36hkwt0&t=4s
EEM • ルーティングテーブル
の経路変化でトリガー
• Pythonに情報を提供
REST API
OSPF
経路
Catalyst 3850Cisco 1900
×
+ローカルファイルに記述
::cisco::eem::event_register_routing network 1.1.1.0/24 type all ge 24
import requests
import sys
import eem
ACCESS_TOKEN = ”<access_token>"
ROOM_ID = ”<room_id>"
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
event = eem.event_reqinfo()
message = ’# RoutingTable Change Detected # -> ' + event['network'] + '-' + event['type'] + '-BY-' + event['protocol']
header=setHeaders()
postMsg(header,ROOM_ID,message)
routewatch.py 1. ルーティング変更イベントを検出したら…
2. 通知内容を作って…
3. 書く。以上。
https://qiita.com/kikuta1978/items/42526882b57eafe480ad
SiSi SiSi
SiSiSiSiSiSi SiSiSiSiSiSi SiSiSiSiSiSi
• ネットワーク越しではできないことができ、想像力が膨らむ!(装置内のAPIとか)
• 装置やベンダーに依存する分、オープンに議論しにくい(かもしれない)
• やってみると、けっこう楽しい(しかもわりとリアルに役立つかもしれない)
まとめ:On-box プログラマビリティ
外部からの監視や自動化
• Zabbix
• Python
• Ansible
• Netconf/YANG
• …
内部からの監視や自動化
Shell
Python
EEM
Shell
Python
EEM
• On-box Python
• コンテナ
• イベント -> アクション
• …
Thank you!

More Related Content

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

20171010 on-box programmability

  • 1. On-box programmability Kazumasa Ikuta 2017.10.10 NetOpsCoding#5 × ネットワークプログラマビリティ勉強会#13
  • 4. • Ciscoさん EEM(2003頃〜) … CLI or Tcl • YAMAHAさん Luaスクリプト(2009/10) … Lua • Juniperさん JUNOScript2.0 … XSLT/SLAX
  • 7. Arista EoS Event Manager (Condition à Action)
  • 9. 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 ~]$ [guestshell@guestshell flash]$ 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.6) pip (9.0.1) requests (2.18.4) setuptools (22.0.5) urllib3 (1.22) [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]$ Catalyst で bash vi, Python pip
  • 10. cat3850(config-applet)#event ? application Application specific event cli CLI event config Configuration policy event counter Counter event env Environmental event gold GOLD event identity Identity event interface Interface event ioswdsysmon IOS WDSysMon event ipsla IPSLA Event mat MAC address table event neighbor-discovery Neighbor Discovery event nf NF Event none Manually run policy event oir OIR event rf Redundancy Facility event routing Routing event rpc Remote Procedure Call event snmp SNMP event snmp-notification SNMP Notification Event snmp-object SNMP object event syslog Syslog event tag event tag identifier timer Timer event cat3850(config-applet)#action 100 ? add Add append Append to a variable break Break out of a conditional loop cli Execute a CLI command cns-event Send a CNS event comment add comment context Save or retrieve context information continue Continue to next loop iteration counter Modify a counter value decrement Decrement a variable divide Divide else else conditional elseif elseif conditional end end conditional block exit Exit from applet run file file operations force-switchover Force a software switchover foreach foreach loop gets get line of input from active tty handle-error On error action help Read/Set parser help buffer if if conditional increment Increment a variable info Obtain system specific information mail Send an e-mail multiply Multiply policy Run a pre-registered policy publish-event Publish an application specific event puts print data to active tty regexp regular expression match reload Reload system set Set a variable snmp-object-value Specify value for the SNMP get request snmp-trap Send an SNMP trap string string commands subtract Subtract syslog Log a syslog message track Read/Set a tracking object wait Wait for a specified amount of time while while loop 内部イベント検出 アクション &&
  • 11. Demo https://www.youtube.com/watch?v=7Hla36hkwt0&t=4s EEM • ルーティングテーブル の経路変化でトリガー • Pythonに情報を提供 REST API OSPF 経路 Catalyst 3850Cisco 1900 × +ローカルファイルに記述
  • 12. ::cisco::eem::event_register_routing network 1.1.1.0/24 type all ge 24 import requests import sys import eem ACCESS_TOKEN = ”<access_token>" ROOM_ID = ”<room_id>" 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 event = eem.event_reqinfo() message = ’# RoutingTable Change Detected # -> ' + event['network'] + '-' + event['type'] + '-BY-' + event['protocol'] header=setHeaders() postMsg(header,ROOM_ID,message) routewatch.py 1. ルーティング変更イベントを検出したら… 2. 通知内容を作って… 3. 書く。以上。 https://qiita.com/kikuta1978/items/42526882b57eafe480ad
  • 13. SiSi SiSi SiSiSiSiSiSi SiSiSiSiSiSi SiSiSiSiSiSi • ネットワーク越しではできないことができ、想像力が膨らむ!(装置内のAPIとか) • 装置やベンダーに依存する分、オープンに議論しにくい(かもしれない) • やってみると、けっこう楽しい(しかもわりとリアルに役立つかもしれない) まとめ:On-box プログラマビリティ 外部からの監視や自動化 • Zabbix • Python • Ansible • Netconf/YANG • … 内部からの監視や自動化 Shell Python EEM Shell Python EEM • On-box Python • コンテナ • イベント -> アクション • …