-
Notifications
You must be signed in to change notification settings - Fork 63
Kathara.model.Lab
A Kathara network scenario, containing information about devices and collision domains.
Attributes:
-
name
(str): The name of the network scenario. -
description
(str): A short description of the network scenario. -
version
(str): The version of the network scenario. -
author
(str): The author of the network scenario. -
email
(str): The email of the author of the network scenario. -
web
(str): The web address of the author of the network scenario. -
path
(str): The path of the network scenario, if exists. -
hash
(str): The hash identifier of the network scenario. -
machines
(Dict[str, Kathara.model.Machine]): The devices of the network scenario. Keys are device names, Values are Kathara device objects. -
links
(Dict[str, Kathara.model.Link]): The collision domains of the network scenario. Keys are collision domains names, Values are Kathara collision domain objects. -
general_options
(Dict[str, Any]): Keys are option names, values are option values. -
has_dependencies
(bool): True if there are dependencies among the devices boot. shared_startup_path(str) The path of the shared startup file, if exists. shared_shutdown_path(str) The path of the shared shutdown file, if exists. shared_folder(str) The path of the shared folder, if exists.
__init__(name: Optional[str], path: Optional[str] = None) → None
Create a new instance of a Kathara network scenario.
Args:
-
name
(str): The name of the network scenario. -
path
(str): The path to the network scenario directory, if exists.
Returns: None
add_option(name: str, value: Any) → None
Add an option to the network scenario.
Args:
-
name
(str): The name of the option. -
value
(Any): The value of the option.
Returns: None
apply_dependencies(dependencies: List[str]) → None
Order the list of devices of the network scenario to satisfy the boot dependencies.
Args:
-
dependencies
(List[str]): If not empty, dependencies are applied.
Returns: None
assign_meta_to_machine(
machine_name: str,
meta_name: str,
meta_value: str
) → MachinePackage.Machine
Assign meta information to the specified device.
Args:
-
machine_name
(str): The name of the device. -
meta_name
(str): The name of the meta property. -
meta_value
(str): The value of the meta property.
Returns:
-
Kathara.model.Machine
: The Kathara device specified by the name.
Raises:
-
MachineOptionError
: If invalid values are specified for meta properties.
attach_external_links(
external_links: Dict[str, List[Kathara.model.ExternalLink.ExternalLink]]
) → None
Attach external collision domains to the network scenario.
Args:
-
external_links
(Dict[Kathara.model.Link, List[Kathara.model.ExternalLink]]): Keys are Link objects, values are ExternalLink objects.
Returns: None
Raises:
-
LinkNotFoundError
: If the external collision domain specified is not associated to the network scenario.
check_integrity() → None
Check if the network interfaces numbers of all the devices in the network scenario are correctly assigned.
Returns: None
connect_machine_to_link(
machine_name: str,
link_name: str,
machine_iface_number: int = None
) → Tuple[ForwardRef('MachinePackage.Machine'), Kathara.model.Link.Link]
Connect the specified device to the specified collision domain.
Args:
-
machine_name
(str): The device name. -
link_name
(str): The collision domain name. -
machine_iface_number
(int): The number of the device interface to connect. If it is None, the first free number is used.
Returns:
-
Tuple[Kathara.model.Machine, Kathara.model.Link]
: A tuple containing the Kathara device and collision domain specified by their names.
Raises:
-
Exception
: If an already used interface number is specified.
create_shared_folder() → None
If the network scenario has a directory, create the network scenario shared folder.
Returns: None
Raises:
-
IOError
: If the shared folder is a Symlink, delete it. -
OSError
: If there is a permission error.
find_machine(machine_name: str) → bool
Check if the specified device is in the network scenario.
Args:
-
machine_name
(str): The name of the device to search.
Returns:
-
bool
: True if the device is in the network scenario, else False.
find_machines(machine_names: Set[str]) → bool
Check if the specified devices are in the network scenario.
Args:
-
machine_names
(Set[str]): A set of strings containing the names of the devices to search.
Returns:
-
bool
: True if the devices are all in the network scenario, else False.
get_link(name: str) → Link
Get the specified collision domain.
Args:
-
name
(str): The name of the collision domain.
Returns:
-
Kathara.model.Link
: A Kathara collision domain.
Raises:
-
LinkNotFoundError
: If the specified link is not in the network scenario.
get_links_from_machines(
selected_machines: Union[List[str], Set[str]]
) → Set[str]
Return the name of the collision domains connected to the selected devices.
Args:
-
selected_machines
(Set[str]): A set with selected devices names.
Returns:
-
Set[str]
: A set of names of collision domains to deploy.
get_machine(name: str) → MachinePackage.Machine
Get the specified device.
Args:
-
name
(str): The name of the device
Returns:
-
Kathara.model.Machine
: A Kathara device.
Raises:
-
MachineNotFoundError
: If the device is not in the network scenario.
get_or_new_link(name: str) → Link
Get the specified collision domain. If it not exists, create and add it to the collision domains list.
Args:
-
name
(str): The name of the collision domain.
Returns:
-
Kathara.model.Link
: A Kathara collision domain.
get_or_new_machine(name: str, **kwargs: Dict[str, Any]) → MachinePackage.Machine
Get the specified device. If it not exists, create and add it to the devices list.
Args:
-
name
(str): The name of the device -
**kwargs (Dict[str, Any])
: Contains device meta information. Keys are meta property names, values are meta property values.
Returns:
-
Kathara.model.Machine
: A Kathara device.
has_path() → bool
Check if the network scenario has a directory.
Returns:
-
bool
: True if self.path is not None, else False.
new_link(name: str) → Link
Create the collision domain and add it to the collision domains list.
Args:
-
name
(str): The name of the collision domain.
Returns:
-
Kathara.model.Link
: A Kathara collision domain.
Raises:
-
LinkAlreadyExistsError
: If the specified link is already in the network scenario.
new_machine(name: str, **kwargs: Dict[str, Any]) → MachinePackage.Machine
Create and add the device to the devices list.
Args:
-
name
(str): The name of the device -
**kwargs (Dict[str, Any])
: Contains device meta information. Keys are meta property names, values are meta property values.
Returns:
-
Kathara.model.Machine
: A Kathara device.
Raises:
-
MachineAlreadyExistsError
: If the device is already in the network scenario.
Website: kathara.org
Contact us: contact@kathara.org