- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
06-11-2020 01:03 PM
Greetings,
I use Template Stacks with variables a lot for firewalls with the same hardware and network settings.
To assign the value of a variable, I go to the template stack and export the variable CSV file. I modify the file with the values for my firewall and import the CSV file.
This is all good, but I would like to automate this via API.
Via the API I can add new variables to my Templates, but this is not what I want to do. I want to add the values to the variables for the NGFW devices assigned to the Template Stack.
I just can't figure out how to add values to the devices in my templates.
I would even be ok with exporting the variable CSV via API, have my script modify the CSV, (add the values in the appropriate sections), and then import the CSV via API, but once again, I can't find where you can export the variables CSV. I can export all kinds of other items, but not this.
I am doing my scripting in python with the pandevice module.
Thanks.
05-12-2021 10:40 AM
Hi @mrzepa2 @grchew,
Does this help, for the example of a variable which is an IP address?
https://{{host}}/api/?key={{key}}&type=config&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='{{template-stack-name}}']/devices/entry[@name='{{serial-number}}']/variable&element=<entry name="{{var-name}}"><type><ip-netmask>{{object-ip-1}}</ip-netmask></type></entry>
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!