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 ````).
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
-----
#. Compare the output of the *get* and *show* requests for
``group1`` to confirm *candidate* and *active* configuration
are different.
#. Use **panxapi.py** to commit the *candidate* configuration with
the changes from the previous labs.
#. Compare the output of the *get* and *show* requests to confirm
*candidate* and *active* configuration are the same.
#. Attempt to commit again.
.. admonition:: Solution
:class: toggle
::
$ XPATH="/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/address-group/entry[@name='group1']"
$ panxapi.py -sr $XPATH
show: success
addr1
addr2
addr3
$ panxapi.py -gr $XPATH
get: success [code="19"]
addr1
addr2
addr3
addr4
addr5
$ panxapi.py -C '' --sync
commit: success: "Configuration committed successfully"
$ panxapi.py -sr $XPATH
show: success
addr1
addr2
addr3
addr4
addr5
$ panxapi.py -gr $XPATH
get: success [code="19"]
addr1
addr2
addr3
addr4
addr5
$ panxapi.py -C '' --sync
commit: success [code="19"]: "There are no changes to commit."