cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1202
Views
12
Helpful
4
Replies

Adding a device in Managed state

smp
Level 4
Level 4

I developed some code to add devices using the PUT Bulk Import API back on product version 3.0. I just started testing that code with version 3.1 of the product where I discovered a new Admin State property. When I add a device with the API, it is always added in the Un-Managed state. As a consequence, none of the properties of the device are discovered.

Is there a way to add a device in a Managed state with the API? If not, is there an API call I can make to change the Admin State from Un-Managed to Managed?

1 Accepted Solution

Accepted Solutions

Spencer Zier
Cisco Employee
Cisco Employee

This service behaves like the bulk import option available in the UI.  After providing the names, addresses, and credentials a job is created.  That job moves to successful completion once all of the devices are added.  Once a device is added, Prime Infrastructure will attempt to connect to the device, collect inventory, and manage it.  If this is successful, the device's admin status will move from Un-Managed to Managed.  However, if the device is unreachable, if the credentials are incorrect, or the device is unresponsive, it will remain in the Un-Managed state.

To programmatically check the device's state, you can access the data/Devices resource.  The managementStatus response parameter will show MANAGED_AND_SYNCHRONIZED and the reachability response parameter will show REACHABLE when it's successful.  Otherwise, it could show MANAGED_BUT_CONFLICTINGCREDENTIALS or some other management state, and the collectionDetail response parameter will show the reason.  For example, I initiated a job via the API to add two devices, one being a reachable device with all the correct credentials, the other being reachable but I specified some of the wrong credentials.  For the first, it has a Managed admin status in the UI and shows as MANAGED_AND_SYNCHRONIZED via the UI.  For the second, the UI shows Un-Managed, and the API shows the collectionDetail as "CLI Failure: Invalid Enable password."

View solution in original post

4 Replies 4

Spencer Zier
Cisco Employee
Cisco Employee

This service behaves like the bulk import option available in the UI.  After providing the names, addresses, and credentials a job is created.  That job moves to successful completion once all of the devices are added.  Once a device is added, Prime Infrastructure will attempt to connect to the device, collect inventory, and manage it.  If this is successful, the device's admin status will move from Un-Managed to Managed.  However, if the device is unreachable, if the credentials are incorrect, or the device is unresponsive, it will remain in the Un-Managed state.

To programmatically check the device's state, you can access the data/Devices resource.  The managementStatus response parameter will show MANAGED_AND_SYNCHRONIZED and the reachability response parameter will show REACHABLE when it's successful.  Otherwise, it could show MANAGED_BUT_CONFLICTINGCREDENTIALS or some other management state, and the collectionDetail response parameter will show the reason.  For example, I initiated a job via the API to add two devices, one being a reachable device with all the correct credentials, the other being reachable but I specified some of the wrong credentials.  For the first, it has a Managed admin status in the UI and shows as MANAGED_AND_SYNCHRONIZED via the UI.  For the second, the UI shows Un-Managed, and the API shows the collectionDetail as "CLI Failure: Invalid Enable password."

Thanks again for the reply Spencer. It turned out that I am testing my code against our test instance of PI which has consumed all our licenses in that environment, so none of the collections are taking place. But I only figured this out by looking at the collectionDetail status of the device as you suggested.

The frustrating part about this is that nowhere in the product GUI was I able to find this answer. The only way I could find that answer is with the API, which many customers will not know how to do.

In any case, thanks again for your reply and insight. You have been really great for this community.

You should be able to see this in the UI as well.  In the Device Work Center (or what used to be called the Device Work Center, Inventory > Device Management > Network Devices), there's a collection status column that show the same information that the API response parameter does.  You just have to click the little info icon.  I don't have an instance with license limitations, but here's an example of a different type of collection failure.

collection_status.png

That column was outside my visible view.

Sorry about that!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: