ネットワーク API のあれこれ
NetworkNode API
How do you wan to talk with your Network Node?
Twitter: @ebiken | ebiken.g@gmail.com
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 1
ネットワーク API のあれこれ|ENOG37@燕三条2016/02/19|@ebiken 8
API対応状況(ネットワーク機器各種)
なぜネットワーク運用自動化が進まないのか
Why is it difficult to automate network operation
by Biglobe 土屋さん
http://www.slideshare.net/taijitsuchiya5/ss-47398248
http://www.slideshare.net/taijitsuchiya5/whitebox-switch-48099814
REST API ??
9.
REST おさらい
ネットワーク APIのあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 9
REST おさらい
• URI = リソース
• HTTP Method=操作
• POST => Create
• GET => Read
• PUT => Update
• DELETE => Delete
• BODYエンコーディング(符号化)
• 何でも良い:JSON, XML, CSV etc.
• でも JSON が多い
• ステート(セッション)もたない
操作 リソース
Brocade vRouter 5600(Vyatta)
• URI: コマンドを表す(リソースではなく)
• Encoding符号化: JSON
• 参照・設定、共にセッションを持つ
• Config Workflow
• Ops: one-time output
• Ops: continuous output
• GET /rest/op/<cmd>
• Ops with no session ID will return parameter definitions.
• Very different from RESTful concept.
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 12
Brocade vRouter 5600 (Vyatta)
13.
Brocade vRouter 5600(Vyatta)
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 13
設定投入&適用 Workflow
1. Begin a configuration session
• Config Session ID named "conf-id" will be
generated.
2. make configuration changes
• PUT /rest/conf/<conf-id>/set/<path>
• PUT /rest/conf/<conf-id>/delete/<path>
3. commit changes
• POST /rest/conf/<conf-id>/<cmd>
4. optional: view config
• GET /rest/conf/<conf-id>/<path>
5. save config
• POST /rest/conf/<conf-id>/<cmd>
6. Finish configuration session
• DELETE /rest/conf/<conf-id>
14.
Brocade vRouter 5600(Vyatta)
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 14
参照コマンド (One Time)
• Begin a ops session
• POST /rest/op/show/version
• HTTP/1.1 201 Created
• Location: rest/op/137AA3B22A362CA3
• Get output from the command just
sent
• GET /rest/op/137AA3B22A362CA3
• HTTP/1.1 200 OK
• If request 2nd time, it's gone.
• GET /rest/op/137AA3B22A362CA3
• HTTP/1.1 410 Gone
15.
Brocade vRouter 5600(Vyatta)
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 15
参照コマンド (継続的)
• Begin a ops session (ex: ping)
• POST /rest/op/ping/10.0.0.1
• Get ouput (1st)
• GET /rest/op/02B3479CA1522F2A
• HTTP/1.1 200 OK
• PING 10.3.0.1 (10.3.0.1) 56(84) bytes of
data.
• 64 bytes from 10.3.0.1: icmp_seq=1
ttl=64 time=0.839 ms
• 64 bytes from 10.3.0.1: icmp_seq=2
ttl=64 time=0.846 ms
• ...
• 64 bytes from 10.3.0.1: icmp_seq=18
ttl=64 time=0.821 ms
• Get output (2nd)
• GET /rest/op/02B3479CA1522F2A
• HTTP/1.1 200 OK
• 64 bytes from 10.3.0.1: icmp_seq=19
ttl=64 time=0.799 ms
• 64 bytes from 10.3.0.1: icmp_seq=20
ttl=64 time=0.807 ms
• ...
• Stop a ops session (and the command
ping)
• DELETE /rest/op/02B3479CA1522F2A
.
device-name port
JUNOS: XMLRPC Single Method
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 20
URI Example
https://198.51.100.1:3000/rpc/get-software-information
... /get-interface-information?terse=&interface-name=ge-0/0/1
method
method parameters
参考:JunosのREST APIを使ってみる
http://qiita.com/kazubu/items/e5e0941f66f6c6f2f55a
21.
JUNOS: XML RPCSingle Method
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 21
CLIコマンドに対応する RPC method 確認方法
参考:JunosのREST APIを使ってみる
http://qiita.com/kazubu/items/e5e0941f66f6c6f2f55a
• OpenSwitch byHP
• REST実装あり。但し現状は OVSDB に対する操作のみ。
• ops-restd : Overview
• ------------
• OpenSwitch provides a Tornado framework-based application to access
**OVSDB** using RESTful APIs. The ops-restd module provides all the necessary
python packages required to add, delete, modify tables in the OVSDB database
using ```HTTP``` methods, ```GET, POST, PUT and DELETE```.
• Linux Shellアクセスできる機器増えてるので、Switchに載るGateway作ると
か?
• OpenFlowでもなんでも、RESTでアクセスできるように。
ネットワーク API のあれこれ|ENOG37@燕三条 2016/02/19|@ebiken 26