controller module¶
Module ‘controller’ serves to connect the view objects with the data objects.
-
class
controller.
Controller
(gui)¶ Bases:
object
Defines methods to fill the view and to react to occuring events.
-
connect_signals
()¶ Connect signals from the view with corresponding methods.
-
export_data
()¶ Gather network data for export.
Returns: Dictionary with network data (hierarchy levels, names, layout positions) and defined paths. Return type: dict
-
gui_connection_fill_interfaces
()¶ Push available network interface modules into the view.
-
gui_defined_paths_add
(path)¶ Add a defined path to the Defined paths widget.
Parameters: path (data.DefinedPath) – Defined path to add.
-
gui_element_detailed
(grph_element)¶ Set the chosen device to be detailed in the Detail panel.
Parameters: grph_element (gui.canvas.Datapath or gui.canvas.Node) – Graphical element of the device to be detailed.
-
gui_element_selected
(grph_element)¶ Add the chosen device into or remove from the defined path.
Parameters: grph_element (gui.canvas.Datapath or gui.canvas.Node) – Graphical element of the device to be detailed.
Turn path definition on or off depeneding on the chosen panel.
Parameters: tab_index (int) – Index number of the current panel.
-
import_data
(mashup)¶ Import network data.
Parameters: mashup (dict) – Dictionary with network data and defined paths.
-
layout_tree
()¶ Change the layout to a tree-like structure.
-
network_connection_close
()¶ Close the network connection.
-
network_connection_open
()¶ Open a network connection and perform subsequent tasks.
-
network_level_change
(grph_element, old_level, new_level)¶ Change the hierarchy level for the given datapath.
Parameters: - grph_element (gui.canvas.Datapath) – Graphical element of the datapath to change.
- old_level (enums.DeviceType) – Old level of the datapath.
- new_level (enums.DeviceType) – New level of the datapath.
-
network_load
()¶ Load network data from an external file.
-
network_name_change
(name)¶ Change the name for the given device.
Parameters: name (string) – Name to set.
-
network_remove_path
(row)¶ Remove a defined path from the local storage.
Parameters: row (int) – Row number of the path to remove.
-
network_save
()¶ Save network data to an external file.
-
network_update
(changes)¶ Process changes in the network.
Parameters: changes (interfaces.Update) – A summary of changes in the network.
-
path_clear
()¶ Clear the path definition.
-
path_complete_state_changed
(state)¶ Take actions when the path is complete or made incomplete.
Parameters: state (bool) – True if the path is complete, False otherwise.
-
path_confirm
()¶ Confirm the path definition.
-
path_deselect_elements
(net_elements)¶ Graphically deselect given elements.
Parameters: net_elements (list of intertfaces.Datapath or interfaces.Node) – A list of network devices to be deselected in the visualization.
-
path_discard
()¶ Discard the defined path.
-
path_remove_element
(net_element)¶ Remove the given network device from the defined path.
Parameters: net_element (interfaces.Datapath or interfaces.Node) – Network device to remove from the defined path.
-
path_remove_from_table
(index)¶ Remove a part of the path based on element selected in the table.
Parameters: index (int) – Index of the double clicked item.
-
-
class
controller.
EnumEncoder
(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶ Bases:
json.encoder.JSONEncoder
Custom encoder to transform Enum objects into the JSON format.
-
default
(obj)¶ Returns a serializable object for the given object.
Parameters: obj (object) – Object to be serialized. Returns: Serialized representation of the given object. Return type: string
-
-
class
controller.
Path
(controller, table)¶ Bases:
object
Keeps track of the path that is being defined.
-
add_element
(net_element)¶ Add a network device to the path.
Parameters: net_element (interfaces.Datapath or interfaces.Node) – Network device to add. Returns: - bool – True if the device has been successfully added.
- enums.Alert – In case the device could not have been added for a certain reason.
-
add_to_table
(net_element)¶ Add a network device to the path definition table.
Parameters: net_element (interfaces.Datapath or interfaces.Node) – Network device to add.
-
change_datapath_level
(net_element, new_level)¶ Change the hierarchy level of a datapath in the path.
Parameters: - net_element (interfaces.Datapath) – Datapath to change.
- new_level (enums.DeviceType) – New hierarchy level to set.
-
clear
()¶ Clear the defined path.
Returns: List of devices to graphically remove from the path. Return type: list
-
complete
(state)¶ Change the state of the path definition.
Parameters: state (bool) – Whether the path is complete (True) or incomplete (False).
-
element_on_row
(row)¶ Get the element placed on the given row.
Parameters: row (int) – Row number. Returns: - interfaces.Datapath – In case a datapath is placed on the row.
- interfaces.Node – In case a node is placed on the row.
- None – In case the index is out of range.
-
remove_element
(net_element, confirmed=False)¶ Remove a network device from the path.
Parameters: - net_element (interfaces.Datapath or interfaces.Node) – Network device to remove.
- confirmed (bool or int) – Whether a question dialog has been confirmed or not. If yes, it contains the Enum numeric value.
Returns: - list – List of devices to graphically remove from the path.
- enums.AlertQuestion – In case the removal has to be confirmed.
-
-
class
controller.
UpdateWorker
(network, interval, gui)¶ Bases:
PyQt5.QtCore.QObject
Provides the functionality for network updates.
-
connectionClosed
¶
-
update
()¶ Request a network update and emit a signal with the changes.
-
updateFinished
¶
-
-
controller.
as_enum
(d)¶ Return Enum object for its string representation.
Parameters: d (dict) – Dictionary object. Returns: - Enum – In case the dictionary value is a representation of Enum.
- dict – In case the dictionary value is not a representation of Enum.