Commit Configuration

The panxapi.py -C cmd option performs the type=commit API request to commit the candidate configuration. The commit options are specified with the cmd argument, which is an XML document (the default is <commit/>).

The commit operation is performed asynchronously (as a management server job). To simulate a synchronous commit by waiting for job completion use the –sync option.

Example: Perform Synchronous commit

Warning

Don’t execute the commit right now; you will perform a commit in the lab below.

$ panxapi.py -C '' --sync
commit: success: "Configuration committed successfully"

Note

When no cmd argument is used you must specify a null string.

Lab 9

  1. Compare the output of the get and show requests for group1 to confirm candidate and active configuration are different.

  2. Use panxapi.py to commit the candidate configuration with the changes from the previous labs.

  3. Compare the output of the get and show requests to confirm candidate and active configuration are the same.

  4. Attempt to commit again.

Solution

$ XPATH="/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/address-group/entry[@name='group1']"

$ panxapi.py -sr $XPATH
show: success
<entry name="group1">
  <static>
    <member>addr1</member>
    <member>addr2</member>
    <member>addr3</member>
  </static>
</entry>

$ panxapi.py -gr $XPATH
get: success [code="19"]
  <entry admin="admin" dirtyId="4" name="group1" time="2018/04/14 08:55:19">
    <static admin="admin" dirtyId="4" time="2018/04/14 08:55:19">
      <member admin="admin" dirtyId="4" time="2018/04/14 08:55:19">addr1</member>
      <member admin="admin" dirtyId="4" time="2018/04/14 08:55:19">addr2</member>
      <member admin="admin" dirtyId="4" time="2018/04/14 08:55:19">addr3</member>
      <member admin="admin" dirtyId="4" time="2018/04/14 08:55:19">addr4</member>
      <member admin="admin" dirtyId="4" time="2018/04/14 08:55:19">addr5</member>
    </static>
  </entry>

$ panxapi.py -C '' --sync
commit: success: "Configuration committed successfully"

$ panxapi.py -sr $XPATH
show: success
<entry name="group1">
  <static>
    <member>addr1</member>
    <member>addr2</member>
    <member>addr3</member>
    <member>addr4</member>
    <member>addr5</member>
  </static>
</entry>

$ panxapi.py -gr $XPATH
get: success [code="19"]
  <entry name="group1">
    <static>
      <member>addr1</member>
      <member>addr2</member>
      <member>addr3</member>
      <member>addr4</member>
      <member>addr5</member>
    </static>
  </entry>

$ panxapi.py -C '' --sync
commit: success [code="19"]: "There are no changes to commit."