Batfish Commands
Here we describe the non-question related Batfish functions
Networks
- pybatfish.client.session.Session.set_network(self, name: str | None = None, prefix: str = 'pcp') str
Configure the network used for analysis.
- Parameters:
name (str) – name of the network to set. If None, a name will be generated
prefix – prefix to prepend to auto-generated network names if name is empty
- Returns:
name of the configured network
- Return type:
str
- Raises:
BatfishException – if configuration fails
- pybatfish.client.session.Session.list_networks(self) list[str]
List networks the session’s API key can access.
- Returns:
network names
- Return type:
list
- pybatfish.client.session.Session.delete_network(self, name: str) None
Delete network by name.
- Parameters:
name (str) – name of the network to delete
Snapshots
- pybatfish.client.session.Session.init_snapshot(self, upload: str, name: str | None = None, overwrite: bool = False, extra_args: dict[str, Any] | None = None) str
Initialize a new snapshot.
- Parameters:
upload (str) – path to the snapshot zip or directory
name (str) – name of the snapshot to initialize
overwrite (bool) – whether to overwrite an existing snapshot with the same name
extra_args (dict) – extra arguments to control snapshot processing: 1) “ignoremanagementinterfaces” (bool) – whether to shut management interfaces (default is True); 2) “parsereuse” (bool) – whether to reuse parsing work from prior snapshots when file content is identical (default is True)
- Returns:
name of initialized snapshot
- Return type:
str
- pybatfish.client.session.Session.set_snapshot(self, name: str | None = None, index: int | None = None) str
Set the current snapshot by name or index.
- Parameters:
name (str) – 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.session.Session.list_snapshots(self, verbose: bool = False) list[str] | list[dict[str, Any]]
List snapshots for the current network.
- Parameters:
verbose (bool) – If true, return the full output of Batfish, including snapshot metadata.
- Returns:
snapshot names or the full JSON response containing snapshots and metadata (if verbose=True)
- Return type:
list
- pybatfish.client.session.Session.delete_snapshot(self, name: str) None
Delete specified snapshot from current network.
- Parameters:
name (str) – name of the snapshot to delete
- pybatfish.client.session.Session.fork_snapshot(self, base_name: str, name: str | None = None, overwrite: bool = False, deactivate_interfaces: list[Interface] | None = None, deactivate_nodes: list[str] | None = None, restore_interfaces: list[Interface] | None = None, restore_nodes: list[str] | None = None, add_files: str | None = None, extra_args: dict[str, Any] | None = None) str | None
Copy an existing snapshot and deactivate or reactivate specified interfaces, nodes, and links on the copy.
- Parameters:
base_name (str) – name of the snapshot to copy
name (str) – name of the snapshot to initialize
overwrite (bool) – whether to overwrite an existing snapshot with the same name
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 control snapshot processing: 1) “ignoremanagementinterfaces” (bool) – whether to shut management interfaces (default is True); 2) “parsereuse” (bool) – whether to reuse parsing work from prior snapshots when file content is identical (default is True)
- Returns:
name of initialized snapshot or None if the call fails
- Return type:
Optional[str]
Reference Library
- pybatfish.client.session.Session.get_reference_library(self) ReferenceLibrary
Returns the reference library for the active network.
- pybatfish.client.session.Session.get_reference_book(self, name: str) ReferenceBook
Returns the specified reference book for the active network.
- Parameters:
name (str) – name of the reference book to fetch
- pybatfish.client.session.Session.put_reference_book(self, book: ReferenceBook) None
Put a reference book in the active network.
If a book with the same name exists, it is overwritten.
- Parameters:
book (
ReferenceBook
) – The ReferenceBook object to add
- pybatfish.client.session.Session.delete_reference_book(self, name: str) None
Deletes the reference book with the specified name for the active network.
- Parameters:
name (str) – name of the reference book to delete