03-08-2022 07:14 AM
Hello, I am using the command runner code here: https://github.com/CiscoDevNet/dne-dna-code/blob/master/intro-dnac/04_Cmd_Runner/cmd_runner.py
It can get the command output but it finishes with an error as below. If I am trying to run this with multiple switches, it can only get the output for the first switch and then stops with the error. Any ideas? Thanks!
hostname id
S1743 1025e9d4-45ce-46b2-85ef-def4a9d9b990
executing ios command --> show ver | inc RELEASE
Command runner Initiated! Task ID --> bbbab842-8c68-42ab-9e3d-e800c754b763
Retrieving Path Trace Results....
File ID --> 63a0f84d-4bc9-42a8-98df-1baab25c454b
{'SUCCESS': {'show ver | inc RELEASE': 'show ver | inc RELEASE\nCisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.8, RELEASE SOFTWARE (fc4)\nBOOTLDR: System Bootstrap, Version 16.9.1r[FC3], RELEASE SOFTWARE (P)\nS1743#'}, 'FAILURE': {}, 'BLACKLISTED': {}}
Traceback (most recent call last):
File "C:\Python Codes\command_runner_bulk_device.py", line 112, in <module>
get_device_list()
File "C:\Python Codes\command_runner_bulk_device.py", line 63, in get_device_list
initiate_cmd_runner(token,device['id']) # initiate command runner
File "C:\Python Codes\command_runner_bulk_device.py", line 82, in initiate_cmd_runner
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 98, in get_task_info
get_task_info(task_id, token)
File "C:\Python Codes\command_runner_bulk_device.py", line 99, in get_task_info
get_cmd_output(token, file_id)
File "C:\Python Codes\command_runner_bulk_device.py", line 108, in get_cmd_output
print(cmd_result.json()[0]["commandResponses"])
KeyError: 0
Solved! Go to Solution.
03-21-2022 01:35 PM
@zhenningx awesome!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide