- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
12-28-2018 10:32 AM
Hi,
I've been trying to tailor two API calls for adding managed device to a template in panorama and override template variable for for the specific device.
Looking at the API browser I get the following which throws error message with curl.
# Add device to template stack
curl -k -X GET "https://<panorama>/api/?type=op&key=<my_key>=&xpath=/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='test-template']/devices/entry[@name='111111111111111']/>"
#Override variabes for specific device
curl -k -X GET "https://<panorama>/api/?type=config&action=get&xpath=/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='test-template']/devices/entry[@name='111111111111111']/variable" cookie="1234567890" override="yes"><entry name="$subnet"><type><ip-netmask>192.168.1.0/24</ip-netmask></type></entry></request>"
I was hoping that some one can point me in the right direction on how the API should look like.
01-07-2019 01:48 PM
Figured the first part:
curl -k -g "https://panorama/api/?type=config&action=set&key=my_key/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='TEST']/devices&element=<entry%20name='111111111111111'/>"
Still batling with how to override the variable:
Here is what I'm using for xpath:
xpath=/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='TEST']/devices/entry[@name='111111111111111']/variable/entry[@name='$Variable1']/type/ip-netmask&element=<member name='10.10.10.0/24'/>"
I'm getting "bad xpath"
01-08-2019 08:30 AM
If you're doing a set
because $Variable1
doesn't already exist, then this should be what you do:
type=config
action=set
key=(your_key_here)
xpath=/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='(your_name_here)']/variable
element=<entry name='$Variable1'><type><ip-netmask>10.10.10.0/24</ip-netmask></type></entry>
If the variable $Variable1
already exists, you'll want to do an EDIT instead of SET. So in the above:
1) action
should be edit
instead of set
2) xpath should have the following added on to the end: /entry[@name='$Variable1']
That should do it I think.
01-08-2019 09:53 AM
I'm doing override as the varibale already exists in the template.
I just fixed it, here is the API call.
https://panorama/api/?type=config&action=set&key=my_key&xpath=/config/devices/entry[@name='localhost.localdomain']/template-stack/entry[@name='TEST']/devices/entry[@name='1111111111']/variable&element=<entry name='$Variable1'><type><ip-netmask>10.10.10.0/24</ip-netmask></type></entry>"
I did use Postman to do get call as curl tends to have issues with spaces and special characters.
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!