<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create a new IP address on a specific interface in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75492#M1212</link>
    <description>&lt;P&gt;When using 'set', the element should not contain the end of the xpath (you don't need the &amp;lt;ip&amp;gt;&amp;lt;/ip&amp;gt; part of the element). &amp;nbsp;This is only needed when using 'edit'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you're missing the layer3 element in the xpath.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;xpath&lt;/STRONG&gt; should end with: &amp;nbsp; entry[@name='ethernet1/1']/layer3/ip&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;element&lt;/STRONG&gt; should be: &amp;nbsp; &amp;lt;entry name='x.x.x.x/x'/&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here are a few examples of setting an ip address on ethernet1/1 using the API:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;With a browser:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;https://&amp;lt;fw ip&amp;gt;/api?key=&amp;lt;apikey&amp;gt;&amp;amp;type=config&amp;amp;action=set&amp;amp;xpath=/config/devices/entry[@name='localhost.localdomain']/network/interface/ethernet/entry[@name='ethernet1/1']/layer3/ip&amp;amp;element=&amp;lt;entry name='5.5.5.5/24'/&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;With pan-python&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pan-python is available here: &amp;nbsp;&lt;A href="https://github.com/kevinsteves/pan-python" target="_blank"&gt;https://github.com/kevinsteves/pan-python&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pan-python abstracts out much of the API into simple parameters on a command line or python script. &amp;nbsp;It also handles encoding and other 'under-the-hood' complexity for you. &amp;nbsp;On a linux CLI, with pan-python installed, you can make the same API call like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;panxapi.py -h &amp;lt;fw ip&amp;gt; -K &amp;lt;apikey&amp;gt; -S "&amp;lt;entry name='5.5.5.5/24'/&amp;gt;" "/config/devices/entry/network/interface/ethernet/entry[@name='ethernet1/3']/layer3/ip"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;With pandevice framework (python SDK):&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pandevice is available here: &amp;nbsp;&lt;A href="https://github.com/PaloAltoNetworks/pandevice" target="_blank"&gt;https://github.com/PaloAltoNetworks/pandevice&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a python SDK that allows you to interact with the API at an object level. &amp;nbsp;No XPath or XML is required. &amp;nbsp;pandevice is also natively vsys and HA aware.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This example accomplishes the same thing, but using objects in python without XPaths or XML:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;from pandevice import firewall, network
fw = firewall.Firewall("&amp;lt;fw ip&amp;gt;", "admin", "password")
fw.add(network.EthernetInterface("ethernet1/1", ip="5.5.5.5/24")).create()&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2016 19:17:45 GMT</pubDate>
    <dc:creator>btorresgil</dc:creator>
    <dc:date>2016-03-30T19:17:45Z</dc:date>
    <item>
      <title>Create a new IP address on a specific interface</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75479#M1210</link>
      <description>&lt;P&gt;I would like to create a new IP address on an interface with xml api. I tried different requests but no one worked.&lt;/P&gt;
&lt;P&gt;I tried to use config set wiht the xpath which ended to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[@name='interface']/ip and after &amp;amp;element=&amp;lt;ip&amp;gt;&amp;lt;entry name="x.x.x.x/x"/&amp;gt;&amp;lt;/ip&amp;gt; and similar settings but the response is always '406 Not Acceptable'.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 16:57:45 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75479#M1210</guid>
      <dc:creator>NemethGyorgy</dc:creator>
      <dc:date>2016-03-30T16:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new IP address on a specific interface</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75492#M1212</link>
      <description>&lt;P&gt;When using 'set', the element should not contain the end of the xpath (you don't need the &amp;lt;ip&amp;gt;&amp;lt;/ip&amp;gt; part of the element). &amp;nbsp;This is only needed when using 'edit'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you're missing the layer3 element in the xpath.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;xpath&lt;/STRONG&gt; should end with: &amp;nbsp; entry[@name='ethernet1/1']/layer3/ip&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;element&lt;/STRONG&gt; should be: &amp;nbsp; &amp;lt;entry name='x.x.x.x/x'/&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here are a few examples of setting an ip address on ethernet1/1 using the API:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;With a browser:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;https://&amp;lt;fw ip&amp;gt;/api?key=&amp;lt;apikey&amp;gt;&amp;amp;type=config&amp;amp;action=set&amp;amp;xpath=/config/devices/entry[@name='localhost.localdomain']/network/interface/ethernet/entry[@name='ethernet1/1']/layer3/ip&amp;amp;element=&amp;lt;entry name='5.5.5.5/24'/&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;With pan-python&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pan-python is available here: &amp;nbsp;&lt;A href="https://github.com/kevinsteves/pan-python" target="_blank"&gt;https://github.com/kevinsteves/pan-python&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pan-python abstracts out much of the API into simple parameters on a command line or python script. &amp;nbsp;It also handles encoding and other 'under-the-hood' complexity for you. &amp;nbsp;On a linux CLI, with pan-python installed, you can make the same API call like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;panxapi.py -h &amp;lt;fw ip&amp;gt; -K &amp;lt;apikey&amp;gt; -S "&amp;lt;entry name='5.5.5.5/24'/&amp;gt;" "/config/devices/entry/network/interface/ethernet/entry[@name='ethernet1/3']/layer3/ip"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;With pandevice framework (python SDK):&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pandevice is available here: &amp;nbsp;&lt;A href="https://github.com/PaloAltoNetworks/pandevice" target="_blank"&gt;https://github.com/PaloAltoNetworks/pandevice&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a python SDK that allows you to interact with the API at an object level. &amp;nbsp;No XPath or XML is required. &amp;nbsp;pandevice is also natively vsys and HA aware.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This example accomplishes the same thing, but using objects in python without XPaths or XML:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;from pandevice import firewall, network
fw = firewall.Firewall("&amp;lt;fw ip&amp;gt;", "admin", "password")
fw.add(network.EthernetInterface("ethernet1/1", ip="5.5.5.5/24")).create()&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 19:17:45 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75492#M1212</guid>
      <dc:creator>btorresgil</dc:creator>
      <dc:date>2016-03-30T19:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new IP address on a specific interface</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75547#M1213</link>
      <description>&lt;P&gt;The things are a bit more complicated but I didn't write all details. We use Panorama, and the interface is a subinterface of an aggregate interface. But I tried the similar way. The current request is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/api/?type=config&amp;amp;action=set&amp;amp;key=myapikey&amp;amp;xpath=/config/devices/entry[@name='localhost.localdomain']/template/entry[@name='templatename']/config/devices/entry[@name='localhost.localdomain']/network/interface/aggregate-ethernet/entry[@name='ae6']/layer3/units/entry[@name='ae6.16']/ip&amp;amp;element=&amp;lt;entry name='10.20.30.40/24'/&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I get&amp;nbsp;406 Not Acceptable&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 10:21:55 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/create-a-new-ip-address-on-a-specific-interface/m-p/75547#M1213</guid>
      <dc:creator>NemethGyorgy</dc:creator>
      <dc:date>2016-03-31T10:21:55Z</dc:date>
    </item>
  </channel>
</rss>

