EEM・Guest Shellとon-box Python6 / 7

Guest ShellとPython

Guest Shellはdevice上のLinux環境で、対応するIOx/application hosting、storage/resourceとnetwork接続が必要になる。routing/control planeそのもののshellとは違い、外部serverへの到達にはguest側interface、management/VRF、default route・DNS/NAT等のplatform条件を構成する。IOS側でpingできることだけでGuest Shellの到達性を証明しない。

対応するdeviceでguestshell enableを行い、guestshell run python3等でscriptを実行する。deviceのcli moduleは、Guest Shell等の対応環境からIOS CLIを取得・構成する。一般の外部PCへ同名moduleを入れるだけでは、自動でremote IOSへ接続するものではない。

from cli import cli

summary = cli("show ip interface brief")
for line in summary.splitlines()[:20]:
    print(line)

この例は最大20行の状態を表示する。取得量と保存先を制限し、巨大なshow tech全体をmemoryへ無制限に取り込まない。configure/configurep等で設定する場合は、対象のCLI modeとerror/read-backを確認する。

学習パスへ
参考資料