Skip to content

Kathara.model.Machine

tcaiazzi edited this page Dec 20, 2021 · 15 revisions

module Kathara.model.Machine


class Machine

A Kathara device.

Contains information about the device and the API object to interact with the Manager.

Attributes:

  • lab (Kathara.model.Lab): The Kathara network Scenario of the device.
  • name (str): The name of the device.
  • interfaces (List[Kathara.model.Link]): A list of the collision domains of the device.
  • meta (Dict[str, Any]): Keys are meta properties name, values are meta properties values.
  • startup_commands (List[str]): A list of commands to execute at the device startup.
  • api_object (Any): To interact with the current Kathara Manager.
  • capabilities (List[str]): The selected capabilities for the device.
  • startup_path (str): The path of the device startup file, if exists.
  • shutdown_path (str): The path of the device shutdown file, if exists.
  • folder (str): The path of the device folder, if exists.

method Machine.__init__

__init__(lab: 'LabPackage.Lab', name: str, **kwargs) → None

Create a new instance of a Kathara device.

Args:

  • lab (Kathara.model.Lab): The Kathara network scenario of the new device.
  • name (str): The name of the device.
  • **kwargs (Dict[str, Any]): Specifies the optional parameters of the device.

Returns: None


method Machine.add_interface

add_interface(link: 'LinkPackage.Link', number: int = None) → None

Add an interface to the device attached to the specified collision domain.

Args:

  • link (Kathara.model.Link): The Kathara collision domain to attach.
  • number (int): The number of the new interface. If it is None, the first free number is selected.

Returns: None

Raises:

  • Exception: The interface number specified is already used on the device.

method Machine.add_meta

add_meta(name: str, value: Any) → None

Add a meta property to the device.

Args:

  • name (str): The name of the property.
  • value (Any): The value of the property.

Returns: None

Raises:

  • MachineOptionError: The specified value is not valid for the specified property.

method Machine.check

check() → None

Sorts interfaces check if there are missing positions.

Returns: None

Raises:

  • NonSequentialMachineInterfaceError: If there is a missing interface number.

method Machine.connect

connect(terminal_name: str) → None

Connect to the device with the specified terminal.

Args:

  • terminal_name (str): The name of the terminal to use for the connection. The application must be correctly installed in the host system. This option is only visible on Linux and macOS. On Linux, options are /usr/bin/xterm, TMUX or an user-defined path. On macOS, options are Terminal (default system terminal), iTerm or TMUX.

Returns: None


method Machine.get_cpu

get_cpu(multiplier: int = 1) → Optional[int]

Get the CPU limit, multiplied by a specific multiplier.

User should pass a float value ranging from 0 to max user CPUs. Try to took it from options, or machine meta. Otherwise, return None.

Args: multiplier (int):

Returns:

  • Optional[int]: The CPU limit of the device.

method Machine.get_image

get_image() → str

Get the image of the device, if defined in options or machine meta. If not, use default one.

Returns:

  • str: The name of the device image.

method Machine.get_mem

get_mem() → str

Get memory limit, if defined in options. If not, use the value from device meta. Otherwise, return None.

Returns:

  • str: The memory limit of the device.

method Machine.get_num_terms

get_num_terms() → int

Get the number of terminal to be opened for the device.

Returns:

  • int: The number of terminal to be opened.

method Machine.get_ports

get_ports() → Optional[Dict[Tuple[int, str], int]]

Get the port mapping of the device.

Returns:

  • Dict[(int, str), int]: Keys are pairs (host_port, protocol), values specifies the guest_port.

method Machine.is_ipv6_enabled

is_ipv6_enabled() → bool

Check if IPv6 is enabled on the device.

Returns:

  • bool: True if it is enabled, else False.

method Machine.pack_data

pack_data() → Optional[bytes]

Pack machine data into a .tar.gz file and returns the tar content as a byte array.

While packing files, it also applies the win2linux patch in order to remove UTF-8 BOM.

Returns:

  • bytes: the tar content.

method Machine.update_meta

update_meta(args: Dict[str, Any]) → None

Update the device metas from a dict.

Args:

  • args (Dict[str, Any]): Keys are the meta properties names, values are the updated meta properties values.

Returns: None


This file was automatically generated via lazydocs.

Clone this wiki locally