cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1666
Views
5
Helpful
6
Replies

Prime Infrastructure deploy to devices based on a list

Energia
Level 1
Level 1

Hi, I do need to deploy two lines of config to a few hundred network devices. The devices do exist in Prime, but I only want to deploy the config to a portion of the devices. 
I have have a list (csv) with the IP-addresses of the devices, is it possible to deploy the config based on the list through Prime?

6 Replies 6

marce1000
VIP
VIP

 - Presumably not as seen from the link below :

https://www.cisco.com/c/en/us/td/docs/net_mgmt/prime/infrastructure/3-1/user/guide/pi_ug/config-temp.html#18352

  - I don't think it's possible to import a list as a 'change target' ; if someone found workarounds; glad to here.

M.



-- ' 'Good body every evening' ' this sentence was once spotted on a logo at the entrance of a Weight Watchers Club !

Bill Longman
Cisco Employee
Cisco Employee

You could do this with the NBI. From your CSV, which I'm assuming is just the IP addresses of the devices you want to update, you will need to determine the device ID.

 

for ip in $(cat ipAddress.csv)

do

  curl -k -u username:password https://$piHost/webacs/api/v1/data/Devices?ipAddress="$ip"| grep Devices/

done > deviceIdList.txt

 

From that list you can turn it into the body of the XML that you need to send in the second step. It needs to look like this:

 

<?xml version="1.0" encoding="UTF-8"?>
<cliTemplateCommand>
<targetDevices>
<targetDevice>
<targetDeviceID>17942377</targetDeviceID>
</targetDevice>
<targetDevice>
<targetDeviceID>17942378</targetDeviceID>
</targetDevice>
<targetDevice>
<targetDeviceID>17942379</targetDeviceID>
</targetDevice>
<targetDevice>
<targetDeviceID>17942380</targetDeviceID>
</targetDevice>
</targetDevices>
<templateName>TmpltNmGoesHr</templateName>
</cliTemplateCommand>

 

Then use that to PUT the XML file. Once you do that, it will apply the template to those devices.

curl -k -u username:password -X PUT \
https://$piHost/webacs/api/v1/op/cliTemplateConfiguration/deployTemplateThroughJob \
-H 'content-type: text/xml' -d @deviceListTemplate.xml

 

 

This assumes, of course, that you have already created a template for the command lines that you want to deploy.

 

The other assumption that I made was that the template does not have any parameters. If you need to send parameters to the template for each device, that's a bit different.

 

For help with using templates and the NBI, consult the /nbi_help page for details on what you need to send in the various NBI calls.

 

With curl and the shell, you can get pretty far. You can get even further with some real Python behind it.

 

 - I do acknowlegde the technical knowledge of your answers but in the end the product should evolve to include such tasks automatically for the requested functionality ; which would create great added value. It's a bit like having a banking app and saying : 'but if you need to transfer money to a series of multiple recipients simultaniously , you need to learn Fortran first!

M.



-- ' 'Good body every evening' ' this sentence was once spotted on a logo at the entrance of a Weight Watchers Club !

Hold on...it's not like it cannot be done without programming. The problem as stated was that the IP addresses of the devices to manage were in a CSV file. You can just as easily recreate that "CSV file" by creating a user defined group and then running the template against that group. No programming required.

Thanks!
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: