Kathara.manager.docker.DockerManager - KatharaFramework/Kathara GitHub Wiki

module Kathara.manager.docker.DockerManager


function check_docker_status

check_docker_status(method)

Decorator function to check if Docker daemon is running properly.


class DockerManager

The class responsible to interact between Kathara and the Docker APIs.


method DockerManager.connect_tty_obj

connect_tty_obj(
    machine: Kathara.model.Machine.Machine,
    shell: str = None,
    logs: bool = False,
    wait: Union[bool, Tuple[int, float]] = True
) → None

Connect 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.

method DockerManager.exec_obj

exec_obj(
    machine: Kathara.model.Machine.Machine,
    command: Union[List[str], str],
    wait: Union[bool, Tuple[int, float]] = False,
    stream: bool = True
) → Union[Kathara.manager.docker.exec_stream.DockerExecStream.DockerExecStream, 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 a DockerExecStream object. If False, returns a tuple containing the complete stdout, the stderr, and the return code of the command.

Returns:

  • Union[DockerExecStream, Tuple[bytes, bytes, int]]: A DockerExecStream 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.
  • ValueError: If the wait values is neither a boolean nor a tuple, or an invalid tuple.

method DockerManager.get_formatted_manager_name

get_formatted_manager_name() → str

Return a formatted string containing the current manager name.

Returns:

  • str: A formatted string containing the current manager name.

method DockerManager.get_link_stats_obj

get_link_stats_obj(
    link: Kathara.model.Link.Link,
    all_users: bool = False
) → Generator[Optional[Kathara.manager.docker.stats.DockerLinkStats.DockerLinkStats], 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.
  • PrivilegeError: If all_users is True and the user does not have root privileges.

method DockerManager.get_machine_stats_obj

get_machine_stats_obj(
    machine: Kathara.model.Machine.Machine,
    all_users: bool = False
) → Generator[Optional[Kathara.manager.docker.stats.DockerMachineStats.DockerMachineStats], 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.
  • PrivilegeError: If all_users is True and the user does not have root privileges.

This file was automatically generated via lazydocs.

⚠️ **GitHub.com Fallback** ⚠️