cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
549
Views
5
Helpful
7
Replies

Creating a PNP device in a project through API

I have a python application that runs incrementally to check for unplanned devices and depending on what hardware platform, and how many ports the device has it pulls the serial number and creates a device within a project. That piece works well however I am having issues with the configId and imageId that are being sent to APIC EM through the API. If I put the text string for either in the API data it will appear on the web GUI correctly but fail to complete. If I reference the ID obtained through the API call to the configuration or images it will instead list that as a string value in the GUI, and also fail. Is there a specific format or process that I should be using to find these values?

Everyone's tags (3)
7 REPLIES 7
Beginner

Re: Creating a PNP device in a project through API

In APIC-EM, after the image and config name appear in the gui and then the image fails. Can you click on status and post an image of what the steps the status has gone through up to the failure?

Highlighted

Re: Creating a PNP device in a project through API

Brennan,

Dave is out of Texas and has been working with APIC-EM and has lots of programming experience. If we can figure out a time he is available, we might be able to get to the bottom of this whether it is a matter of order of operations, syntax, or a bug.

Philip

Cisco Employee

Re: Creating a PNP device in a project through API

Take a look at my blog post, it shows how to use "configId".  Network Automation with Plug and Play (PnP) – Part 2

Both "configId" and "imageId" are 32 character UUID, and should be passed as strings.

You PUT body should be something like this:

[{

        "serialNumber": "12345678901",

        "platformId": "C2960X",

        "hostName": "syd-sw2",

        "pkiEnabled": true,

        "configId": "d300a372-ce55-4b02-9aac-b49e9c0d6e20"

        "id" : "projectDeviceId"

}]

Can you include a screenshot to show the completed rule?

Maybe even some debugs from your script to show the data you are sending to the PUT API call (and the URL)

Adam

Re: Creating a PNP device in a project through API

Hi Adam,

Please see the requests below:

Create Device Sent:

[{

    "platformId": "WS-C3650-48PD",

    "hostName": "Superswitch" ,

    "configId": "58792682-97d0-4ae7-9fae-7217ab1dfb81",

  }

  ]

Recieved:

202 Accepted

{

    "response": {

        "taskId": "b748d0a9-7fb8-4bc8-a172-6d44d05fe62e",

        "url": "/api/v1/task/b748d0a9-7fb8-4bc8-a172-6d44d05fe62e"

    },

    "version": "1.0"

}

RESPONSE_WITH_ERROR


History Info

TimestampEvent
2017-06-23 13:47:26 (Pacific Daylight Time)Received response from pnp agent for message correlatorId: CiscoPnP-1.0-16-453-FFA6C46210-16 but with error code : ZTD_CMD_ERROR Response String: ERROR:PnP Service Error 1416:Invalid source file for running config upgrade service log: 
2017-06-23 13:41:34 (Pacific Daylight Time)Matched a pre-provisioned device in site Pre-Build
2017-06-23 13:40:28 (Pacific Daylight Time)Matched a pre-provisioned rule in site Pre-Build
2017-06-23 13:39:56 (Pacific Daylight Time)Received new work request from Agent while expecting work response. Retrying operation FILESYSTEM_INFO_REQUESTED
2017-06-23 13:39:37 (Pacific Daylight Time)Device authentication status has changed to None
2017-06-23 13:39:37 (Pacific Daylight Time)Device first contact
Beginner

Re: Creating a PNP device in a project through API

If you manually add the config in the GUI instead of using the API to add the config, does it push the image successfully?

Also, are you getting the 32 character string that refers to the config you want to attach in a previous part of your script before POSTing it back? I am wondering if the string has changed for some reason from when you got it vs. when you send it back - that would be unlikely if you GET it 2 seconds before you POST it.

Cisco Employee

Re: Creating a PNP device in a project through API

Thanks.

Is the config file saved in the config datastore?

Sent from my iPhone

Cisco Employee

Re: Creating a PNP device in a project through API

Further to above comment.

If you do a GET of https://<apic-ip>/api/v1/file/namespace/config

you should see a list of file entries. 

Can I have a look at the one for configId "58792682-97d0-4ae7-9fae-7217ab1dfb81".  It will appear as the "id"

For example, mine looks like this ("id": "032cbf1a-7754-4e3c-b7a8-e4494060b198")

{ "nameSpace": "config",

"name": "3650-IWAN-dns.txt",

"downloadPath": "/file/032cbf1a-7754-4e3c-b7a8-e4494060b198",

"fileSize": "457",

"fileFormat": "text/plain",

"md5Checksum": "caaef9007391476913d958315a40e335", "sha1Checksum": "cb89a0c994df16cad9ee431f08d1073c17314f84",

"id": "032cbf1a-7754-4e3c-b7a8-e4494060b198" },

Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.