Skip to content

Commit

Permalink
Support vsys for import_file().
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsteves committed Jan 5, 2024
1 parent 5271e97 commit ffcb73e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion bin/panxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ def main():
action = 'import'
if options['ad_hoc'] is not None:
extra_qs_used = True
vsys = options['vsys'][0] if len(options['vsys']) else None
xapi.import_file(category=options['import'],
file=options['file'],
filename=options['name'],
vsys=vsys,
extra_qs=options['ad_hoc'])
print_status(xapi, action)
print_response(xapi, options)
Expand Down Expand Up @@ -903,7 +905,7 @@ def usage():
--file path import file path
--strict yes|no multi-config strict-transactional
--vsys vsys VSYS for dynamic update/partial commit/
operational command/report
operational command/report/import
-l api_username[:api_password]
-h hostname
-P port URL port number
Expand Down
7 changes: 5 additions & 2 deletions doc/pan.xapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ Threat PCAP export
exporting from firewall devices, however this requirement will be
removed in a future version of PAN-OS.

import_file(category=None, file=None, filename=None)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import_file(category=None, file=None, filename=None, vsys=None)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The import_file() method performs the ``type=import`` import file API
request with the **category** argument.
Expand All @@ -460,6 +460,9 @@ import_file(category=None, file=None, filename=None)
the ``Content-Disposition`` header. If **filename** is not specified
and **file** specifies a path, the basename of the path is used.

The **vsys** argument is used to set the location to a specific
Virtual System.

log(self, log_type=None, nlogs=None, skip=None, filter=None, interval=None, timeout=None)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
9 changes: 6 additions & 3 deletions doc/panxapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SYNOPSIS
--file path import file path
--strict yes|no multi-config strict-transactional
--vsys vsys VSYS for dynamic update/partial commit/
operational command/report
operational command/report/import
-l api_username[:api_password]
-h hostname
-P port URL port number
Expand Down Expand Up @@ -276,6 +276,9 @@ DESCRIPTION

The **--name** option is used to specify the file name.

The **--vsys** option is used to set the location to a specific
Virtual System.

The **--ad-hoc** option is used to specify additional import
arguments, for example:

Expand Down Expand Up @@ -408,8 +411,8 @@ DESCRIPTION

``--vsys`` *vsys*
Specify optional **vsys** for dynamic update (**-U**), partial vsys
commit (**--partial** vsys), commit-all (**-A**) and operational
commands (**-o**).
commit (**--partial** vsys), commit-all (**-A**), operational
commands (**-o**) and import (**--import**).

*vsys* can be specified using name (**vsys2**) or number (**2**).

Expand Down
3 changes: 3 additions & 0 deletions lib/pan/xapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ def import_file(self,
category=None,
file=None,
filename=None,
vsys=None,
extra_qs=None):
self.__set_api_key()
self.__clear_response()
Expand All @@ -1052,6 +1053,8 @@ def import_file(self,
query['key'] = self.api_key
if category is not None:
query['category'] = category
if vsys is not None:
query['vsys'] = vsys
if extra_qs is not None:
query = self.__merge_extra_qs(query, extra_qs)

Expand Down

0 comments on commit ffcb73e

Please sign in to comment.