virl2_client package
- exception virl2_client.InitializationError
Bases:
VirlException
- exception virl2_client.InterfaceNotFound
Bases:
ElementNotFound
- exception virl2_client.LabNotFound
Bases:
ElementNotFound
- exception virl2_client.LinkNotFound
Bases:
ElementNotFound
- exception virl2_client.NodeNotFound
Bases:
ElementNotFound
- class virl2_client.ClientConfig(url: str | None = None, username: str | None = None, password: str | None = None, ssl_verify: bool | str = True, allow_http: bool = False, auto_sync: float = 1.0, raise_for_auth_failure: bool = True, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5)
Bases:
tupleStores client library configuration, which can be used to create any number of identically configured instances of ClientLibrary.
- make_client() ClientLibrary
- allow_http: bool
Alias for field number 4
- auto_sync: float
Alias for field number 5
- convergence_wait_max_iter: int
Alias for field number 7
- convergence_wait_time: int | float
Alias for field number 8
- password: str | None
Alias for field number 2
- raise_for_auth_failure: bool
Alias for field number 6
- ssl_verify: bool | str
Alias for field number 3
- url: str | None
Alias for field number 0
- username: str | None
Alias for field number 1
- class virl2_client.ClientLibrary(url: str | None = None, username: str | None = None, password: str | None = None, ssl_verify: bool | str = True, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5)
Bases:
objectPython bindings for the REST API of a CML controller.
- __init__(url: str | None = None, username: str | None = None, password: str | None = None, ssl_verify: bool | str = True, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5) None
Initializes a ClientLibrary instance. Note that ssl_verify can also be a string that points to a cert (see class documentation).
- Parameters:
url – URL of controller. It’s also possible to pass the URL via the
VIRL2_URLenvironment variable. If no protocol scheme is provided, “https:” is used.username – Username of the user to authenticate
password – Password of the user to authenticate
ssl_verify – Path SSL controller certificate, or True to load from
CA_BUNDLEenvironment variable, or False to disableraise_for_auth_failure – Raise an exception if unable to connect to controller (use for scripting scenarios)
allow_http – If set, a https URL will not be enforced
convergence_wait_max_iter – maximum number of iterations to wait for lab to converge
convergence_wait_time – wait interval in seconds to wait during one iteration during lab convergence wait
- Raises:
InitializationError – If no URL is provided, authentication fails or host can’t be reached
- all_labs(show_all: bool = False) list[Lab]
Retrieves a list of all defined labs.
- Parameters:
show_all – Whether to get only labs owned by the admin or all user labs
- Returns:
A list of lab objects
- Return type:
list[models.Lab]
- check_controller_version() None
Checks remote controller version against current client version (specified in self.VERSION) and against controller version blacklist (specified in self.INCOMPATIBLE_CONTROLLER_VERSIONS) and raises exception if versions are incompatible or prints warning if client minor version is lower than controller minor version.
- create_lab(title: str | None = None) Lab
Creates an empty lab with the given name. If no name is given, then the created lab ID is set as the name.
Note that the lab will be auto-syncing according to the Client Library’s auto-sync setting when created. The lab has a property to override this on a per-lab basis.
Example:
lab = client_library.create_lab() print(lab.id) lab.create_node("r1", "iosv", 50, 100)
- Parameters:
title – The Lab name (or title)
- Returns:
A Lab instance
- find_labs_by_title(title: str) list[Lab]
Return a list of labs which match the given title.
- Parameters:
title – The title to search for
- Returns:
A list of lab objects which match the title specified
- get_diagnostics() dict
Returns the controller diagnostic data as JSON
- Returns:
diagnostic data
- Return type:
dict
- get_host() str
Returns the hostname of the session to the controller.
- Returns:
A hostname
- get_lab_list(show_all: bool = False) list[str]
Returns list of all lab IDs.
- Parameters:
show_all (bool) – Whether to get only labs owned by the admin or all user labs
- Returns:
a list of Lab IDs
- Return type:
list[str]
- get_sample_labs() dict[str, dict]
Returns a dictionary with information about all sample labs available on host.
- Returns:
A dictionary of sample lab information, where keys are titles
- get_system_health() dict
Returns the controller system health data as JSON
- Returns:
system health data
- get_system_stats() dict
Returns the controller resource statistics as JSON
- Returns:
system resource statistics
- import_lab(topology: str, title: str | None = None, offline: bool = False, virl_1x: bool = False) Lab
Imports an existing topology from a string.
- Parameters:
topology – Topology representation as a string
title – Title of the lab (optional)
offline – whether the ClientLibrary should import the lab locally. The topology parameter has to be a JSON string in this case. This can not be XML or YAML representation of the lab. Compatible JSON from GET /labs/{lab_id}/topology.
virl_1x – Is this old virl-1x topology format (default=False)
- Returns:
A Lab instance
- Raises:
ValueError – if there’s no lab ID in the API response
httpx.HTTPError – if there was a transport error
- import_lab_from_path(path: str, title: str | None = None) Lab
Imports an existing topology from a file / path.
- Parameters:
path – Topology filename / path
title – Title of the lab
- Returns:
A Lab instance
- import_sample_lab(title: str) Lab
Imports a built-in sample lab.
- Parameters:
title – sample lab name, as returned by get_sample_labs
- Returns:
a Lab instance
- is_system_ready(wait: bool = False, max_wait: int = 60, sleep: int = 5) bool
Reports whether the system is ready or not.
- Parameters:
wait – if this is true, the call will block until it’s ready
max_wait – maximum time to wait, in seconds
sleep – time to wait between tries, in seconds
- Returns:
ready state
- static is_virl_1x(path: Path) bool
- join_existing_lab(lab_id: str, sync_lab: bool = True) Lab
Creates a new ClientLibrary lab instance that is retrieved from the controller.
If sync_lab is set to true, then synchronize current lab by applying the changes that were done in UI or in another ClientLibrary session.
Join preexisting lab:
lab = client_library.join_existing_lab("2e6a18")
- Parameters:
lab_id – The lab ID to be joined.
sync_lab – Synchronize changes.
- Returns:
A Lab instance
- logout(clear_all_sessions: bool = False) None
Invalidate current token.
- remove_lab(lab_id: str) None
Use carefully, it removes a given lab:
client_library.remove_lab("1f6cd7")
- Parameters:
lab_id (str) – The lab ID to be removed.
- system_info() dict
Get information about the system where the application runs. Can be called without authentication.
- Returns:
system information json
- INCOMPATIBLE_CONTROLLER_VERSIONS = [2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.1, 2.2.2, 2.2.3]
- VERSION = 2.5.0
- auto_sync
auto_sync automatically syncs data with the backend after a specific time. The default expiry time is 1.0s. This time can be configured by setting the auto_sync_interval.
- property session: Client
Returns the used httpx client session object.
- Returns:
The session object
Subpackages
- virl2_client.models package
GroupManagementInterfaceInterface.__init__()Interface.as_dict()Interface.bring_up()Interface.degree()Interface.get_link_to()Interface.is_connected()Interface.links()Interface.peer_interfaces()Interface.peer_nodes()Interface.remove_on_server()Interface.shutdown()Interface.connectedInterface.discovered_ipv4Interface.discovered_ipv6Interface.discovered_mac_addressInterface.is_physicalInterface.lab_base_urlInterface.linkInterface.peer_interfaceInterface.peer_nodeInterface.physicalInterface.readbytesInterface.readpacketsInterface.stateInterface.writebytesInterface.writepackets
LabLab.__init__()Lab.add_node_local()Lab.build_configurations()Lab.cleanup_pyats_connections()Lab.connect_two_nodes()Lab.create_interface()Lab.create_interface_local()Lab.create_link()Lab.create_link_local()Lab.create_node()Lab.details()Lab.download()Lab.find_nodes_by_tag()Lab.get_interface_by_id()Lab.get_link_by_id()Lab.get_link_by_interfaces()Lab.get_link_by_nodes()Lab.get_node_by_id()Lab.get_node_by_label()Lab.get_pyats_testbed()Lab.has_converged()Lab.import_lab()Lab.interfaces()Lab.is_active()Lab.links()Lab.need_to_wait()Lab.nodes()Lab.remove()Lab.remove_interface()Lab.remove_link()Lab.remove_node()Lab.remove_nodes()Lab.start()Lab.state()Lab.stop()Lab.sync()Lab.sync_events()Lab.sync_l3_addresses_if_outdated()Lab.sync_layer3_addresses()Lab.sync_operational()Lab.sync_operational_if_outdated()Lab.sync_pyats()Lab.sync_states()Lab.sync_states_if_outdated()Lab.sync_statistics()Lab.sync_statistics_if_outdated()Lab.sync_topology_if_outdated()Lab.update_lab()Lab.update_lab_groups()Lab.wait_until_lab_converged()Lab.wipe()Lab.descriptionLab.groupsLab.idLab.lab_base_urlLab.notesLab.ownerLab.resource_poolsLab.sessionLab.statisticsLab.title
LicensingLicensing.__init__()Licensing.cancel_reservation()Licensing.complete_reservation()Licensing.delete_reservation_confirmation_code()Licensing.delete_reservation_return_code()Licensing.deregister()Licensing.disable_reservation_mode()Licensing.discard_reservation()Licensing.enable_reservation_mode()Licensing.features()Licensing.get_certificate()Licensing.get_reservation_confirmation_code()Licensing.get_reservation_return_code()Licensing.install_certificate()Licensing.register()Licensing.register_renew()Licensing.register_wait()Licensing.release_reservation()Licensing.remove_certificate()Licensing.renew_authorization()Licensing.request_reservation()Licensing.reservation_mode()Licensing.set_default_transport()Licensing.set_product_license()Licensing.set_transport()Licensing.status()Licensing.tech_support()Licensing.update_features()Licensing.wait_for_status()Licensing.base_urlLicensing.max_waitLicensing.wait_interval
LinkLink.__init__()Link.as_dict()Link.get_condition()Link.has_converged()Link.remove_condition()Link.remove_on_server()Link.set_condition()Link.set_condition_by_name()Link.start()Link.stop()Link.wait_until_converged()Link.base_urlLink.interfacesLink.lab_base_urlLink.labelLink.node_aLink.node_bLink.nodesLink.readbytesLink.readpacketsLink.stateLink.writebytesLink.writepackets
NodeNode.__init__()Node.add_tag()Node.console_key()Node.console_logs()Node.create_interface()Node.degree()Node.extract_configuration()Node.get_interface_by_label()Node.get_interface_by_slot()Node.get_link_to()Node.get_links_to()Node.has_converged()Node.interfaces()Node.is_active()Node.is_booted()Node.links()Node.map_l3_addresses_to_interfaces()Node.next_available_interface()Node.peer_interfaces()Node.peer_nodes()Node.physical_interfaces()Node.remove_on_server()Node.remove_tag()Node.run_pyats_command()Node.run_pyats_config_command()Node.start()Node.stop()Node.sync_layer3_addresses()Node.sync_operational()Node.tags()Node.update()Node.vnc_key()Node.wait_until_converged()Node.wipe()Node.boot_disk_sizeNode.compute_idNode.configNode.configurationNode.cpu_limitNode.cpu_usageNode.cpusNode.data_volumeNode.disk_readNode.disk_writeNode.hide_linksNode.image_definitionNode.lab_base_urlNode.labelNode.node_definitionNode.ramNode.resource_poolNode.stateNode.xNode.y
NodeImageDefinitionsNodeImageDefinitions.__init__()NodeImageDefinitions.download_image_definition()NodeImageDefinitions.download_image_file_list()NodeImageDefinitions.download_node_definition()NodeImageDefinitions.image_definitions()NodeImageDefinitions.image_definitions_for_node_definition()NodeImageDefinitions.node_definitions()NodeImageDefinitions.remove_dropfolder_image()NodeImageDefinitions.remove_image_definition()NodeImageDefinitions.remove_node_definition()NodeImageDefinitions.upload_image_definition()NodeImageDefinitions.upload_image_file()NodeImageDefinitions.upload_node_definition()NodeImageDefinitions.session
ResourcePoolManagementResourcePoolManagement.__init__()ResourcePoolManagement.create_resource_pool()ResourcePoolManagement.create_resource_pools()ResourcePoolManagement.get_resource_pools_by_ids()ResourcePoolManagement.sync_resource_pools()ResourcePoolManagement.sync_resource_pools_if_outdated()ResourcePoolManagement.resource_poolsResourcePoolManagement.session
SystemManagementSystemManagement.__init__()SystemManagement.add_compute_host_local()SystemManagement.get_external_connectors()SystemManagement.get_mac_address_block()SystemManagement.get_web_session_timeout()SystemManagement.set_mac_address_block()SystemManagement.set_web_session_timeout()SystemManagement.sync_compute_hosts()SystemManagement.sync_compute_hosts_if_outdated()SystemManagement.compute_hostsSystemManagement.session
TokenAuthUserManagement- Submodules
- virl2_client.models.authentication
- virl2_client.models.cl_pyats
- virl2_client.models.groups
- virl2_client.models.interface
InterfaceInterface.__init__()Interface.as_dict()Interface.bring_up()Interface.degree()Interface.get_link_to()Interface.is_connected()Interface.links()Interface.peer_interfaces()Interface.peer_nodes()Interface.remove_on_server()Interface.shutdown()Interface.connectedInterface.discovered_ipv4Interface.discovered_ipv6Interface.discovered_mac_addressInterface.is_physicalInterface.lab_base_urlInterface.linkInterface.peer_interfaceInterface.peer_nodeInterface.physicalInterface.readbytesInterface.readpacketsInterface.stateInterface.writebytesInterface.writepackets
- virl2_client.models.lab
LabLab.__init__()Lab.add_node_local()Lab.build_configurations()Lab.cleanup_pyats_connections()Lab.connect_two_nodes()Lab.create_interface()Lab.create_interface_local()Lab.create_link()Lab.create_link_local()Lab.create_node()Lab.details()Lab.download()Lab.find_nodes_by_tag()Lab.get_interface_by_id()Lab.get_link_by_id()Lab.get_link_by_interfaces()Lab.get_link_by_nodes()Lab.get_node_by_id()Lab.get_node_by_label()Lab.get_pyats_testbed()Lab.has_converged()Lab.import_lab()Lab.interfaces()Lab.is_active()Lab.links()Lab.need_to_wait()Lab.nodes()Lab.remove()Lab.remove_interface()Lab.remove_link()Lab.remove_node()Lab.remove_nodes()Lab.start()Lab.state()Lab.stop()Lab.sync()Lab.sync_events()Lab.sync_l3_addresses_if_outdated()Lab.sync_layer3_addresses()Lab.sync_operational()Lab.sync_operational_if_outdated()Lab.sync_pyats()Lab.sync_states()Lab.sync_states_if_outdated()Lab.sync_statistics()Lab.sync_statistics_if_outdated()Lab.sync_topology_if_outdated()Lab.update_lab()Lab.update_lab_groups()Lab.wait_until_lab_converged()Lab.wipe()Lab.descriptionLab.groupsLab.idLab.lab_base_urlLab.notesLab.ownerLab.resource_poolsLab.sessionLab.statisticsLab.title
- virl2_client.models.licensing
LicensingLicensing.__init__()Licensing.cancel_reservation()Licensing.complete_reservation()Licensing.delete_reservation_confirmation_code()Licensing.delete_reservation_return_code()Licensing.deregister()Licensing.disable_reservation_mode()Licensing.discard_reservation()Licensing.enable_reservation_mode()Licensing.features()Licensing.get_certificate()Licensing.get_reservation_confirmation_code()Licensing.get_reservation_return_code()Licensing.install_certificate()Licensing.register()Licensing.register_renew()Licensing.register_wait()Licensing.release_reservation()Licensing.remove_certificate()Licensing.renew_authorization()Licensing.request_reservation()Licensing.reservation_mode()Licensing.set_default_transport()Licensing.set_product_license()Licensing.set_transport()Licensing.status()Licensing.tech_support()Licensing.update_features()Licensing.wait_for_status()Licensing.base_urlLicensing.max_waitLicensing.wait_interval
- virl2_client.models.link
LinkLink.__init__()Link.as_dict()Link.get_condition()Link.has_converged()Link.remove_condition()Link.remove_on_server()Link.set_condition()Link.set_condition_by_name()Link.start()Link.stop()Link.wait_until_converged()Link.base_urlLink.interfacesLink.lab_base_urlLink.labelLink.node_aLink.node_bLink.nodesLink.readbytesLink.readpacketsLink.stateLink.writebytesLink.writepackets
- virl2_client.models.node
NodeNode.__init__()Node.add_tag()Node.console_key()Node.console_logs()Node.create_interface()Node.degree()Node.extract_configuration()Node.get_interface_by_label()Node.get_interface_by_slot()Node.get_link_to()Node.get_links_to()Node.has_converged()Node.interfaces()Node.is_active()Node.is_booted()Node.links()Node.map_l3_addresses_to_interfaces()Node.next_available_interface()Node.peer_interfaces()Node.peer_nodes()Node.physical_interfaces()Node.remove_on_server()Node.remove_tag()Node.run_pyats_command()Node.run_pyats_config_command()Node.start()Node.stop()Node.sync_layer3_addresses()Node.sync_operational()Node.tags()Node.update()Node.vnc_key()Node.wait_until_converged()Node.wipe()Node.boot_disk_sizeNode.compute_idNode.configNode.configurationNode.cpu_limitNode.cpu_usageNode.cpusNode.data_volumeNode.disk_readNode.disk_writeNode.hide_linksNode.image_definitionNode.lab_base_urlNode.labelNode.node_definitionNode.ramNode.resource_poolNode.stateNode.xNode.y
- virl2_client.models.node_image_definitions
NodeImageDefinitionsNodeImageDefinitions.__init__()NodeImageDefinitions.download_image_definition()NodeImageDefinitions.download_image_file_list()NodeImageDefinitions.download_node_definition()NodeImageDefinitions.image_definitions()NodeImageDefinitions.image_definitions_for_node_definition()NodeImageDefinitions.node_definitions()NodeImageDefinitions.remove_dropfolder_image()NodeImageDefinitions.remove_image_definition()NodeImageDefinitions.remove_node_definition()NodeImageDefinitions.upload_image_definition()NodeImageDefinitions.upload_image_file()NodeImageDefinitions.upload_node_definition()NodeImageDefinitions.session
print_progress_bar()
- virl2_client.models.resource_pools
ResourcePoolResourcePool.__init__()ResourcePool.get_usage()ResourcePool.remove()ResourcePool.update()ResourcePool.cpusResourcePool.descriptionResourcePool.disk_spaceResourcePool.external_connectorsResourcePool.idResourcePool.is_templateResourcePool.labelResourcePool.licensesResourcePool.ramResourcePool.templateResourcePool.user_poolsResourcePool.users
ResourcePoolManagementResourcePoolManagement.__init__()ResourcePoolManagement.create_resource_pool()ResourcePoolManagement.create_resource_pools()ResourcePoolManagement.get_resource_pools_by_ids()ResourcePoolManagement.sync_resource_pools()ResourcePoolManagement.sync_resource_pools_if_outdated()ResourcePoolManagement.resource_poolsResourcePoolManagement.session
ResourcePoolUsageResourcePoolUsageBase
- virl2_client.models.system
ComputeHostSystemManagementSystemManagement.__init__()SystemManagement.add_compute_host_local()SystemManagement.get_external_connectors()SystemManagement.get_mac_address_block()SystemManagement.get_web_session_timeout()SystemManagement.set_mac_address_block()SystemManagement.set_web_session_timeout()SystemManagement.sync_compute_hosts()SystemManagement.sync_compute_hosts_if_outdated()SystemManagement.compute_hostsSystemManagement.session
- virl2_client.models.users
Submodules
virl2_client.exceptions
- exception virl2_client.exceptions.DesynchronizedError
Bases:
VirlException
- exception virl2_client.exceptions.ElementAlreadyExists
Bases:
VirlException,FileExistsError
- exception virl2_client.exceptions.ElementNotFound
Bases:
VirlException,KeyError
- exception virl2_client.exceptions.InitializationError
Bases:
VirlException
- exception virl2_client.exceptions.InterfaceNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.InvalidImageFile
Bases:
VirlException
- exception virl2_client.exceptions.InvalidProperty
Bases:
VirlException
- exception virl2_client.exceptions.LabNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.LinkNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.NodeNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.VirlException
Bases:
Exception
virl2_client.virl2_client
- class virl2_client.virl2_client.ClientConfig(url: str | None = None, username: str | None = None, password: str | None = None, ssl_verify: bool | str = True, allow_http: bool = False, auto_sync: float = 1.0, raise_for_auth_failure: bool = True, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5)
Bases:
tupleStores client library configuration, which can be used to create any number of identically configured instances of ClientLibrary.
- make_client() ClientLibrary
- allow_http: bool
Alias for field number 4
- auto_sync: float
Alias for field number 5
- convergence_wait_max_iter: int
Alias for field number 7
- convergence_wait_time: int | float
Alias for field number 8
- password: str | None
Alias for field number 2
- raise_for_auth_failure: bool
Alias for field number 6
- ssl_verify: bool | str
Alias for field number 3
- url: str | None
Alias for field number 0
- username: str | None
Alias for field number 1
- class virl2_client.virl2_client.ClientLibrary(url: str | None = None, username: str | None = None, password: str | None = None, ssl_verify: bool | str = True, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5)
Bases:
objectPython bindings for the REST API of a CML controller.
- __init__(url: str | None = None, username: str | None = None, password: str | None = None, ssl_verify: bool | str = True, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5) None
Initializes a ClientLibrary instance. Note that ssl_verify can also be a string that points to a cert (see class documentation).
- Parameters:
url – URL of controller. It’s also possible to pass the URL via the
VIRL2_URLenvironment variable. If no protocol scheme is provided, “https:” is used.username – Username of the user to authenticate
password – Password of the user to authenticate
ssl_verify – Path SSL controller certificate, or True to load from
CA_BUNDLEenvironment variable, or False to disableraise_for_auth_failure – Raise an exception if unable to connect to controller (use for scripting scenarios)
allow_http – If set, a https URL will not be enforced
convergence_wait_max_iter – maximum number of iterations to wait for lab to converge
convergence_wait_time – wait interval in seconds to wait during one iteration during lab convergence wait
- Raises:
InitializationError – If no URL is provided, authentication fails or host can’t be reached
- all_labs(show_all: bool = False) list[Lab]
Retrieves a list of all defined labs.
- Parameters:
show_all – Whether to get only labs owned by the admin or all user labs
- Returns:
A list of lab objects
- Return type:
list[models.Lab]
- check_controller_version() None
Checks remote controller version against current client version (specified in self.VERSION) and against controller version blacklist (specified in self.INCOMPATIBLE_CONTROLLER_VERSIONS) and raises exception if versions are incompatible or prints warning if client minor version is lower than controller minor version.
- create_lab(title: str | None = None) Lab
Creates an empty lab with the given name. If no name is given, then the created lab ID is set as the name.
Note that the lab will be auto-syncing according to the Client Library’s auto-sync setting when created. The lab has a property to override this on a per-lab basis.
Example:
lab = client_library.create_lab() print(lab.id) lab.create_node("r1", "iosv", 50, 100)
- Parameters:
title – The Lab name (or title)
- Returns:
A Lab instance
- find_labs_by_title(title: str) list[Lab]
Return a list of labs which match the given title.
- Parameters:
title – The title to search for
- Returns:
A list of lab objects which match the title specified
- get_diagnostics() dict
Returns the controller diagnostic data as JSON
- Returns:
diagnostic data
- Return type:
dict
- get_host() str
Returns the hostname of the session to the controller.
- Returns:
A hostname
- get_lab_list(show_all: bool = False) list[str]
Returns list of all lab IDs.
- Parameters:
show_all (bool) – Whether to get only labs owned by the admin or all user labs
- Returns:
a list of Lab IDs
- Return type:
list[str]
- get_sample_labs() dict[str, dict]
Returns a dictionary with information about all sample labs available on host.
- Returns:
A dictionary of sample lab information, where keys are titles
- get_system_health() dict
Returns the controller system health data as JSON
- Returns:
system health data
- get_system_stats() dict
Returns the controller resource statistics as JSON
- Returns:
system resource statistics
- import_lab(topology: str, title: str | None = None, offline: bool = False, virl_1x: bool = False) Lab
Imports an existing topology from a string.
- Parameters:
topology – Topology representation as a string
title – Title of the lab (optional)
offline – whether the ClientLibrary should import the lab locally. The topology parameter has to be a JSON string in this case. This can not be XML or YAML representation of the lab. Compatible JSON from GET /labs/{lab_id}/topology.
virl_1x – Is this old virl-1x topology format (default=False)
- Returns:
A Lab instance
- Raises:
ValueError – if there’s no lab ID in the API response
httpx.HTTPError – if there was a transport error
- import_lab_from_path(path: str, title: str | None = None) Lab
Imports an existing topology from a file / path.
- Parameters:
path – Topology filename / path
title – Title of the lab
- Returns:
A Lab instance
- import_sample_lab(title: str) Lab
Imports a built-in sample lab.
- Parameters:
title – sample lab name, as returned by get_sample_labs
- Returns:
a Lab instance
- is_system_ready(wait: bool = False, max_wait: int = 60, sleep: int = 5) bool
Reports whether the system is ready or not.
- Parameters:
wait – if this is true, the call will block until it’s ready
max_wait – maximum time to wait, in seconds
sleep – time to wait between tries, in seconds
- Returns:
ready state
- static is_virl_1x(path: Path) bool
- join_existing_lab(lab_id: str, sync_lab: bool = True) Lab
Creates a new ClientLibrary lab instance that is retrieved from the controller.
If sync_lab is set to true, then synchronize current lab by applying the changes that were done in UI or in another ClientLibrary session.
Join preexisting lab:
lab = client_library.join_existing_lab("2e6a18")
- Parameters:
lab_id – The lab ID to be joined.
sync_lab – Synchronize changes.
- Returns:
A Lab instance
- logout(clear_all_sessions: bool = False) None
Invalidate current token.
- remove_lab(lab_id: str) None
Use carefully, it removes a given lab:
client_library.remove_lab("1f6cd7")
- Parameters:
lab_id (str) – The lab ID to be removed.
- system_info() dict
Get information about the system where the application runs. Can be called without authentication.
- Returns:
system information json
- INCOMPATIBLE_CONTROLLER_VERSIONS = [2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.1, 2.2.2, 2.2.3]
- VERSION = 2.5.0
- auto_sync
auto_sync automatically syncs data with the backend after a specific time. The default expiry time is 1.0s. This time can be configured by setting the auto_sync_interval.
- password: str
- property session: Client
Returns the used httpx client session object.
- Returns:
The session object
- url: str
- username: str
- class virl2_client.virl2_client.Version(version_str: str)
Bases:
object- __init__(version_str: str) None
- static parse_version_str(version_str: str) str
- major
- minor
- patch
- version_str
- virl2_client.virl2_client.prepare_url(url: str, allow_http: bool) tuple[str, str]