genie shell
基本的な使い方
genie shell --testbed testbed.yml
from genie.testbed import load
tb = load('testbed.yml')
# yml に記述の device を確認
for device in tb.devices:
print(device)
# devicce に 接続 (device 名の指定は alias でも可)
tb.devices['R1'].connect(via='vty')
# 接続確認
tb.devices['R1'].connected
# 切断
tb.devices['R1'].disconnect()
# parse: CLI コマンド結果を解析
# 対応コマンドは https://developer.cisco.com/docs/genie-docs/
tb.devices['R1'].parse('show route')
# 変数に格納して任意の値にアクセス
v4route = tb.devices['rt'].parse('show route')
for value in v4route['vrf']['default']['address_family']['ipv4']['routes']:
print(value)
# Learn: 抽象的なコマンドを適切に解釈して parse
tb.devices['R1'].learn('routing')