API calls to add managed device to panorama template and override variables.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

API calls to add managed device to panorama template and override variables.

L1 Bithead

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.

 

 

3 REPLIES 3

L1 Bithead

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"

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.

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.

  • 3495 Views
  • 3 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!