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, jwtoken: str | None = None, ssl_verify: bool | str = True, allow_http: bool = False, auto_sync: float = 1.0, events: bool = False, raise_for_auth_failure: bool = True, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5, check_version: bool = True)
Bases:
NamedTupleStores client library configuration, which can be used to create any number of identically configured instances of ClientLibrary.
- classmethod get_configuration(url: str | None, username: str | None, password: str | None, jwtoken: str | None, ssl_verify: bool | str | None, allow_inputs: bool | None = None) ClientConfig
- make_client() ClientLibrary
- allow_http: bool
Alias for field number 5
- auto_sync: float
Alias for field number 6
- check_version: bool
Alias for field number 11
- convergence_wait_max_iter: int
Alias for field number 9
- convergence_wait_time: int | float
Alias for field number 10
- events: bool
Alias for field number 7
- jwtoken: str | None
Alias for field number 3
- password: str | None
Alias for field number 2
- raise_for_auth_failure: bool
Alias for field number 8
- ssl_verify: bool | str
Alias for field number 4
- 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, jwtoken: str | None = None, ssl_verify: bool | str | None = None, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5, events: bool = False, client_type: str = None, check_version: bool = True)
Bases:
objectPython bindings for the REST API of a CML controller.
- __init__(url: str | None = None, username: str | None = None, password: str | None = None, jwtoken: str | None = None, ssl_verify: bool | str | None = None, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5, events: bool = False, client_type: str = None, check_version: bool = True) None
- all_labs(show_all: bool = False) list[Lab]
Join all labs owned by this user (or all labs) and return their list.
- Parameters:
show_all – Whether to get only labs owned by the admin or all user labs.
- Returns:
A list of Lab objects.
- check_controller_version() Version | None
Check remote controller version against current client version (specified in self.VERSION and support last 3 minor versions). Raise exception if versions are incompatible, or print warning if the client minor version is lower than the controller minor version. These all are disabled if self.check_version attribute is set to False.
- Raises:
InitializationError – If the controller version is incompatible.
- Returns:
None
- create_lab(title: str | None = None, description: str | None = None, notes: str | None = None, autostart: dict | None = None, node_staging: dict | None = None) Lab
Create a new lab with optional title, description, and notes.
If no title, description, or notes are provided, the server will generate a default title in the format “Lab at Mon 13:30 PM” and leave the description and notes blank.
The lab will automatically sync based on the Client Library’s auto-sync setting when created, but this behavior can be overridden on a per-lab basis.
Example:
lab = client_library.create_lab() print(lab.id) lab.create_node("r1", "iosv", 50, 100)
- Parameters:
title – The title of the lab.
description – The description of the lab.
notes – The notes of the lab.
autostart – Parameter for autostart (enabled, priority, delay).
node_staging – Parameter for node staging (enabled, abort_on_failure, start_remaining).
- Returns:
A Lab instance representing the created lab.
- 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 matching the specified title.
- get_diagnostics(*categories: DiagnosticsCategory) dict
Return selected diagnostics data as a JSON object.
- Parameters:
categories – List of diagnostics categories to fetch. DEPRECATED: If not provided, provide DiagnosticsCategory.ALL to fetch all diagnostics data.
- Returns:
The diagnostics data.
- get_host() str
Return the hostname of the session to the controller.
- Returns:
The hostname.
- get_lab_list(show_all: bool = False) list[str]
Get the list of all lab IDs.
- Parameters:
show_all – Whether to include labs owned by all users (True) or only labs owned by the admin (False).
- Returns:
A list of lab IDs.
- get_local_lab(lab_id: str) Lab
Get a local lab by its ID.
- Parameters:
lab_id – The ID of the lab.
- Returns:
The Lab object with the specified ID.
- Raises:
LabNotFound – If the lab with the given ID does not exist.
- get_sample_labs() dict[str, dict]
Return a dictionary with information about all sample labs available on the host.
- Returns:
A dictionary of sample lab information where the keys are the titles.
- get_system_health() dict
Return the controller system health data as a JSON object.
- Returns:
The system health data.
- get_system_stats() dict
Return the controller resource statistics as a JSON object.
- Returns:
The system resource statistics.
- import_lab(topology: str, title: str | None = None, offline: bool | None = None, virl_1x: bool = False) Lab
Import an existing topology from a string.
- Parameters:
topology – The topology representation as a string.
title – The title of the lab.
offline – DEPRECATED: Offline mode has been removed.
virl_1x – Whether the topology format is the old, VIRL 1.x format.
- Returns:
The imported Lab instance.
- Raises:
ValueError – If no lab ID is returned in the API response.
httpx.HTTPError – If there was a transport error.
- import_lab_from_path(path: Path | str, title: str | None = None) Lab
Import an existing topology from a file or path.
- Parameters:
path – The topology filename or path.
title – The title of the lab.
- Returns:
The imported Lab instance.
- Raises:
FileNotFoundError – If the specified path does not exist.
- import_sample_lab(title: str) Lab
Import a built-in sample lab.
- Parameters:
title – The sample lab name.
- Returns:
The imported Lab instance.
- is_system_ready(wait: bool = False, max_wait: int = 60, sleep: int = 5) bool
Report whether the system is ready or not.
- Parameters:
wait – Whether to block until the system is ready.
max_wait – The maximum time to wait in seconds.
sleep – The time to wait between tries in seconds.
- Returns:
The ready state of the system.
- static is_virl_1x(path: Path) bool
Check if the given file is of VIRL version 1.x.
- Parameters:
path – The path to check.
- Returns:
Whether the file is of VIRL version 1.x.
- join_existing_lab(lab_id: str, sync_lab: bool = True) Lab
Join a lab that exists on the server and make it accessible locally.
If sync_lab is set to True, the current lab will be synchronized by applying any changes that were made in the UI or in another ClientLibrary session.
- Example::
lab = client_library.join_existing_lab(“2e6a18”)
- Parameters:
lab_id – The ID of the lab to be joined.
sync_lab – Whether to synchronize the lab.
- Returns:
A Lab instance representing the joined lab.
- Raises:
LabNotFound – If no lab with the given ID exists on the host.
- logout(clear_all_sessions: bool = False) bool
Invalidate the current token.
- Parameters:
clear_all_sessions – Whether to clear all user sessions as well.
- remove_lab(lab_id: str | Lab) None
Remove a lab identified by its ID or Lab object.
Use this method with caution as it permanently deletes the specified lab.
If you have the lab object, you can also do
lab.remove().- Parameters:
lab_id – The ID or Lab object representing the lab to be removed.
- start_event_listening()
Start listening for and parsing websocket events.
To replace the default event handling mechanism, subclass event_handling.EventHandler (or EventHandlerBase if necessary), then do:: from .event_listening import EventListener custom_listener = EventListener() custom_listener._event_handler = CustomHandler(client_library) client_library.event_listener = custom_listener
- Returns:
- stop_event_listening()
Stop listening for and parsing websocket events.
- system_info() dict
Get information about the system where the application runs. Can be called without authentication.
- Returns:
The system information as a JSON object.
- VERSION = 2.10.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 uuid: str
Return the UUID4 that identifies this client to the server.
Subpackages
- virl2_client.models package
AnnotationAnnotation.__init__()Annotation.as_dict()Annotation.get_default_property_values()Annotation.is_valid_property()Annotation.remove()Annotation.update()Annotation.border_colorAnnotation.border_styleAnnotation.colorAnnotation.idAnnotation.thicknessAnnotation.typeAnnotation.x1Annotation.y1Annotation.z_index
AuthManagementAuthManagement.__init__()AuthManagement.get_ldap_groups()AuthManagement.get_settings()AuthManagement.refresh_ldap_groups()AuthManagement.sync()AuthManagement.sync_if_outdated()AuthManagement.test_auth()AuthManagement.test_current_auth()AuthManagement.update_settings()AuthManagement.managerAuthManagement.method
GroupManagementGroupManagement.__init__()GroupManagement.associations()GroupManagement.create_group()GroupManagement.delete_group()GroupManagement.get_group()GroupManagement.group_id()GroupManagement.group_labs()GroupManagement.group_members()GroupManagement.groups()GroupManagement.update_associations()GroupManagement.update_group()
InterfaceInterface.__init__()Interface.as_dict()Interface.bring_up()Interface.get_link_to()Interface.remove()Interface.shutdown()Interface.connectedInterface.deployed_mac_addressInterface.discovered_ipv4Interface.discovered_ipv6Interface.discovered_mac_addressInterface.idInterface.ip_snooped_infoInterface.labelInterface.linkInterface.mac_addressInterface.nodeInterface.operationalInterface.peer_interfaceInterface.peer_nodeInterface.physicalInterface.readbytesInterface.readpacketsInterface.slotInterface.stateInterface.typeInterface.writebytesInterface.writepackets
LabLab.__init__()Lab.annotations()Lab.build_configurations()Lab.cleanup_pyats_connections()Lab.clear_discovered_addresses()Lab.connect_two_nodes()Lab.create_annotation()Lab.create_interface()Lab.create_link()Lab.create_node()Lab.create_smart_annotation()Lab.details()Lab.download()Lab.find_nodes_by_tag()Lab.get_annotation_by_id()Lab.get_interface_by_id()Lab.get_link_by_id()Lab.get_node_by_id()Lab.get_node_by_label()Lab.get_pyats_testbed()Lab.get_smart_annotation_by_id()Lab.get_smart_annotation_by_tag()Lab.has_converged()Lab.import_lab()Lab.interfaces()Lab.is_active()Lab.links()Lab.need_to_wait()Lab.nodes()Lab.remove()Lab.remove_annotation()Lab.remove_annotations()Lab.remove_interface()Lab.remove_link()Lab.remove_node()Lab.remove_nodes()Lab.remove_smart_annotation()Lab.remove_smart_annotations()Lab.set_autostart()Lab.set_node_staging()Lab.smart_annotations()Lab.start()Lab.state()Lab.stop()Lab.sync()Lab.sync_events()Lab.sync_interfaces_operational()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_associations()Lab.update_connector_mappings()Lab.update_lab()Lab.update_lab_groups()Lab.update_lab_properties()Lab.wait_until_lab_converged()Lab.wipe()Lab.associationsLab.autostartLab.connector_mappingsLab.descriptionLab.groupsLab.idLab.node_stagingLab.notesLab.ownerLab.resource_poolsLab.statisticsLab.title
LabRepositoryLabRepositoryManagementLabRepositoryManagement.__init__()LabRepositoryManagement.add_lab_repository()LabRepositoryManagement.add_lab_repository_local()LabRepositoryManagement.get_lab_repositories()LabRepositoryManagement.get_lab_repository()LabRepositoryManagement.get_lab_repository_by_name()LabRepositoryManagement.refresh_lab_repositories()LabRepositoryManagement.sync_lab_repositories()LabRepositoryManagement.sync_lab_repositories_if_outdated()LabRepositoryManagement.lab_repositories
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_reservation_confirmation_code()Licensing.get_reservation_return_code()Licensing.register()Licensing.register_renew()Licensing.register_wait()Licensing.release_reservation()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.max_waitLicensing.wait_interval
LinkLink.__init__()Link.as_dict()Link.capture_status()Link.download_capture()Link.get_capture_packet()Link.get_capture_packets()Link.get_condition()Link.has_converged()Link.remove()Link.remove_condition()Link.set_condition()Link.set_condition_by_name()Link.start()Link.start_capture()Link.stop()Link.stop_capture()Link.wait_until_converged()Link.idLink.interface_aLink.interface_bLink.interfacesLink.labLink.labelLink.node_aLink.node_bLink.nodesLink.readbytesLink.readpacketsLink.stateLink.writebytesLink.writepackets
NodeNode.__init__()Node.add_tag()Node.clear_discovered_addresses()Node.clone_image()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()Node.remove_tag()Node.run_pyats_command()Node.run_pyats_config_command()Node.set_pyats_credentials()Node.start()Node.stop()Node.sync_interface_operational()Node.sync_interface_operational_if_outdated()Node.sync_l3_addresses_if_outdated()Node.sync_layer3_addresses()Node.sync_operational()Node.sync_operational_if_outdated()Node.tags()Node.update()Node.update_parameters()Node.vnc_key()Node.wait_until_converged()Node.wipe()Node.boot_disk_sizeNode.compute_idNode.configurationNode.configuration_filesNode.cpu_limitNode.cpu_usageNode.cpusNode.data_volumeNode.disk_readNode.disk_writeNode.hide_linksNode.idNode.image_definitionNode.labNode.labelNode.node_definitionNode.operationalNode.parametersNode.pinned_compute_idNode.priorityNode.pyats_credentialsNode.ramNode.resource_poolNode.smart_annotationsNode.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.set_image_definition_read_only()NodeImageDefinitions.set_node_definition_read_only()NodeImageDefinitions.upload_image_definition()NodeImageDefinitions.upload_image_file()NodeImageDefinitions.upload_node_definition()
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_pools
SmartAnnotationSmartAnnotation.__init__()SmartAnnotation.as_dict()SmartAnnotation.remove()SmartAnnotation.update()SmartAnnotation.border_colorSmartAnnotation.border_styleSmartAnnotation.fill_colorSmartAnnotation.group_distanceSmartAnnotation.idSmartAnnotation.is_onSmartAnnotation.labSmartAnnotation.labelSmartAnnotation.paddingSmartAnnotation.tagSmartAnnotation.tag_offset_xSmartAnnotation.tag_offset_ySmartAnnotation.tag_sizeSmartAnnotation.thicknessSmartAnnotation.z_index
SystemManagementSystemManagement.__init__()SystemManagement.add_compute_host_local()SystemManagement.add_system_notice_local()SystemManagement.delete_external_connector()SystemManagement.get_external_connectors()SystemManagement.get_new_compute_host_state()SystemManagement.get_telemetry_events()SystemManagement.get_web_session_timeout()SystemManagement.set_new_compute_host_state()SystemManagement.set_web_session_timeout()SystemManagement.sync_compute_hosts()SystemManagement.sync_compute_hosts_if_outdated()SystemManagement.sync_system_notices()SystemManagement.sync_system_notices_if_outdated()SystemManagement.update_external_connector()SystemManagement.compute_hostsSystemManagement.controllerSystemManagement.maintenance_modeSystemManagement.maintenance_noticeSystemManagement.system_noticesSystemManagement.telemetrySystemManagement.telemetry_state
TokenAuthUserManagementUserManagement.__init__()UserManagement.associations()UserManagement.create_user()UserManagement.delete_user()UserManagement.get_user()UserManagement.get_username()UserManagement.sync_users()UserManagement.sync_users_if_outdated()UserManagement.update_associations()UserManagement.update_user()UserManagement.user_groups()UserManagement.user_id()UserManagement.users()
- Submodules
- virl2_client.models.annotation module
AnnotationAnnotation.__init__()Annotation.as_dict()Annotation.get_default_property_values()Annotation.is_valid_property()Annotation.remove()Annotation.update()Annotation.border_colorAnnotation.border_styleAnnotation.colorAnnotation.idAnnotation.thicknessAnnotation.typeAnnotation.x1Annotation.y1Annotation.z_index
AnnotationEllipseAnnotationLineAnnotationRectangleAnnotationText
- virl2_client.models.auth_management module
AuthManagementAuthManagement.__init__()AuthManagement.get_ldap_groups()AuthManagement.get_settings()AuthManagement.refresh_ldap_groups()AuthManagement.sync()AuthManagement.sync_if_outdated()AuthManagement.test_auth()AuthManagement.test_current_auth()AuthManagement.update_settings()AuthManagement.managerAuthManagement.method
AuthMethodManagerLDAPManagerLDAPManager.METHODLDAPManager.admin_search_filterLDAPManager.cert_data_pemLDAPManager.display_attributeLDAPManager.email_address_attributeLDAPManager.group_display_attributeLDAPManager.group_membership_filterLDAPManager.group_search_baseLDAPManager.group_search_filterLDAPManager.group_user_attributeLDAPManager.group_via_userLDAPManager.manager_dnLDAPManager.manager_passwordLDAPManager.resource_poolLDAPManager.root_dnLDAPManager.server_urlsLDAPManager.timeoutLDAPManager.use_ntlmLDAPManager.user_search_baseLDAPManager.user_search_filterLDAPManager.verify_tls
RADIUSManager
- virl2_client.models.authentication module
- virl2_client.models.cl_pyats module
- virl2_client.models.group module
GroupManagementGroupManagement.__init__()GroupManagement.associations()GroupManagement.create_group()GroupManagement.delete_group()GroupManagement.get_group()GroupManagement.group_id()GroupManagement.group_labs()GroupManagement.group_members()GroupManagement.groups()GroupManagement.update_associations()GroupManagement.update_group()
- virl2_client.models.groups module
- virl2_client.models.interface module
InterfaceInterface.__init__()Interface.as_dict()Interface.bring_up()Interface.get_link_to()Interface.remove()Interface.shutdown()Interface.connectedInterface.deployed_mac_addressInterface.discovered_ipv4Interface.discovered_ipv6Interface.discovered_mac_addressInterface.idInterface.ip_snooped_infoInterface.labelInterface.linkInterface.mac_addressInterface.nodeInterface.operationalInterface.peer_interfaceInterface.peer_nodeInterface.physicalInterface.readbytesInterface.readpacketsInterface.slotInterface.stateInterface.typeInterface.writebytesInterface.writepackets
- virl2_client.models.lab module
LabLab.__init__()Lab.annotations()Lab.build_configurations()Lab.cleanup_pyats_connections()Lab.clear_discovered_addresses()Lab.connect_two_nodes()Lab.create_annotation()Lab.create_interface()Lab.create_link()Lab.create_node()Lab.create_smart_annotation()Lab.details()Lab.download()Lab.find_nodes_by_tag()Lab.get_annotation_by_id()Lab.get_interface_by_id()Lab.get_link_by_id()Lab.get_node_by_id()Lab.get_node_by_label()Lab.get_pyats_testbed()Lab.get_smart_annotation_by_id()Lab.get_smart_annotation_by_tag()Lab.has_converged()Lab.import_lab()Lab.interfaces()Lab.is_active()Lab.links()Lab.need_to_wait()Lab.nodes()Lab.remove()Lab.remove_annotation()Lab.remove_annotations()Lab.remove_interface()Lab.remove_link()Lab.remove_node()Lab.remove_nodes()Lab.remove_smart_annotation()Lab.remove_smart_annotations()Lab.set_autostart()Lab.set_node_staging()Lab.smart_annotations()Lab.start()Lab.state()Lab.stop()Lab.sync()Lab.sync_events()Lab.sync_interfaces_operational()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_associations()Lab.update_connector_mappings()Lab.update_lab()Lab.update_lab_groups()Lab.update_lab_properties()Lab.wait_until_lab_converged()Lab.wipe()Lab.associationsLab.autostartLab.connector_mappingsLab.descriptionLab.groupsLab.idLab.node_stagingLab.notesLab.ownerLab.resource_poolsLab.statisticsLab.title
- virl2_client.models.lab_repository module
LabRepositoryLabRepositoryManagementLabRepositoryManagement.__init__()LabRepositoryManagement.add_lab_repository()LabRepositoryManagement.add_lab_repository_local()LabRepositoryManagement.get_lab_repositories()LabRepositoryManagement.get_lab_repository()LabRepositoryManagement.get_lab_repository_by_name()LabRepositoryManagement.refresh_lab_repositories()LabRepositoryManagement.sync_lab_repositories()LabRepositoryManagement.sync_lab_repositories_if_outdated()LabRepositoryManagement.lab_repositories
- virl2_client.models.licensing module
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_reservation_confirmation_code()Licensing.get_reservation_return_code()Licensing.register()Licensing.register_renew()Licensing.register_wait()Licensing.release_reservation()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.max_waitLicensing.wait_interval
- virl2_client.models.link module
LinkLink.__init__()Link.as_dict()Link.capture_status()Link.download_capture()Link.get_capture_packet()Link.get_capture_packets()Link.get_condition()Link.has_converged()Link.remove()Link.remove_condition()Link.set_condition()Link.set_condition_by_name()Link.start()Link.start_capture()Link.stop()Link.stop_capture()Link.wait_until_converged()Link.idLink.interface_aLink.interface_bLink.interfacesLink.labLink.labelLink.node_aLink.node_bLink.nodesLink.readbytesLink.readpacketsLink.stateLink.writebytesLink.writepackets
- virl2_client.models.node module
NodeNode.__init__()Node.add_tag()Node.clear_discovered_addresses()Node.clone_image()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()Node.remove_tag()Node.run_pyats_command()Node.run_pyats_config_command()Node.set_pyats_credentials()Node.start()Node.stop()Node.sync_interface_operational()Node.sync_interface_operational_if_outdated()Node.sync_l3_addresses_if_outdated()Node.sync_layer3_addresses()Node.sync_operational()Node.sync_operational_if_outdated()Node.tags()Node.update()Node.update_parameters()Node.vnc_key()Node.wait_until_converged()Node.wipe()Node.boot_disk_sizeNode.compute_idNode.configurationNode.configuration_filesNode.cpu_limitNode.cpu_usageNode.cpusNode.data_volumeNode.disk_readNode.disk_writeNode.hide_linksNode.idNode.image_definitionNode.labNode.labelNode.node_definitionNode.operationalNode.parametersNode.pinned_compute_idNode.priorityNode.pyats_credentialsNode.ramNode.resource_poolNode.smart_annotationsNode.stateNode.xNode.y
- virl2_client.models.node_image_definition module
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.set_image_definition_read_only()NodeImageDefinitions.set_node_definition_read_only()NodeImageDefinitions.upload_image_definition()NodeImageDefinitions.upload_image_file()NodeImageDefinitions.upload_node_definition()
print_progress_bar()
- virl2_client.models.node_image_definitions module
- virl2_client.models.resource_pool module
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_pools
ResourcePoolUsageResourcePoolUsageBase
- virl2_client.models.resource_pools module
- virl2_client.models.smart_annotation module
SmartAnnotationSmartAnnotation.__init__()SmartAnnotation.as_dict()SmartAnnotation.remove()SmartAnnotation.update()SmartAnnotation.border_colorSmartAnnotation.border_styleSmartAnnotation.fill_colorSmartAnnotation.group_distanceSmartAnnotation.idSmartAnnotation.is_onSmartAnnotation.labSmartAnnotation.labelSmartAnnotation.paddingSmartAnnotation.tagSmartAnnotation.tag_offset_xSmartAnnotation.tag_offset_ySmartAnnotation.tag_sizeSmartAnnotation.thicknessSmartAnnotation.z_index
- virl2_client.models.system module
ComputeHostComputeHost.__init__()ComputeHost.remove()ComputeHost.update()ComputeHost.admission_stateComputeHost.compute_idComputeHost.hostnameComputeHost.is_connectedComputeHost.is_connectorComputeHost.is_simulatorComputeHost.is_syncedComputeHost.node_countsComputeHost.nodesComputeHost.server_address
SystemManagementSystemManagement.__init__()SystemManagement.add_compute_host_local()SystemManagement.add_system_notice_local()SystemManagement.delete_external_connector()SystemManagement.get_external_connectors()SystemManagement.get_new_compute_host_state()SystemManagement.get_telemetry_events()SystemManagement.get_web_session_timeout()SystemManagement.set_new_compute_host_state()SystemManagement.set_web_session_timeout()SystemManagement.sync_compute_hosts()SystemManagement.sync_compute_hosts_if_outdated()SystemManagement.sync_system_notices()SystemManagement.sync_system_notices_if_outdated()SystemManagement.update_external_connector()SystemManagement.compute_hostsSystemManagement.controllerSystemManagement.maintenance_modeSystemManagement.maintenance_noticeSystemManagement.system_noticesSystemManagement.telemetrySystemManagement.telemetry_state
SystemNotice
- virl2_client.models.user module
UserManagementUserManagement.__init__()UserManagement.associations()UserManagement.create_user()UserManagement.delete_user()UserManagement.get_user()UserManagement.get_username()UserManagement.sync_users()UserManagement.sync_users_if_outdated()UserManagement.update_associations()UserManagement.update_user()UserManagement.user_groups()UserManagement.user_id()UserManagement.users()
- virl2_client.models.users module
Submodules
virl2_client.event_handling module
- class virl2_client.event_handling.Event(event_dict: dict[str, Any])
Bases:
object- __init__(event_dict: dict[str, Any])
An event object, stores parsed info about the event it represents.
- Parameters:
event_dict – A dictionary containing event data.
- class virl2_client.event_handling.EventHandler(client_library: ClientLibrary = None)
Bases:
EventHandlerBaseHandler for JSON events received from controller over websockets. Used by EventListener by default, but can be subclassed and methods overridden to change/extend the handling mechanism, then passed to EventListener.
- class virl2_client.event_handling.EventHandlerBase(client_library: ClientLibrary = None)
Bases:
ABC- __init__(client_library: ClientLibrary = None)
Abstract base class for event handlers.
Subclass this if you want to implement the entire event handling mechanism from scratch, otherwise subclass EventHandler instead.
- Parameters:
client_library – The client library which should be modified by events.
virl2_client.event_listening module
- class virl2_client.event_listening.EventListener(client_library: ClientLibrary)
Bases:
object- __init__(client_library: ClientLibrary)
Initialize an EventListener instance. EventListener creates and listens to a websocket connection to the server. Events are then sent to the EventHandler instance for handling. Use start_listening() to open and stop_listening() to close connection.
- Parameters:
client_library – Parent ClientLibrary instance which provides connection info and is modified when synchronizing.
- start_listening()
Start listening for events.
- stop_listening()
Stop listening for events.
virl2_client.exceptions module
- exception virl2_client.exceptions.APIError(message: str, *, request: Request, response: Response)
Bases:
VirlException,HTTPStatusError
- exception virl2_client.exceptions.AnnotationNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.ControllerNotFound
Bases:
VirlException- __init__() None
- 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.InvalidAnnotationType
Bases:
VirlException
- exception virl2_client.exceptions.InvalidContentType
Bases:
VirlException
- exception virl2_client.exceptions.InvalidImageFile
Bases:
VirlException
- exception virl2_client.exceptions.InvalidProperty
Bases:
VirlException
- exception virl2_client.exceptions.InvalidTopologySchema
Bases:
VirlException
- exception virl2_client.exceptions.LabNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.LabRepositoryNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.LinkNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.MethodNotActive
Bases:
VirlException
- exception virl2_client.exceptions.NodeNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.PyatsDeviceNotFound
Bases:
PyatsException
- exception virl2_client.exceptions.PyatsException
Bases:
VirlException
- exception virl2_client.exceptions.PyatsNotInstalled
Bases:
PyatsException
- exception virl2_client.exceptions.SmartAnnotationNotFound
Bases:
ElementNotFound
- exception virl2_client.exceptions.VirlException
Bases:
Exception
virl2_client.utils module
- class virl2_client.utils.OptInStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum- ACCEPTED = 'accepted'
- DECLINED = 'declined'
- UNSET = 'unset'
- class virl2_client.utils.property_s(fget=None, fset=None, fdel=None, doc=None)
Bases:
propertyA modified property that will check staleness.
- __init__(fget=None, fset=None, fdel=None, doc=None)
- virl2_client.utils.check_stale(func: TCallable) TCallable
A decorator that will make the wrapped function check staleness.
- virl2_client.utils.get_url_from_template(endpoint: str, url_templates: dict[str, str], values: dict | None = None) str
Generate the URL for a given API endpoint from given templates.
- Parameters:
endpoint – The desired endpoint.
url_templates – The templates to map values to.
values – Keyword arguments used to format the URL.
- Returns:
The formatted URL.
- virl2_client.utils.locked(func: TCallable) TCallable
A decorator that makes a method threadsafe. Parent class instance must have a _session.lock property for locking to occur.
virl2_client.virl2_client module
- class virl2_client.virl2_client.ClientConfig(url: str | None = None, username: str | None = None, password: str | None = None, jwtoken: str | None = None, ssl_verify: bool | str = True, allow_http: bool = False, auto_sync: float = 1.0, events: bool = False, raise_for_auth_failure: bool = True, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5, check_version: bool = True)
Bases:
NamedTupleStores client library configuration, which can be used to create any number of identically configured instances of ClientLibrary.
- classmethod get_configuration(url: str | None, username: str | None, password: str | None, jwtoken: str | None, ssl_verify: bool | str | None, allow_inputs: bool | None = None) ClientConfig
- make_client() ClientLibrary
- allow_http: bool
Alias for field number 5
- auto_sync: float
Alias for field number 6
- check_version: bool
Alias for field number 11
- convergence_wait_max_iter: int
Alias for field number 9
- convergence_wait_time: int | float
Alias for field number 10
- events: bool
Alias for field number 7
- jwtoken: str | None
Alias for field number 3
- password: str | None
Alias for field number 2
- raise_for_auth_failure: bool
Alias for field number 8
- ssl_verify: bool | str
Alias for field number 4
- 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, jwtoken: str | None = None, ssl_verify: bool | str | None = None, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5, events: bool = False, client_type: str = None, check_version: bool = True)
Bases:
objectPython bindings for the REST API of a CML controller.
- __init__(url: str | None = None, username: str | None = None, password: str | None = None, jwtoken: str | None = None, ssl_verify: bool | str | None = None, raise_for_auth_failure: bool = False, allow_http: bool = False, convergence_wait_max_iter: int = 500, convergence_wait_time: int | float = 5, events: bool = False, client_type: str = None, check_version: bool = True) None
- all_labs(show_all: bool = False) list[Lab]
Join all labs owned by this user (or all labs) and return their list.
- Parameters:
show_all – Whether to get only labs owned by the admin or all user labs.
- Returns:
A list of Lab objects.
- check_controller_version() Version | None
Check remote controller version against current client version (specified in self.VERSION and support last 3 minor versions). Raise exception if versions are incompatible, or print warning if the client minor version is lower than the controller minor version. These all are disabled if self.check_version attribute is set to False.
- Raises:
InitializationError – If the controller version is incompatible.
- Returns:
None
- create_lab(title: str | None = None, description: str | None = None, notes: str | None = None, autostart: dict | None = None, node_staging: dict | None = None) Lab
Create a new lab with optional title, description, and notes.
If no title, description, or notes are provided, the server will generate a default title in the format “Lab at Mon 13:30 PM” and leave the description and notes blank.
The lab will automatically sync based on the Client Library’s auto-sync setting when created, but this behavior can be overridden on a per-lab basis.
Example:
lab = client_library.create_lab() print(lab.id) lab.create_node("r1", "iosv", 50, 100)
- Parameters:
title – The title of the lab.
description – The description of the lab.
notes – The notes of the lab.
autostart – Parameter for autostart (enabled, priority, delay).
node_staging – Parameter for node staging (enabled, abort_on_failure, start_remaining).
- Returns:
A Lab instance representing the created lab.
- 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 matching the specified title.
- get_diagnostics(*categories: DiagnosticsCategory) dict
Return selected diagnostics data as a JSON object.
- Parameters:
categories – List of diagnostics categories to fetch. DEPRECATED: If not provided, provide DiagnosticsCategory.ALL to fetch all diagnostics data.
- Returns:
The diagnostics data.
- get_host() str
Return the hostname of the session to the controller.
- Returns:
The hostname.
- get_lab_list(show_all: bool = False) list[str]
Get the list of all lab IDs.
- Parameters:
show_all – Whether to include labs owned by all users (True) or only labs owned by the admin (False).
- Returns:
A list of lab IDs.
- get_local_lab(lab_id: str) Lab
Get a local lab by its ID.
- Parameters:
lab_id – The ID of the lab.
- Returns:
The Lab object with the specified ID.
- Raises:
LabNotFound – If the lab with the given ID does not exist.
- get_sample_labs() dict[str, dict]
Return a dictionary with information about all sample labs available on the host.
- Returns:
A dictionary of sample lab information where the keys are the titles.
- get_system_health() dict
Return the controller system health data as a JSON object.
- Returns:
The system health data.
- get_system_stats() dict
Return the controller resource statistics as a JSON object.
- Returns:
The system resource statistics.
- import_lab(topology: str, title: str | None = None, offline: bool | None = None, virl_1x: bool = False) Lab
Import an existing topology from a string.
- Parameters:
topology – The topology representation as a string.
title – The title of the lab.
offline – DEPRECATED: Offline mode has been removed.
virl_1x – Whether the topology format is the old, VIRL 1.x format.
- Returns:
The imported Lab instance.
- Raises:
ValueError – If no lab ID is returned in the API response.
httpx.HTTPError – If there was a transport error.
- import_lab_from_path(path: Path | str, title: str | None = None) Lab
Import an existing topology from a file or path.
- Parameters:
path – The topology filename or path.
title – The title of the lab.
- Returns:
The imported Lab instance.
- Raises:
FileNotFoundError – If the specified path does not exist.
- import_sample_lab(title: str) Lab
Import a built-in sample lab.
- Parameters:
title – The sample lab name.
- Returns:
The imported Lab instance.
- is_system_ready(wait: bool = False, max_wait: int = 60, sleep: int = 5) bool
Report whether the system is ready or not.
- Parameters:
wait – Whether to block until the system is ready.
max_wait – The maximum time to wait in seconds.
sleep – The time to wait between tries in seconds.
- Returns:
The ready state of the system.
- static is_virl_1x(path: Path) bool
Check if the given file is of VIRL version 1.x.
- Parameters:
path – The path to check.
- Returns:
Whether the file is of VIRL version 1.x.
- join_existing_lab(lab_id: str, sync_lab: bool = True) Lab
Join a lab that exists on the server and make it accessible locally.
If sync_lab is set to True, the current lab will be synchronized by applying any changes that were made in the UI or in another ClientLibrary session.
- Example::
lab = client_library.join_existing_lab(“2e6a18”)
- Parameters:
lab_id – The ID of the lab to be joined.
sync_lab – Whether to synchronize the lab.
- Returns:
A Lab instance representing the joined lab.
- Raises:
LabNotFound – If no lab with the given ID exists on the host.
- logout(clear_all_sessions: bool = False) bool
Invalidate the current token.
- Parameters:
clear_all_sessions – Whether to clear all user sessions as well.
- remove_lab(lab_id: str | Lab) None
Remove a lab identified by its ID or Lab object.
Use this method with caution as it permanently deletes the specified lab.
If you have the lab object, you can also do
lab.remove().- Parameters:
lab_id – The ID or Lab object representing the lab to be removed.
- start_event_listening()
Start listening for and parsing websocket events.
To replace the default event handling mechanism, subclass event_handling.EventHandler (or EventHandlerBase if necessary), then do:: from .event_listening import EventListener custom_listener = EventListener() custom_listener._event_handler = CustomHandler(client_library) client_library.event_listener = custom_listener
- Returns:
- stop_event_listening()
Stop listening for and parsing websocket events.
- system_info() dict
Get information about the system where the application runs. Can be called without authentication.
- Returns:
The system information as a JSON object.
- VERSION = 2.10.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.
- jwtoken: str | None
- password: str | None
- url: str
- username: str | None
- property uuid: str
Return the UUID4 that identifies this client to the server.
- class virl2_client.virl2_client.DiagnosticsCategory(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum- ALL = 'all'
- COMPUTES = 'computes'
- LABS = 'labs'
- LAB_EVENTS = 'lab_events'
- LICENSING = 'licensing'
- NODE_DEFINITIONS = 'node_definitions'
- NODE_LAUNCH_QUEUE = 'node_launch_queue'
- SERVICES = 'services'
- STARTUP_SCHEDULER = 'startup_scheduler'
- USER_LIST = 'user_list'