How to Configure the Management Interface IP via API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

How to Configure the Management Interface IP via API

L1 Bithead

Trying to automate a task of configuring the management interface of a firewall device through the API.  I see where the API's leading for the configuration, but I'm stumped as to how to edit/set the IP.

 

Example. using Powershell:

 

$Firewall = https://firewall

$apiKey = apikey

$ipaddress = x.x.x.x

 

 

$content1 = Invoke-RestMethod "$Firewall/api/?type=config&key=$apiKey&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/ip-address/member[@name='$ipaddress']"

How would I proceed with setting the $ipaddress I need to the location?

 

1 accepted solution

Accepted Solutions

The XPath cannot end in slash.  For example:

 

$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/"
set: error [code="13"]: "set failed, may need to override template object first"
<response code="13" status="error"><msg><line>set failed, may need to override template object first</line></msg></response>

$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system"
set: success [code="20"]: "command succeeded"
<response code="20" status="success"><msg>command succeeded</msg></response>

View solution in original post

4 REPLIES 4

L4 Transporter

I think you need to include the "element=" for the value you want to set:

 

For example somehting like this:

 

$content1 = Invoke-RestMethod "$Firewall/api/?type=config&key=$apiKey&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/&element=<ip-address>$ipaddress</ip-address>"

I've played around with the element approach from both /deviceconfig/system and /deviceconfig/system/ipaddress.

 

Unfortunately, I'm not having any luck on it.

The XPath cannot end in slash.  For example:

 

$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/"
set: error [code="13"]: "set failed, may need to override template object first"
<response code="13" status="error"><msg><line>set failed, may need to override template object first</line></msg></response>

$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system"
set: success [code="20"]: "command succeeded"
<response code="20" status="success"><msg>command succeeded</msg></response>

That was it.  Thanks ksteves1

  • 1 accepted solution
  • 5627 Views
  • 4 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!