- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
06-14-2012 12:12 PM
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>
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!