-
-
Notifications
You must be signed in to change notification settings - Fork 73
Kathara.foundation.manager.IManager
Interface to be implemented in the virtualization managers
check_image(image_name: str) → NoneCheck if the specified image is valid.
Args:
-
image_name(str): The name of the image
Returns: None
Raises:
-
ConnectionError: If the image is not locally available and there is no connection to a remote image repository. -
ImageNotFoundError: If the image is not found.
connect_machine_to_link(
machine: Kathara.model.Machine.Machine,
link: Kathara.model.Link.Link,
mac_address: Optional[str] = None
) → NoneConnect a Kathara device to a collision domain.
Args:
-
machine(Kathara.model.Machine): A Kathara machine object. -
link(Kathara.model.Link): A Kathara collision domain object. -
mac_address(Optional[str]): The MAC address to assign to the interface.
Returns: None
Raises:
-
LabNotFoundError: If the device specified is not associated to any network scenario. -
LabNotFoundError: If the collision domain is not associated to any network scenario. -
MachineCollisionDomainConflictError: If the device is already connected to the collision domain.
connect_tty(
machine_name: str,
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
shell: str = None,
logs: bool = False,
wait: Union[bool, Tuple[int, float]] = True
) → NoneConnect to a device in a running network scenario, using the specified shell.
Args:
-
machine_name(str): The name of the device to connect. -
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
shell(str): The name of the shell to use for connecting. -
logs(bool): If True, print startup logs on stdout. -
wait(Union[bool, Tuple[int, float]]): If True, wait indefinitely until the end of the startup commands execution before connecting. If a tuple is provided, the first value indicates the number of retries before stopping waiting and the second value indicates the time interval to wait for each retry. Default is True.
Returns: None
Raises:
-
InvocationError: If a running network scenario hash or name is not specified.
connect_tty_obj(
machine: Kathara.model.Machine.Machine,
shell: str = None,
logs: bool = False,
wait: Union[bool, Tuple[int, float]] = True
) → NoneConnect to a device in a running network scenario, using the specified shell.
Args:
-
machine(Machine): The device to connect. -
shell(str): The name of the shell to use for connecting. -
logs(bool): If True, print startup logs on stdout. -
wait(Union[bool, Tuple[int, float]]): If True, wait indefinitely until the end of the startup commands execution before connecting. If a tuple is provided, the first value indicates the number of retries before stopping waiting and the second value indicates the time interval to wait for each retry. Default is True.
Returns: None
Raises:
-
LabNotFoundError: If the specified device is not associated to any network scenario.
copy_files(
machine: Kathara.model.Machine.Machine,
guest_to_host: Dict[str, Union[str, io.IOBase]]
) → NoneCopy files on a running device in the specified paths.
Args:
-
machine(Kathara.model.Machine): A running device object. It must have the api_object field populated. -
guest_to_host(Dict[str, Union[str, io.IOBase]]): A dict containing the device path as key and a fileobj to copy in path as value or a path to a file.
Returns: None
deploy_lab(
lab: Kathara.model.Lab.Lab,
selected_machines: Optional[Set[str]] = None,
excluded_machines: Optional[Set[str]] = None
) → NoneDeploy a Kathara network scenario.
Args:
-
lab(Kathara.model.Lab): A Kathara network scenario. -
selected_machines(Optional[Set[str]]): If not None, deploy only the specified devices. -
excluded_machines(Optional[Set[str]]): If not None, exclude devices from being deployed.
Returns: None
deploy_link(link: Kathara.model.Link.Link) → NoneDeploy a Kathara collision domain.
Args:
-
link(Kathara.model.Link): A Kathara collision domain object.
Returns: None
Raises:
-
LabNotFoundError: If the collision domain is not associated to any network scenario.
deploy_machine(machine: Kathara.model.Machine.Machine) → NoneDeploy a Kathara device.
Args:
-
machine(Kathara.model.Machine): A Kathara machine object.
Returns: None
Raises:
-
LabNotFoundError: If the specified device is not associated to any network scenario.
disconnect_machine_from_link(
machine: Kathara.model.Machine.Machine,
link: Kathara.model.Link.Link
) → NoneDisconnect a Kathara device from a collision domain.
Args:
-
machine(Kathara.model.Machine): A Kathara machine object. -
link(Kathara.model.Link): The Kathara collision domain from which disconnect the device.
Returns: None
Raises:
-
LabNotFoundError: If the device specified is not associated to any network scenario. -
LabNotFoundError: If the collision domain is not associated to any network scenario. -
MachineCollisionDomainConflictError: If the device is not connected to the collision domain.
exec(
machine_name: str,
command: Union[List[str], str],
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
wait: Union[bool, Tuple[int, float]] = False,
stream: bool = True
) → Union[Kathara.foundation.manager.exec_stream.IExecStream.IExecStream, Tuple[bytes, bytes, int]]Exec a command on a device in a running network scenario.
Args:
-
machine_name(str): The name of the device to connect. -
command(Union[List[str], str]): The command to exec on the device. -
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
wait(Union[bool, Tuple[int, float]]): If True, wait indefinitely until the end of the startup commands execution before executing the command. If a tuple is provided, the first value indicates the number of retries before stopping waiting and the second value indicates the time interval to wait for each retry. Default is False. -
stream(bool): If True, return an IExecStream object. If False, returns a tuple containing the complete stdout, the stderr, and the return code of the command.
Returns:
-
Union[IExecStream, Tuple[bytes, bytes, int]]: An IExecStream object or a tuple containing the stdout, the stderr and the return code of the command.
Raises:
-
InvocationError: If a running network scenario hash or name is not specified. -
MachineNotRunningError: If the specified device is not running. -
MachineBinaryError: If the binary of the command is not found.
exec_obj(
machine: Kathara.model.Machine.Machine,
command: Union[List[str], str],
wait: Union[bool, Tuple[int, float]] = False,
stream: bool = True
) → Union[Kathara.foundation.manager.exec_stream.IExecStream.IExecStream, Tuple[bytes, bytes, int]]Exec a command on a device in a running network scenario.
Args:
-
machine(Machine): The device to connect. -
command(Union[List[str], str]): The command to exec on the device. -
wait(Union[bool, Tuple[int, float]]): If True, wait indefinitely until the end of the startup commands execution before executing the command. If a tuple is provided, the first value indicates the number of retries before stopping waiting and the second value indicates the time interval to wait for each retry. Default is False. -
stream(bool): If True, return an IExecStream object. If False, returns a tuple containing the complete stdout, the stderr, and the return code of the command.
Returns:
-
Union[IExecStream, Tuple[bytes, bytes, int]]: An IExecStream object or a tuple containing the stdout, the stderr and the return code of the command.
Raises:
-
LabNotFoundError: If the specified device is not associated to any network scenario. -
MachineNotRunningError: If the specified device is not running. -
MachineBinaryError: If the binary of the command is not found.
get_formatted_manager_name() → strReturn a formatted string containing the current manager name.
Returns:
-
str: A formatted string containing the current manager name.
get_lab_from_api(
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None
) → LabReturn the network scenario (specified by the hash or name), building it from API objects.
Args:
-
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name. If None, lab_name should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash. If None, lab_hash should be set.
Returns:
-
Lab: The built network scenario.
Raises:
-
InvocationError: If a running network scenario hash or name is not specified.
get_link_api_object(
link_name: str,
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
all_users: bool = False
) → AnyReturn the corresponding API object of a collision domain in a network scenario.
Args:
-
link_name(str): The name of the collision domain. -
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
all_users(bool): If True, return information about collision domains of all users.
Returns:
-
Any: API object of the collision domain specific for the current manager.
Raises:
-
InvocationError: If a running network scenario hash or name is not specified. -
LinkNotFoundError: If the collision domain is not found.
get_link_stats(
link_name: str,
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
all_users: bool = False
) → Generator[Optional[Kathara.foundation.manager.stats.ILinkStats.ILinkStats], NoneType, NoneType]Return information of the specified deployed network in a specified network scenario.
Args:
-
link_name(str): The name of the collision domain for which statistics are requested. -
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
all_users(bool): If True, return information about the networks of all users.
Returns:
-
Generator[Optional[ILinkStats], None, None]: A generator containing the ILinkStats object with the network info. Returns None if the network is not found.
Raises:
-
InvocationError: If a running network scenario hash or name is not specified.
get_link_stats_obj(
link: Kathara.model.Link.Link,
all_users: bool = False
) → Generator[Optional[Kathara.foundation.manager.stats.ILinkStats.ILinkStats], NoneType, NoneType]Return information of the specified deployed network in a specified network scenario.
Args:
-
link(Link): The collision domain for which statistics are requested. -
all_users(bool): If True, return information about the networks of all users.
Returns:
-
Generator[Optional[ILinkStats], None, None]: A generator containing the ILinkStats object with the network info. Returns None if the network is not found.
Raises:
-
LabNotFoundError: If the specified device is not associated to any network scenario.
get_links_api_objects(
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
all_users: bool = False
) → List[Any]Return API objects of collision domains in a network scenario.
Args:
-
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. -
all_users(bool): If True, return information about collision domains of all users.
Returns:
-
List[Any]: API objects of collision domains, specific for the current manager.
get_links_stats(
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
link_name: str = None,
all_users: bool = False
) → Generator[Dict[str, Kathara.foundation.manager.stats.ILinkStats.ILinkStats], NoneType, NoneType]Return information about deployed networks.
Args:
-
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. -
link_name(str): If specified return all the networks with link_name. -
all_users(bool): If True, return information about the networks of all users.
Returns:
-
Generator[Dict[str, ILinkStats], None, None]: A generator containing dicts that has API Object identifier as keys and ILinksStats objects as values.
get_machine_api_object(
machine_name: str,
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
all_users: bool = False
) → AnyReturn the corresponding API object of a running device in a network scenario.
Args:
-
machine_name(str): The name of the device. -
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
all_users(bool): If True, return information about devices of all users.
Returns:
-
Any: API object of the device specific for the current manager.
Raises:
-
InvocationError: If a running network scenario hash or name is not specified. -
MachineNotFoundError: If the specified device is not found.
get_machine_stats(
machine_name: str,
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
all_users: bool = False
) → Generator[Optional[Kathara.foundation.manager.stats.IMachineStats.IMachineStats], NoneType, NoneType]Return information of the specified device in a specified network scenario.
Args:
-
machine_name(str): The name of the device for which statistics are requested. -
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
all_users(bool): If True, search the device among all the users devices.
Returns:
-
Generator[Optional[IMachineStats], None, None]: A generator containing the IMachineStats object with the device info. Returns None if the device is not found.
Raises:
-
InvocationError: If a running network scenario hash or name is not specified.
get_machine_stats_obj(
machine: Kathara.model.Machine.Machine,
all_users: bool = False
) → Generator[Optional[Kathara.foundation.manager.stats.IMachineStats.IMachineStats], NoneType, NoneType]Return information of the specified device in a specified network scenario.
Args:
-
machine(Machine): The device for which statistics are requested. -
all_users(bool): If True, search the device among all the users devices.
Returns:
-
Generator[Optional[IMachineStats], None, None]: A generator containing the IMachineStats object with the device info. Returns None if the device is not found.
Raises:
-
LabNotFoundError: If the specified device is not associated to any network scenario. -
MachineNotRunningError: If the specified device is not running.
get_machines_api_objects(
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
all_users: bool = False
) → List[Any]Return API objects of running devices.
Args:
-
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. -
all_users(bool): If True, return information about devices of all users.
Returns:
-
List[Any]: API objects of devices, specific for the current manager.
get_machines_stats(
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
machine_name: str = None,
all_users: bool = False
) → Generator[Dict[str, Kathara.foundation.manager.stats.IMachineStats.IMachineStats], NoneType, NoneType]Return information about the running devices.
Args:
-
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. -
machine_name(str): If specified return all the devices with machine_name. -
all_users(bool): If True, return information about the device of all users.
Returns:
-
Generator[Dict[str, IMachineStats], None, None]: A generator containing dicts that has API Object identifier as keys and IMachineStats objects as values.
get_release_version() → strReturn the current manager version.
Returns:
-
str: The current manager version.
retrieve_files(
machine: Kathara.model.Machine.Machine,
src: str,
dst: str
) → NoneCopy files from a running device path to the host.
Args:
-
machine(Kathara.model.Machine): A running device object. It must have the api_object field populated. -
src(str): The path of the file or folder to copy from the device. -
dst(str): The destination path on the host.
Returns: None
undeploy_lab(
lab_hash: Optional[str] = None,
lab_name: Optional[str] = None,
lab: Optional[Kathara.model.Lab.Lab] = None,
selected_machines: Optional[Set[str]] = None,
excluded_machines: Optional[Set[str]] = None
) → NoneUndeploy a Kathara network scenario.
Args:
-
lab_hash(Optional[str]): The hash of the network scenario. Can be used as an alternative to lab_name and lab. If None, lab_name or lab should be set. -
lab_name(Optional[str]): The name of the network scenario. Can be used as an alternative to lab_hash and lab. If None, lab_hash or lab should be set. -
lab(Optional[Kathara.model.Lab]): The network scenario object. Can be used as an alternative to lab_hash and lab_name. If None, lab_hash or lab_name should be set. -
selected_machines(Optional[Set[str]]): If not None, undeploy only the specified devices. -
excluded_machines(Optional[Set[str]]): If not None, exclude devices from being undeployed.
Returns: None
Raises:
-
InvocationError: If a running network scenario hash or name is not specified.
undeploy_link(link: Kathara.model.Link.Link) → NoneUndeploy a Kathara collision domain.
Args:
-
link(Kathara.model.Link): A Kathara collision domain object.
Returns: None
Raises:
-
LabNotFoundError: If the collision domain is not associated to any network scenario.
undeploy_machine(machine: Kathara.model.Machine.Machine) → NoneUndeploy a Kathara device.
Args:
-
machine(Kathara.model.Machine): A Kathara machine object.
Returns: None
Raises:
-
LabNotFoundError: If the device specified is not associated to any network scenario.
update_lab_from_api(lab: Kathara.model.Lab.Lab) → NoneUpdate the passed network scenario from API objects.
Args:
-
lab(Lab): The network scenario to update.
wipe(all_users: bool = False) → NoneUndeploy all the running network scenarios.
Args:
-
all_users(bool): If false, undeploy only the current user network scenarios. If true, undeploy the running network scenarios of all users.
Returns: None
This file was automatically generated via lazydocs.
Website: kathara.org
Contact us: [email protected]