Batfish Commands¶
Here we describe the non-question related Batfish functions
Networks¶
-
pybatfish.client.commands.
bf_set_network
(name: Optional[str] = None, prefix: str = 'pcp') → str[source]¶ Configure the network used for analysis.
- Parameters
name (string) – name of the network to set. If None, a name will be generated using prefix.
prefix – prefix to prepend to auto-generated network names if name is empty
- Returns
The name of the configured network, if configured successfully.
- Return type
string
- Raises
BatfishException – if configuration fails
Snapshots¶
-
pybatfish.client.commands.
bf_init_snapshot
(upload, name=None, overwrite=False, background=False, extra_args=None)[source]¶ Initialize a new snapshot.
- Parameters
upload (zip file or directory) – snapshot to upload
name (string) – name of the snapshot to initialize
overwrite (bool) – whether or not to overwrite an existing snapshot with the same name
background (bool) – whether or not to run the task in the background
extra_args (dict) – extra arguments to be passed to the parse command.
- Returns
name of initialized snapshot, or JSON dictionary of task status if background=True
- Return type
Union[str, Dict]
-
pybatfish.client.commands.
bf_set_snapshot
(name=None, index=None)[source]¶ Set the current snapshot by name or index.
- Parameters
name (string) – name of the snapshot to set as the current snapshot
index (int) – set the current snapshot to the
index
-th most recent snapshot
- Returns
the name of the successfully set snapshot
- Return type
str
-
pybatfish.client.commands.
bf_list_snapshots
(verbose=False)[source]¶ List snapshots for the current network.
- Parameters
verbose – If true, return the full output of Batfish, including snapshot metadata.
- Returns
a list of snapshot names or the full json response containing snapshots and metadata (if verbose=True)
-
pybatfish.client.commands.
bf_delete_snapshot
(name)[source]¶ Delete named snapshot from current network.
- Parameters
name (string) – name of the snapshot to delete
-
pybatfish.client.commands.
bf_fork_snapshot
(base_name, name=None, overwrite=False, background=False, deactivate_interfaces=None, deactivate_nodes=None, restore_interfaces=None, restore_nodes=None, add_files=None, extra_args=None)[source]¶ Copy an existing snapshot and deactivate or reactivate specified interfaces, nodes, and links on the copy.
- Parameters
base_name (string) – name of the snapshot to copy
name (string) – name of the snapshot to initialize
overwrite (bool) – whether or not to overwrite an existing snapshot with the same name
background (bool) – whether or not to run the task in the background
deactivate_interfaces (list[Interface]) – list of interfaces to deactivate in new snapshot
deactivate_nodes (list[str]) – list of names of nodes to deactivate in new snapshot
restore_interfaces (list[Interface]) – list of interfaces to reactivate
restore_nodes (list[str]) – list of names of nodes to reactivate
add_files (str) – path to zip file or directory containing files to add
extra_args (dict) – extra arguments to be passed to the parse command.
- Returns
name of initialized snapshot, JSON dictionary of task status if background=True, or None if the call fails
- Return type
Union[str, Dict, None]
Reference Library¶
-
pybatfish.client.commands.
bf_get_reference_library
()[source]¶ Returns the reference library for the active network.
-
pybatfish.client.commands.
bf_get_reference_book
(book_name)[source]¶ Returns the reference book with the specified for the active network.
-
pybatfish.client.commands.
bf_put_reference_book
(book)[source]¶ Put a reference book in the active network.
If a book with the same name exists, it is overwritten.
- Parameters
book (
pybatfish.datamodel.referencelibrary.ReferenceBook
) – The ReferenceBook object to add
Diagnostics¶
-
pybatfish.client.commands.
bf_upload_diagnostics
(dry_run: bool = True, netconan_config: Optional[str] = None, contact_info: Optional[str] = None, proxy: Optional[str] = None) → str[source]¶ Fetch, anonymize, and optionally upload snapshot diagnostics information.
This runs a series of diagnostic questions on the current snapshot (including collecting parsing and conversion information).
The information collected is anonymized with Netconan which either anonymizes passwords and IP addresses (default) or uses the settings in the provided netconan_config.
The anonymous information is then either saved locally (if dry_run is True) or uploaded to Batfish developers (if dry_run is False). The uploaded information will be accessible only to Batfish developers and will be used to help diagnose any issues you encounter.
If contact_info is supplied (e.g. email address), Batfish developers may contact you if they have follow-up questions or to update you when the issues you encountered are resolved.
- Parameters
dry_run (bool) – if True, upload is skipped and the anonymized files will be stored locally for review. If False, anonymized files will be uploaded to the Batfish developers
netconan_config (string) – path to Netconan configuration file
contact_info (str) – optional contact info associated with this upload
proxy – a proxy URL to use when uploading data.
- Returns
location of anonymized files (local directory if doing dry run, otherwise upload ID)
- Return type
string