Developer Interface¶
This part of the documentation covers all the interfaces of WEmulate.
Database and TC Interface¶
wemulate.ext.utils.add_connection(connection_name, first_logical_interface, second_logical_interface)
¶
Creates a new connection in the database and adds a linux bridge on the host system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection which should be created. |
required |
first_logical_interface |
str
|
Name of the first logical interface. |
required |
second_logical_interface |
str
|
Name of the second logical interface. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/add.py
wemulate.ext.utils.add_parameter(connection_name, parameters, direction)
¶
Add parameters to the already configured parameters on the given connection. If a direction is provided, the parameter will be applied only on the given direction. If not, the parameter will be applied in both directions (bidirectional, in-/outgoing).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection on which the parameters should be configured. |
required |
parameters |
Dict[str, float]
|
Parameters which should be configured. |
required |
direction |
Optional[str]
|
Direction on which the parameter should be applied (bidirectional if None) |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/add.py
wemulate.ext.utils.set_parameter(connection_name, parameters, direction)
¶
Set parameters on the given connection. Replaces all parameters which are configured. If a direction is provided, the parameter will be applied only on the given direction. If not, the parameter will be applied in both directions (bidirectional, in-/outgoing).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection on which the parameters should be configured. |
required |
parameters |
Dict[str, float]
|
Parameters which should be configured. |
required |
direction |
Optional[str]
|
Direction on which the parameter should be applied (bidirectional if None) |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/set.py
wemulate.ext.utils.create_or_update_parameters_in_db(connection, parameters, direction, current_parameters=Dict[str, Dict[str, int]])
¶
Creates and updates parameters in the database.
Args: connection: Connection object on which the updates should be made. parameters: Parameters which should be updated. direction: Direction on which the parameter should be applied (bidirectional if None) current_parameters: Current parameters which should be updated.
Returns: Returns the current_parameters which are set in the database.
Source code in wemulate/ext/utils/common.py
wemulate.ext.utils.set_parameters_with_tc(connection, parameters, direction)
¶
Set parameters on the host system on the given connection.
Args: connection: Connection object on which the updates should be made. parameters: Parameters which should be configured. direction: Direction on which the parameter should be applied (bidirectional if None)
Returns: None
Source code in wemulate/ext/utils/common.py
wemulate.ext.utils.delete_parameters_in_db(parameters, current_parameters, connection, direction)
¶
Delete specific parameters in db.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters |
Dict[str, int]
|
Parameters which should be deleted. |
required |
current_parameters |
Dict[str, Dict[str, int]]
|
The current parameters of the connection. |
required |
connection |
ConnectionModel
|
Connection object on which the updates should be made. |
required |
direction |
Optional[str]
|
Direction on which the parameter should be applied (bidirectional if None) |
required |
Returns:
Type | Description |
---|---|
Dict[str, Dict[str, int]]
|
Returns the current parameters in the database. |
Source code in wemulate/ext/utils/common.py
wemulate.ext.utils.get_current_applied_parameters(connection_name)
¶
Retrieve the connection object and its current applied parameters.
Args: connection_name: The name of the connection
Returns: Returns the connection object (ConnectionModel) and the current_parameters which are currently set.
Source code in wemulate/ext/utils/common.py
wemulate.ext.utils.delete_connection(connection_name)
¶
Delete connection with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection which should be deleted. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/delete.py
wemulate.ext.utils.delete_parameter(connection_name, parameters, direction)
¶
Delete specific parameters on the given connection. If a direction is provided, the parameter will be removed only on the given direction. If not, the parameter will be removed in both directions (bidirectional, in-/outgoing).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection on which the parameters should be deleted. |
required |
parameters |
Dict[str, int]
|
Parameters which should be deleted. |
required |
direction |
Optional[str]
|
The direction on which the parameter should be removed (bidirectional if None) |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/delete.py
wemulate.ext.utils.reset_connection(connection_name)
¶
Deletes all parameter on a specific connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection which should be reset |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/reset.py
wemulate.ext.utils.reset_device()
¶
Deletes all parameters and connection in the database and on the host system.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/reset.py
wemulate.ext.utils.get_physical_interface_names(first_logical_interface, second_logical_interface)
¶
Get the physical interface names for the logical interface names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
first_logical_interface |
str
|
First logical interface name. |
required |
second_logical_interface |
str
|
Second logical interface name. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
Tuple of strings. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.get_logical_interface_by_name(logical_interface_name)
¶
Return the logical interface object for a given name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logical_interface_name |
str
|
Logical interface name. |
required |
Returns:
Type | Description |
---|---|
Optional[LogicalInterfaceModel]
|
Returns a logical interface object. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.connection_exists_in_db(connection_name)
¶
Returns a true if a connection exists in the database
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Connection name. |
required |
Returns:
Type | Description |
---|---|
bool
|
Returns a boolean. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.get_connection_by_name(connection_name)
¶
Returns a a connection object for a connection name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Connection name. |
required |
Returns:
Type | Description |
---|---|
ConnectionModel
|
Returns a connection object. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.get_connection_by_id(connection_id)
¶
Returns a a connection object by its unique id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_id |
int
|
Connection id. |
required |
Returns:
Type | Description |
---|---|
ConnectionModel
|
Returns a connection object. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.get_logical_interface_by_physical_name(physical_interface_name)
¶
Returns the logical interface object for a physical interface name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
physical_interface_name |
str
|
Name of the physical interface. |
required |
Returns:
Type | Description |
---|---|
LogicalInterfaceModel
|
Returns a logical interface object. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.get_logical_interface_by_id(logical_interface_id)
¶
Returns the logical interface object for the logical interface id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logical_interface_id |
int
|
The unique identifier for the specific logical interface. |
required |
Returns:
Type | Description |
---|---|
LogicalInterfaceModel
|
Returns a logical interface object. |
Source code in wemulate/ext/utils/retrieve.py
wemulate.ext.utils.get_connection_list()
¶
Returns all existing connection objects as a list.
Returns:
Type | Description |
---|---|
List[ConnectionModel]
|
Returns a list of connection objects. |
wemulate.ext.utils.reset_connection(connection_name)
¶
Deletes all parameter on a specific connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_name |
str
|
Name of the connection which should be reset |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/reset.py
wemulate.ext.utils.reset_device()
¶
Deletes all parameters and connection in the database and on the host system.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/utils/reset.py
Setting and Configuration Interface¶
wemulate.ext.settings.get_interface_ip(interface)
¶
Returns the ip address of an interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface |
str
|
Name of the interface. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
Returns the ip address as string. |
Source code in wemulate/ext/settings/device.py
wemulate.ext.settings.get_interface_mac_address(interface)
¶
Returns the mac address of an interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface |
str
|
Name of the interface. |
required |
Returns:
Type | Description |
---|---|
str
|
Returns the mac address as string. |
Source code in wemulate/ext/settings/device.py
wemulate.ext.settings.get_mgmt_interfaces()
¶
Returns all management interfaces saved in the database.
Returns:
Type | Description |
---|---|
List[str]
|
Returns the management interfaces as list of strings. |
Source code in wemulate/ext/settings/device.py
wemulate.ext.settings.get_all_interfaces_on_device()
¶
Returns all interfaces on the device.
Returns:
Type | Description |
---|---|
List[str]
|
Returns a list of interfaces. |
wemulate.ext.settings.add_mgmt_interface(interface_name)
¶
Adds an interface as management interfaces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface_name |
str
|
Name of the interface |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wemulate/ext/settings/device.py
wemulate.ext.settings.get_non_mgmt_interfaces()
¶
Returns all interfaces which usable to connect different devices (all non-mgmt interfaces).
Returns:
Type | Description |
---|---|
List[str]
|
Returns the interfaces as list of strings. |
Source code in wemulate/ext/settings/device.py
wemulate.ext.settings.check_if_mgmt_interface_set()
¶
wemulate.ext.settings.get_db_location()
¶
Returns the database path.
Returns:
Type | Description |
---|---|
str
|
Returns the path to the database as string. |
wemulate.ext.settings.check_if_interface_present_on_device(interface_name)
¶
Exceptions¶
wemulate.core.exc.WEmulateError
¶
wemulate.core.exc.WEmulateValidationError
¶
wemulate.core.exc.WEmulateExecutionError
¶
wemulate.core.exc.WEmulateConfigNotFoundError
¶
wemulate.core.exc.WEmulateFileError
¶
wemulate.core.exc.WEmulateDatabaseError
¶
wemulate.core.exc.WemulateMgmtInterfaceError
¶
Bases: WEmulateError
Management Interface not found error