How to Configure the Management Interface IP via API

Reply
L1 Bithead

How to Configure the Management Interface IP via API

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?

 

L4 Transporter

Re: How to Configure the Management Interface IP via API

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>"
L1 Bithead

Re: How to Configure the Management Interface IP via API

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.

L3 Networker

Re: How to Configure the Management Interface IP via API

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>

L1 Bithead

Re: How to Configure the Management Interface IP via API

That was it.  Thanks ksteves1

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 Live Community as a whole!

The Live Community thanks you for your participation!