using panxapi to update a custom-url-category profile from a file

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.

using panxapi to update a custom-url-category profile from a file

L3 Networker

Here's an example of using the panxapi program and some simple
scripting to update a custom-url-category profile from a file of URLs.

If you have an existing URL category:

$ panxapi -t pa-200 -gxr "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='url1']"
get: success
<entry name="url1"><description>custom url1</description></entry>

and you want to periodically update it to contain URLs from a file:

$ cat url1.txt
u1.com
u2.com
u3.com

$ perl -e 'print "<list>\n";while(<>){chomp;print "<member>$_</member>\n"}print "</list>\n"' <url1.txt>url1.xml

$ cat url1.xml
<list>
<member>u1.com</member>
<member>u2.com</member>
<member>u3.com</member>
</list>

$ panxapi -t pa-200 -e ./url1.xml -C '<commit></commit>' "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='url1']/list"
edit: success: command succeeded
commit: success: Commit job enqueued with jobid 21

$ panxapi -t pa-200 -gxr "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='url1']"
get: success
<entry name="url1"><description>custom url1</description><list><member>u1.com</member><member>u2.com</member><member>u3.com</member></list></entry>

then let's say we have a changed list where u2 is deleted and u4 is added:

$ cat url1.txt
u1.com
u3.com
u4.com

$ perl -e 'print "<list>\n";while(<>){chomp;print "<member>$_</member>\n"}print "</list>\n"' <url1.txt>url1.xml

$ cat url1.xml
<list>
<member>u1.com</member>
<member>u3.com</member>
<member>u4.com</member>
</list>

$ panxapi -t pa-200 -e ./url1.xml -C '<commit></commit>' "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='url1']/list"
edit: success: command succeeded
commit: success: Commit job enqueued with jobid 22

$ panxapi -t pa-200 -gxr "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='url1']"
get: success
<entry name="url1"><description>custom url1</description><list><member>u1.com</member><member>u3.com</member><member>u4.com</member></list></entry>

0 REPLIES 0
  • 2357 Views
  • 0 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!