09-18-2021 06:49 PM
Hello,
I am practicing this lab:
https://developer.cisco.com/learning/lab/intro-dnac-cmd-run/step/3
when I run the POST /v1/network-device-poller/cli/read-request to my DNAC, I got the "202 Accepted" message below:
Solved! Go to Solution.
09-18-2021 09:32 PM - edited 09-18-2021 09:34 PM
zhenningx,
The Exercise requires you to run all 3 APIs in order for you to get the results of the command(s) sent to the device(s).
Step 3: Run the first command(s)
In order to run a command there are three API calls required.
1. POST 'dna/intent/api/v1/network-device-poller/cli/read-request' providing a list of commands and deviceId, returns a taskId.
2. GET 'dna/intent/api/v1/task/{taskId}' poll the task until it completes, providing a fileId.
3. GET 'dna/intent/api/v1/file/{fileId}' which returns the results of the commands.
For Example:
------------------------------------------------------------------------------------------
DEVNET: STEP 3 - POST /v1/network-device-poller/cli/read-request
POST
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/dna/intent/api/v1/network-device-poller/cli/read-request
Body:
{
"name" : "show ver",
"commands" :[ "show ver | inc RELEASE" ],
"deviceUuids" :["02699635-1f3d-459c-9212-7a63c29aa25f" ]
}
RESPONSE:
{
"response": {
"taskId": "c8bd1854-8757-4903-b2c7-d53d138b4a22",
"url": "/api/v1/task/c8bd1854-8757-4903-b2c7-d53d138b4a22"
},
"version": "1.0"
}
------------------------------------------------------------------------------------------
DEVNET: STEP 3 - GET /v1/task/{taskId}
GET
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/api/v1/task/c8bd1854-8757-4903-b2c7-d53d138b4a22
RESPONSE:
{
"response": {
"version": 1632025341335,
"startTime": 1632025340814,
"endTime": 1632025341335,
"progress": "{\"fileId\":\"034eecf4-7a71-4ea4-94cc-e3746b29167d\"}",
"username": "tdeleon",
"serviceType": "Command Runner Service",
"rootId": "c8bd1854-8757-4903-b2c7-d53d138b4a22",
"lastUpdate": 1632025341335,
"isError": false,
"instanceTenantId": "5e47482a7a804700bf8be0ed",
"id": "c8bd1854-8757-4903-b2c7-d53d138b4a22"
},
"version": "1.0"
}
------------------------------------------------------------------------------------------
DEVNET: STEP 3 - GET /v1/file{fileId}
GET
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/api/v1/file/034eecf4-7a71-4ea4-94cc-e3746b29167d
RESPONSE:
[{ "deviceUuid":"02699635-1f3d-459c-9212-7a63c29aa25f" ,"commandResponses":{"SUCCESS":{"show ver | inc RELEASE":"show ver | inc RELEASE\nCisco IOS Software [Bengaluru], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 17.6.1, RELEASE SOFTWARE (fc6)\nBOOTLDR: System Bootstrap, Version 17.5.1r, RELEASE SOFTWARE (P)\nV1-FIAB1#"},"FAILURE":{},"BLACKLISTED":{}}}]
Pretty JSON:
[
{
"commandResponses": {
"BLACKLISTED": {},
"FAILURE": {},
"SUCCESS": {
"show ver | inc RELEASE": "show ver | inc RELEASE\nCisco IOS Software [Bengaluru], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 17.6.1, RELEASE SOFTWARE (fc6)\nBOOTLDR: System Bootstrap, Version 17.5.1r, RELEASE SOFTWARE (P)\nV1-FIAB1#"
}
},
"deviceUuid": "02699635-1f3d-459c-9212-7a63c29aa25f"
}
]
------------------------------------------------------------------------------------------
09-18-2021 09:32 PM - edited 09-18-2021 09:34 PM
zhenningx,
The Exercise requires you to run all 3 APIs in order for you to get the results of the command(s) sent to the device(s).
Step 3: Run the first command(s)
In order to run a command there are three API calls required.
1. POST 'dna/intent/api/v1/network-device-poller/cli/read-request' providing a list of commands and deviceId, returns a taskId.
2. GET 'dna/intent/api/v1/task/{taskId}' poll the task until it completes, providing a fileId.
3. GET 'dna/intent/api/v1/file/{fileId}' which returns the results of the commands.
For Example:
------------------------------------------------------------------------------------------
DEVNET: STEP 3 - POST /v1/network-device-poller/cli/read-request
POST
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/dna/intent/api/v1/network-device-poller/cli/read-request
Body:
{
"name" : "show ver",
"commands" :[ "show ver | inc RELEASE" ],
"deviceUuids" :["02699635-1f3d-459c-9212-7a63c29aa25f" ]
}
RESPONSE:
{
"response": {
"taskId": "c8bd1854-8757-4903-b2c7-d53d138b4a22",
"url": "/api/v1/task/c8bd1854-8757-4903-b2c7-d53d138b4a22"
},
"version": "1.0"
}
------------------------------------------------------------------------------------------
DEVNET: STEP 3 - GET /v1/task/{taskId}
GET
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/api/v1/task/c8bd1854-8757-4903-b2c7-d53d138b4a22
RESPONSE:
{
"response": {
"version": 1632025341335,
"startTime": 1632025340814,
"endTime": 1632025341335,
"progress": "{\"fileId\":\"034eecf4-7a71-4ea4-94cc-e3746b29167d\"}",
"username": "tdeleon",
"serviceType": "Command Runner Service",
"rootId": "c8bd1854-8757-4903-b2c7-d53d138b4a22",
"lastUpdate": 1632025341335,
"isError": false,
"instanceTenantId": "5e47482a7a804700bf8be0ed",
"id": "c8bd1854-8757-4903-b2c7-d53d138b4a22"
},
"version": "1.0"
}
------------------------------------------------------------------------------------------
DEVNET: STEP 3 - GET /v1/file{fileId}
GET
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/api/v1/file/034eecf4-7a71-4ea4-94cc-e3746b29167d
RESPONSE:
[{ "deviceUuid":"02699635-1f3d-459c-9212-7a63c29aa25f" ,"commandResponses":{"SUCCESS":{"show ver | inc RELEASE":"show ver | inc RELEASE\nCisco IOS Software [Bengaluru], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 17.6.1, RELEASE SOFTWARE (fc6)\nBOOTLDR: System Bootstrap, Version 17.5.1r, RELEASE SOFTWARE (P)\nV1-FIAB1#"},"FAILURE":{},"BLACKLISTED":{}}}]
Pretty JSON:
[
{
"commandResponses": {
"BLACKLISTED": {},
"FAILURE": {},
"SUCCESS": {
"show ver | inc RELEASE": "show ver | inc RELEASE\nCisco IOS Software [Bengaluru], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 17.6.1, RELEASE SOFTWARE (fc6)\nBOOTLDR: System Bootstrap, Version 17.5.1r, RELEASE SOFTWARE (P)\nV1-FIAB1#"
}
},
"deviceUuid": "02699635-1f3d-459c-9212-7a63c29aa25f"
}
]
------------------------------------------------------------------------------------------
09-19-2021 08:23 AM
Thanks Tomas for the reply! I misunderstood the /v1/network-device-poller/cli/read-request API will return the outputs of the commands. Now I am able to complete this lab!
I still have question how an ordinary user find out what a particular API is supposed to do? For the above API, I checked the doc here: https://developer.cisco.com/docs/dna-center/#!run-read-only-commands-on-devices-to-get-their-real-time-configuration
It only says "Run Read Only Commands On Devices To Get Their Real Time Configuration" which sounds like it is going to return the configuration to me. Where can I find better documents for each of the API?
Also where can I find theshow_command.py script for this lab?
Thanks!
09-19-2021 03:28 PM
Intent API
Cisco DNA Center Platform v. 2.1.2.x
https://developer.cisco.com/docs/dna-center/#%21cisco-dna-2-1-2-x-api-overview
Cisco DNA Center Platform v. 2.2.2.x
https://developer.cisco.com/docs/dna-center/#%21cisco-dna-2-2-2-api-overview
Cisco DNA Center Platform v. 2.2.3.x
https://developer.cisco.com/docs/dna-center/#%21cisco-dna-2-2-3-api-overview
TOTD: New Configuration Archive feature - Export Device configurations to an encrypted zip file
<<attached to response>>
On the Cisco DNA Center itself
{{PROTOCOL}}://{{DNAC.IP.ADDRESS}}/dna/platform/app/consumer-portal/developer-toolkit/apis
09-20-2021 10:34 AM
Thanks Thomas. Do you know where can I find the "show_command.py" script mentioned in this lab?
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