dne-dna-code icon indicating copy to clipboard operation
dne-dna-code copied to clipboard

intro-dnac/cmd-run/show_command.py fails to execute with traceback in observer ('devnetuser') role.

Open JoelRiglerIG opened this issue 5 years ago • 1 comments
trafficstars

Traceback:

(venv) JRIGLER-M-G5SZ:intro-dnac jrigler$ ./cmd-run/show_command.py Traceback (most recent call last): File "./cmd-run/show_command.py", line 112, in <module> results_fileId = execute_commands(token, deviceIdList, commandList) File "./cmd-run/show_command.py", line 47, in execute_commands task_result = post_and_wait(token,url, payload) File "./cmd-run/show_command.py", line 25, in post_and_wait taskid = response.json()['response']['taskId'] KeyError: 'response'

Associated code line (line 25):

taskid = response.json()['response']['taskId']

when parsing response from '/v1/network-device-poller/cli/read-request'.

Running as 'devnetuser' against Always On SandBox (1.2.6) (
* URL: https://sandboxdnac.cisco.com/ * Username: devnetuser
* Password: Cisco123! )

Executing with same credentials in POSTMAN returns results: HTTP Status: 403 Forbidden and { "message": "Role does not have valid permissions to access the API" }

This sample code is used in Learning Lab "Execute Commands Across the Network with Cisco DNA Center Platform and Command Runner", so should not fail - with traceback but should handle invalid role.

JoelRiglerIG avatar Dec 13 '19 21:12 JoelRiglerIG

@JoelRiglerIG seems like this was fixed in commit 276c8a75e8f7ab4b64b2102a1b64ad162dbf4411

/dne-dna-code/intro-dnac/04_Cmd_Runner# python cmd_runner.py 
hostname                 id                       
3504_WLC                 72dc1f0a-e4da-4ec3-a055-822416894dd5
AAA                      3dd27ed6-44f9-486d-abaf-a779781431a0
leaf2.abc.inc            5bc5b967-3f83-4195-891c-788f3e9048f3
spine1.abc.inc           2f0b7d3b-c9e1-491e-a584-f272b5403719

robertcsapo avatar Sep 11 '20 15:09 robertcsapo