見出し画像

Cisco DevNet SandboxのCisco pyATS XPRESSOでpyatsのサンプルを実行したらエラーになった。(対策あり)

Ciscoのエンジニアさんが開発したというpyATSという自動化ツールの学習をしてみようとDevNet Sandboxを予約。無料で使えるのがありがたい。

早速DevBoxにログインしてpyatsを最新版にupdate。用意されているtestbedファイル「/home/developer/py3venv/multi-platform-network.yaml」を使って実行してみたがエラーになる。「"/e65a3c/n3/0" not found!」なんでや。

(py3venv) [developer@devbox py3venv]$ pyats shell --testbed-file multi-platform-network.yaml
Welcome to pyATS Interactive Shell
==================================
Python 3.6.8 (default, Sep 14 2019, 14:33:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

>>> from pyats.topology.loader import load
>>> testbed = load('multi-platform-network.yaml')
------------------------------------------------------------------------------- 
>>> device = testbed.devices['core-rtr01']
>>> device.connect()

2022-05-06 21:50:44,602: %UNICON-INFO: +++ core-rtr01 logfile /tmp/core-rtr01-cli-20220506T215044602.log +++

2022-05-06 21:50:44,602: %UNICON-INFO: +++ Unicon plugin iosxr/iosxrv (unicon.plugins.iosxr.iosxrv) +++

2022-05-06 21:50:44,605: %UNICON-INFO: connection via proxy terminal_server

2022-05-06 21:50:44,609: %UNICON-INFO: +++ connection to spawn: ssh -l developer 10.10.20.161, id: 140668347919664 +++

2022-05-06 21:50:44,610: %UNICON-INFO: connection to terminal_server
Warning: Permanently added '10.10.20.161' (RSA) to the list of known hosts.
developer@10.10.20.161's password:

****
CML^2 Console Server
****

tab completion works
list available nodes and node labels / IDs with "list"
it's also possible to do a "open /lab_1/n0/0" command

consoles>

2022-05-06 21:50:45,058: %UNICON-INFO: +++ initializing handle +++

2022-05-06 21:50:45,079: %UNICON-INFO: connection to core-rtr01

2022-05-06 21:50:45,079: %UNICON-INFO: Waiting for 5 seconds before attempting to connect..

2022-05-06 21:50:50,084: %UNICON-INFO: Trying to connect to prompt on device core-rtr01 ...
consoles> open /e65a3c/n3/0
console "/e65a3c/n3/0" not found!
consoles>
consoles>
consoles>
consoles>

2022-05-06 21:50:56,117: %UNICON-INFO: Can not access prompt on device core-rtr01 so assuming  virtual launch is in progress ...

解答:用意されているtestbedファイルに書かれているコンソールのLab IDと実際のLab IDが違ってる。

multi-platform-network.yaml
  core-rtr01:
    os: iosxr
    type: router
    series: iosxrv
    connections:
      cli:
        protocol: telnet
        proxy: terminal_server
        command: open /e65a3c/n3/0  <----- !!!!!!!!!!
****
CML^2 Console Server
****

tab completion works
list available nodes and node labels / IDs with "list"
it's also possible to do a "open /lab_1/n0/0" command

consoles> list
Lab ID   Node ID      Lines          Node Label                Lab Title
------------------------------------------------------------------------
2e7baf        n0        0,1      internet-rtr01   Multi Platform Network
2e7baf        n1          0     internet-host01   Multi Platform Network
2e7baf       n10          0       inside-host02   Multi Platform Network
2e7baf       n11        0,1           edge-sw01   Multi Platform Network
2e7baf        n2          0     edge-firewall01   Multi Platform Network
2e7baf        n3      0,1,2          core-rtr01   Multi Platform Network  <----- !!!!!!!!!!
2e7baf        n4      0,1,2          core-rtr02   Multi Platform Network
2e7baf        n5        0,1          dist-rtr01   Multi Platform Network
2e7baf        n6        0,1          dist-rtr02   Multi Platform Network
2e7baf        n7        0,1           dist-sw01   Multi Platform Network
2e7baf        n8        0,1           dist-sw02   Multi Platform Network
2e7baf        n9          0       inside-host01   Multi Platform Network
consoles>

testbedファイルのコンソール設定を書き換えたら動いた。

multi-platform-network.yaml
  core-rtr01:
    os: iosxr
    type: router
    series: iosxrv
    connections:
      cli:
        protocol: telnet
        proxy: terminal_server
        command: open /2e7baf/n3/0  <----- !!!!!!!!!!
(py3venv) [developer@devbox py3venv]$ pyats shell --testbed-file multi-platform-network.yaml
Welcome to pyATS Interactive Shell
==================================
Python 3.6.8 (default, Sep 14 2019, 14:33:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

>>> from pyats.topology.loader import load
>>> testbed = load('multi-platform-network.yaml')
------------------------------------------------------------------------------- 
>>> device = testbed.devices['core-rtr01']
>>> device.connect()

2022-05-06 21:57:22,236: %UNICON-INFO: +++ core-rtr01 logfile /tmp/core-rtr01-cli-20220506T215722235.log +++

2022-05-06 21:57:22,236: %UNICON-INFO: +++ Unicon plugin iosxr/iosxrv (unicon.plugins.iosxr.iosxrv) +++

2022-05-06 21:57:22,238: %UNICON-INFO: connection via proxy terminal_server

2022-05-06 21:57:22,243: %UNICON-INFO: +++ connection to spawn: ssh -l developer 10.10.20.161, id: 140325217672440 +++

2022-05-06 21:57:22,244: %UNICON-INFO: connection to terminal_server
Warning: Permanently added '10.10.20.161' (RSA) to the list of known hosts.
developer@10.10.20.161's password:

****
CML^2 Console Server
****

tab completion works
list available nodes and node labels / IDs with "list"
it's also possible to do a "open /lab_1/n0/0" command

consoles>

2022-05-06 21:57:22,682: %UNICON-INFO: +++ initializing handle +++

2022-05-06 21:57:22,687: %UNICON-INFO: connection to core-rtr01

2022-05-06 21:57:22,687: %UNICON-INFO: Waiting for 5 seconds before attempting to connect..

2022-05-06 21:57:27,692: %UNICON-INFO: Trying to connect to prompt on device core-rtr01 ...
consoles> open /2e7baf/n3/0
Connecting to console for core-rtr01
Connected to terminalserver.
Escape character is '^]'.


IMPORTANT:  READ CAREFULLY
Welcome to the Demo Version of Cisco IOS XRv (the "Software").
The Software is subject to and governed by the terms and conditions
of the End User License Agreement and the Supplemental End User
License Agreement accompanying the product, made available at the
time of your order, or posted on the Cisco website at
www.cisco.com/go/terms (collectively, the "Agreement").
As set forth more fully in the Agreement, use of the Software is
strictly limited to internal use in a non-production environment
solely for demonstration and evaluation purposes.  Downloading,
installing, or using the Software constitutes acceptance of the
Agreement, and you are binding yourself and the business entity
that you represent to the Agreement.  If you do not agree to all
of the terms of the Agreement, then Cisco is unwilling to license
the Software to you and (a) you may not download, install or use the
Software, and (b) you may return the Software as more fully set forth
in the Agreement.


Please login with any configured user/password, or cisco/cisco


User Access Verification

Username:
Username:


User Access Verification

Username: cisco
Password:


RP/0/0/CPU0:core-rtr01#

2022-05-06 21:57:31,156: %UNICON-INFO: +++ initializing handle +++

2022-05-06 21:57:31,221: %UNICON-INFO: +++ core-rtr01 with via 'cli': executing command 'terminal length 0' +++
terminal length 0
Sat May  7 04:57:30.507 UTC
RP/0/0/CPU0:core-rtr01#

2022-05-06 21:57:31,638: %UNICON-INFO: +++ core-rtr01 with via 'cli': executing command 'terminal width 0' +++
terminal width 0
Sat May  7 04:57:30.917 UTC
RP/0/0/CPU0:core-rtr01#

2022-05-06 21:57:31,870: %UNICON-INFO: +++ core-rtr01 with via 'cli': configure +++
configure terminal
Sat May  7 04:57:31.217 UTC
RP/0/0/CPU0:core-rtr01(config)#no logging console
RP/0/0/CPU0:core-rtr01(config)#logging console disable
RP/0/0/CPU0:core-rtr01(config)#line console
RP/0/0/CPU0:core-rtr01(config-line)#exec-timeout 0 0
RP/0/0/CPU0:core-rtr01(config-line)#absolute-timeout 0
RP/0/0/CPU0:core-rtr01(config-line)#session-timeout 0
RP/0/0/CPU0:core-rtr01(config-line)#line default
RP/0/0/CPU0:core-rtr01(config-line)#exec-timeout 0 0
RP/0/0/CPU0:core-rtr01(config-line)#absolute-timeout 0
RP/0/0/CPU0:core-rtr01(config-line)#session-timeout 0
RP/0/0/CPU0:core-rtr01(config-line)#commit
Sat May  7 04:57:32.737 UTC
RP/0/0/CPU0:core-rtr01(config-line)#end
RP/0/0/CPU0:core-rtr01#
'Warning: Permanently added \'10.10.20.161\' (RSA) to the list of known hosts.\r\r\ndeveloper@10.10.20.161\'s password: \r\n\r\n****\r\nCML^2 Console Server\r\n****\r\n\r\ntab completion works\r\nlist available nodes and node labels / IDs with "list"\r\nit\'s also possible to do a "open /lab_1/n0/0" command\r\n\r\n\x1b[J\x1b[2K\rconsoles> \n\x1b[J\x1b[2K\rconsoles> o\x1b[J\x1b[2K\rconsoles> op\x1b[J\x1b[2K\rconsoles> ope\x1b[J\x1b[2K\rconsoles> open\x1b[J\x1b[2K\rconsoles> open \x1b[J\x1b[2K\rconsoles> open /\x1b[J\x1b[2K\rconsoles> open /2\x1b[J\x1b[2K\rconsoles> open /2e\x1b[J\x1b[2K\rconsoles> open /2e7\x1b[J\x1b[2K\rconsoles> open /2e7b\x1b[J\x1b[2K\rconsoles> open /2e7ba\x1b[J\x1b[2K\rconsoles> open /2e7baf\x1b[J\x1b[2K\rconsoles> open /2e7baf/\x1b[J\x1b[2K\rconsoles> open /2e7baf/n\x1b[J\x1b[2K\rconsoles> open /2e7baf/n3\x1b[J\x1b[2K\rconsoles> open /2e7baf/n3/\x1b[J\x1b[2K\rconsoles> open /2e7baf/n3/0\x1b[J\x1b[2K\rconsoles> open /2e7baf/n3/0\x1b[J\x1b[2K\rconsoles> open /2e7baf/n3/0\r\nConnecting to console for core-rtr01\r\nConnected to terminalserver.\r\nEscape character is \'^]\'.\r\n\r\n\r\nIMPORTANT:  READ CAREFULLY\r\nWelcome to the Demo Version of Cisco IOS XRv (the "Software").\r\nThe Software is subject to and governed by the terms and conditions\r\nof the End User License Agreement and the Supplemental End User\r\nLicense Agreement accompanying the product, made available at the\r\ntime of your order, or posted on the Cisco website at\r\nwww.cisco.com/go/terms (collectively, the "Agreement").\r\nAs set forth more fully in the Agreement, use of the Software is\r\nstrictly limited to internal use in a non-production environment\r\nsolely for demonstration and evaluation purposes.  Downloading,\r\ninstalling, or using the Software constitutes acceptance of the\r\nAgreement, and you are binding yourself and the business entity\r\nthat you represent to the Agreement.  If you do not agree to all\r\nof the terms of the Agreement, then Cisco is unwilling to license\r\nthe Software to you and (a) you may not download, install or use the\r\nSoftware, and (b) you may return the Software as more fully set forth\r\nin the Agreement.\r\n\r\n\r\nPlease login with any configured user/password, or cisco/cisco\r\n\r\n\r\nUser Access Verification\r\n\r\nUsername: \r\n\rUsername: \r\n\r\r\n\r\nUser Access Verification\r\n\r\nUsername: cisco\r\n\rPassword: \r\n\r\n\r\nRP/0/0/CPU0:core-rtr01#\nterminal length 0\r\n\rSat May  7 04:57:30.507 UTC\r\nRP/0/0/CPU0:core-rtr01#\nterminal width 0\r\n\rSat May  7 04:57:30.917 UTC\r\nRP/0/0/CPU0:core-rtr01#\nconfigure terminal\r\n\rSat May  7 04:57:31.217 UTC\r\nRP/0/0/CPU0:core-rtr01(config)#no logging console\r\n\rRP/0/0/CPU0:core-rtr01(config)#logging console disable\r\n\rRP/0/0/CPU0:core-rtr01(config)#line console\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#exec-timeout 0 0\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#absolute-timeout 0\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#session-timeout 0\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#line default\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#exec-timeout 0 0\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#absolute-timeout 0\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#session-timeout 0\r\n\rRP/0/0/CPU0:core-rtr01(config-line)#commit\r\n\rSat May  7 04:57:32.737 UTC\r\nRP/0/0/CPU0:core-rtr01(config-line)#end\r\n\rRP/0/0/CPU0:core-rtr01#\n'
>>>

この記事が気に入ったらサポートをしてみませんか?