cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3595
Views
5
Helpful
4
Replies

DNA Lab Question

zhenningx
Level 4
Level 4

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:

 

{
    "response": {
        "taskId""42b4a062-2341-428f-ab97-23ad0e92d264",
        "url""/api/v1/task/42b4a062-2341-428f-ab97-23ad0e92d264"
    },
    "version""1.0"
}
 
My payload is:
 "name" : "show ver",
 "commands" : ["show ver | inc RELEASE"],
 "deviceUuids" : [ "{{deviceId}}"]
}
 
Any ideas why I got the 202 reply, not the 200 reply with the show version command result?
 
Thanks!
 
1 Accepted Solution

Accepted Solutions

Tomas de Leon
Cisco Employee
Cisco Employee

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"
}
]

------------------------------------------------------------------------------------------

 

View solution in original post

4 Replies 4

Tomas de Leon
Cisco Employee
Cisco Employee

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"
}
]

------------------------------------------------------------------------------------------

 

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!

 

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

Thanks Thomas. Do you know where can I find the "show_command.py" script mentioned in this lab?