-
-
Notifications
You must be signed in to change notification settings - Fork 76
Kathara.model.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(collection.OrderedDict[int, 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.
__init__(lab: 'LabPackage.Lab', name: str, **kwargs) → NoneCreate 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
add_interface(link: 'LinkPackage.Link', number: int = None) → NoneAdd 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:
-
MachineCollisionDomainConflictError: If the interface number specified is already used on the device. -
MachineCollisionDomainConflictError: If the device is already connected to the collision domain.
add_meta(name: str, value: Any) → NoneAdd 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: If the specified value is not valid for the specified property.
check() → NoneSorts interfaces check if there are missing positions.
Returns: None
Raises:
-
NonSequentialMachineInterfaceError: If there is a missing interface number.
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 take it from options, or device meta. Otherwise, return None.
Args:
-
multiplier(int): A numeric multiplier for the CPU limit value.
Returns:
-
Optional[int]: The CPU limit of the device.
Raises:
-
MachineOptionError: If the CPU value specified is not valid.
get_image() → strGet the image of the device, if defined in options or device meta. If not, use default one.
Returns:
-
str: The name of the device image.
get_mem() → strGet 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.
Raises:
-
MachineOptionError: If the memory value specified is not valid.
get_num_terms() → intGet the number of terminal to be opened for the device.
Returns:
-
int: The number of terminal to be opened.
Raises:
-
MachineOptionError: If the terminals number value specified is not valid.
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.
is_ipv6_enabled() → boolCheck if IPv6 is enabled on the device.
Returns:
-
bool: True if it is enabled, else False.
Raises:
-
MachineOptionError: If the IPv6 value specified is not valid.
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.
remove_interface(link: 'LinkPackage.Link') → NoneDisconnect the device from the specified collision domain.
Args:
-
link(Kathara.model.Link): The Kathara collision domain to disconnect.
Returns: None
Raises:
-
MachineCollisionDomainConflictError: If the device is not connected to the collision domain.
update_meta(args: Dict[str, Any]) → NoneUpdate 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.
Website: kathara.org
Contact us: contact@kathara.org