Connections API¶
Connection
’s will be used to connect Device
’s with each other. It does not matter whether
the device is a Scenario
device or a Setup
device.
Every connection object has to inherit from the class Connection
directly. It is important to note that
the connection tree is not realized via the normal Python inheritance, but by an internal representation. More details
see Connections.
Basic Connection
¶
The basic Connection
class is the master class of every connection. It can always be used as container for
your sub-tree connection too.
- class balder.Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
This is the basic connection class. On one side it is the common base class for all connection objects. On the other side it can also be used to describe a container connection, that contains a list of different connection items.
- append_to_based_on(*args: Tuple[Union[Type[_balder.connection.Connection], _balder.connection.Connection]]) None ¶
with this method you can extend the internal based_on list with the transferred elements. Any number of
Connection()
objects or tuples withConnection()
objects can be given to this method- Parameters
args – all connection items that should be added here
- classmethod based_on(*args: Union[Tuple[Union[Type[_balder.connection.Connection], _balder.connection.Connection], ...], Type[_balder.connection.Connection], _balder.connection.Connection]) _balder.connection.Connection ¶
With this method it is possible to define several sublayers of the connection. You can pass various other connections in this method as arguments.
Note that multiple parameters of this method (but also of all other methods that work with Connections) mean an OR operation. So if you define a BaseConnType.based_on(ConnType1, ConnType2) it means that your connection BaseConnType is based on a ConnType1 or a ConnType2.
In order to describe an AND operation, i.e. that the BaseConnType is based on a` ConnType1` and a ConnType2, you have to pass them as a tuple. This would look like this: BaseConnType.based_on((ConnType1, ConnType2))
- Parameters
args – all connection items for which this connection is based on
- property based_on_elements: List[Union[_balder.connection.Connection, Tuple[_balder.connection.Connection]]]¶
returns a copy of the internal based_on_connection
- static check_if_tuple_contained_in_connection(tuple_elem: Tuple[_balder.connection.Connection], other_elem: _balder.connection.Connection) bool ¶
This method checks if the tuple given by tuple_elem is contained in the other_elem. To ensure that a tuple element is contained in a connection tree, there has to be another tuple into the other_elem, that has the same length or is bigger. In addition, there has to exist an order combination where every element of the tuple_elem is contained in the found tuple in other_elem. In this case it doesn’t matter where the tuple is in other_elem (will be converted to single, and tuple will be searched in all BASED_ON elements). If the tuple element of other_elem has fewer items than our tuple_elem, it will be ignored. The method only search for a valid existing item in the other_elem tuple for every item of the tuple_elem.
- Parameters
tuple_elem – the tuple element that should be contained in the other_elem
other_elem – the connection object, the given tuple should be contained in
- static cleanup_connection_list(full_list: List[Union[_balder.connection.Connection, Tuple[_balder.connection.Connection]]]) List[Union[_balder.connection.Connection, Tuple[_balder.connection.Connection]]] ¶
This method cleanup a connection list while removing items that are direct duplicates and by removing duplicates that are fully contained_in other items.
- Parameters
full_list – the full list of connections and tuples of connections that should be cleaned-up
- Returns
returns the cleaned up list
- clone() _balder.connection.Connection ¶
This method returns an exact clone of this connection. For this clone every inner connection object will be newly instantiated, but all internal references (like the devices and so on) will not be copied (objects are the same for this object and the clone). The method will make a normal copy for every connection object in the _based_on_elements list.
- contained_in(other_conn: _balder.connection.Connection, ignore_metadata=False) bool ¶
This method helps to find out whether this connection-tree fits within a given connection tree. A connection object is a certain part of the large connection tree that Balder has at its disposal. This method checks whether a possibility of this connection tree fits in one possibility of the given connection tree.
Note
The method returns true if one single connection of this object fits in another single connection that is given by other_conn.
- Parameters
other_conn – the other connection
ignore_metadata – if this value is true the method ignores the metadata
- Returns
true if the self object is contained in the other_conn, otherwise false
- static convert_tuple_to_singles(tuple_elem: Tuple[_balder.connection.Connection]) List[Union[_balder.connection.Connection, Tuple[_balder.connection.Connection]]] ¶
This method converts the given tuple_elem to single items and return these.
- Parameters
tuple_elem – the tuple element out of which the single items are being created
- Returns
a list of new connection objects that are single items
- cut_into_all_possible_subtrees() List[Union[_balder.connection.Connection, Tuple[_balder.connection.Connection]]] ¶
This method cuts the resolved connection tree in all possible pieces by removing elements that change the existing tree - thereby the method returns a list with all possibilities (a copy of this object with all elements is contained too).
Note
Note that the given element or the child elements of a given direct
Connection
object has to be single!
- equal_with(other_conn: _balder.connection.Connection, ignore_metadata=False) bool ¶
This method returns True if the current object matches the given object. It always converts the elements to a resolved version and checks if both of them are exactly the same.
Note
Note that both Connection objects have to have the same ending parent elements. Only the order of the parent elements are obviously irrelevant.
Note
Note that it doesn’t matter if the connection is embedded in a container-Connection element (direct instance of :class`Connection`) or not. It only checks, that the logical data of them are the same. If both elements are a container for a list of child connections, the method secures that both has the same children. If only one (same for both) has one child connection which is embedded in a container
Connection
class, it returns also true if the other connection is like the one child element of the other containerConnection
.- Parameters
other_conn – the other connection, this connection will be compared with
ignore_metadata – if this value is true the method ignores the metadata
- Returns
returns True if both elements are same
- property from_device¶
device from which the connection starts
- property from_node_name¶
the name of the node in the Device from which the connection starts
- get_conn_partner_of(device: Type[_balder.device.Device], node: Optional[str] = None) Tuple[Type[_balder.device.Device], str] ¶
This method returns the connection partner of this connection - it always returns the other not given side
- Parameters
device – the device itself - the other will be returned
node – the node name of the device itself (only required if the connection starts and ends with the same device)
- classmethod get_parents(tree_name: Optional[str] = None) List[Type[_balder.connection.Connection]] ¶
This method returns the parent classes of this connection.
- Parameters
tree_name – the tree name the parents should be returned (default: use tree defined in GlobalSetting)
- get_resolved() _balder.connection.Connection ¶
This method returns a resolved Connection Tree. This means that it convert the based_on references so that every based on connection is a direct parent of the current element. It secures that there are no undefined connection layers between an object and the given parent.
Note
This method returns the connection without a container
Connection
, if the containerConnection
would only consist of one single connection (which is no tuple!). In this case the method returns this child connection directly without anyConnection
container otherwise theConnection
container class with all resolved child classes will be returned.
- get_singles() List[_balder.connection.Connection] ¶
This method returns a list with connection objects where every element is a single clear possibility of the current connection sub-tree. With this method the OR possibilities will be resolved, so that every item does not contain any OR relations.
Note
If the current object is a container
Connection
object (direct instance ofConnection
), this method returns the single elements without a container class!
- get_tree_str() str ¶
This method returns a string, that represents all internal connections as readable string.
- Returns
a readable string of the whole connection tree
- has_connection_from_to(start_device, end_device=None)¶
This method checks if there is a connection from
start_device
toend_device
. This will return true if thestart_device
andend_device
given in this method are also thestart_device
andend_device
mentioned in this connection object. If this is a bidirectional connection,start_device
andend_device
can switch places.- Parameters
start_device – the device for which the method should check whether it is a communication partner (for non-bidirectional connection, this has to be the start device)
end_device – the other device for which the method should check whether it is a communication partner (for non-bidirectional connection, this has to be the end device - this is optional if only the start device should be checked)
- Returns
returns true if the given direction is possible
- intersection_with(other_conn: Union[Connection, Type[Connection], List[Connection, Type[Connection], Tuple[Connection]]]) Union[Connection, None] ¶
This method returns a list of subtrees that describe the intersection of this connection subtree and the given ones. Note that this method converts all connections in single resolved connections first. For these connections the method checks if there are common intersections between the elements of this object and the given connection elements. The method cleans up this list and only return unique sub-connection trees!
- Parameters
other_conn – the other sub connection tree list
- Returns
the intersection connection or none, if the method has no intersection
- is_bidirectional()¶
Provides the information in which direction the connection is supported (if the property returns true, the connection must work in both directions, otherwise it is a unidirectional connection from the from_device to the` to_device`
- classmethod is_child_of(other_conn: Type[_balder.connection.Connection]) bool ¶
determines whether this connection is a child of the given connection
- classmethod is_parent_of(other_conn: Type[_balder.connection.Connection]) bool ¶
determines whether this connection is a parent of the given connection
- is_resolved()¶
This method returns true if the given (sub-)connection tree is completely resolved (describes every single Connection object of the tree - there are no undefined connection layers between an object and the given parent).
- is_single()¶
This method returns true if there exists no logical OR in the based on connection(s). One AND tuple is allowed.
Note
Note that this method also returns False, if the connection is not completely resolved!
- is_universal()¶
Provides the information if the current connection object is a universal connection. This means, that the type is the base
Connection
and the based_on_elements are empty.
- property metadata: dict¶
returns the connection metadata dictionary
- set_devices(from_device: Type[_balder.device.Device], to_device: Type[_balder.device.Device])¶
Method for setting the devices of the connection if this has not yet been done during instantiation
Note
Note that you can not change the devices after they were set (only possible internally)
- Parameters
from_device – device from which the connection starts
to_device – device at which the connection ends
- set_metadata_for_all_subitems(metadata: Optional[Dict[str, Union[_balder.device.Device, str]]])¶
This method sets the metadata for all existing Connection items in this element.
- Parameters
metadata – the metadata that should be set (if the value is explicitly set to None, it removes the metadata from every item)
- classmethod set_parents(data: Optional[List[Type[_balder.connection.Connection]]], tree_name: str = '')¶
This method allows to set the data for the parent classes of this connection - note that None will remove the entry and completely disconnect this object from the global connection tree
- Parameters
data – the new parents (None if everything should be reset)
tree_name – the tree name of the parents that should be set (default: global tree)
- property to_device¶
device at which the connection ends
- property to_node_name¶
the name of the node in the Device at which the connection ends
- update_node_names(from_device_node_name: str, to_device_node_name: str) None ¶
This method dates the names of the nodes from which the connection in the from_device originates and finally arrives in the` to_device`. Please provide the node name of your
from_device
infrom_device_node_name
and the node name of yourto_device
into_device_node_name
.- Parameters
from_device_node_name – specifies the node in the
from_device
to_device_node_name – specifies the node in the
to_device
OSI Layer 1: Physical Layer¶
- class balder.connections.BluetoothConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Bluetooth connection (OSI LAYER 1)
- class balder.connections.CanBusConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder CAN-Bus connection (OSI LAYER 1)
- class balder.connections.CoaxialCableConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Coaxial-Cable connection (OSI LAYER 1)
- class balder.connections.DslConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder DSL connection (OSI LAYER 1)
- class balder.connections.RS232Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder RS232 connection (OSI LAYER 1)
- class balder.connections.RS422Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder RS422 connection (OSI LAYER 1)
- class balder.connections.RS485Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder RS485 connection (OSI LAYER 1)
- class balder.connections.IsdnConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder ISDN connection (OSI LAYER 1)
- class balder.connections.I2CConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder I2C connection (OSI LAYER 1)
- class balder.connections.I2SConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder I2S connection (OSI LAYER 1)
- class balder.connections.OneWireConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder One-Wire connection (OSI LAYER 1)
- class balder.connections.OpticalFiberConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Optical-Fiber connection (OSI LAYER 1)
- class balder.connections.SpiConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder SPI connection (OSI LAYER 1)
- class balder.connections.TwistedPairCableConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Twisted-Pair Cable connection (OSI LAYER 1)
- class balder.connections.UsbConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder USB connection (OSI LAYER 1)
- class balder.connections.WifiConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Wi-Fi connection (OSI LAYER 1)
OSI Layer 2: Data Link Layer¶
- class balder.connections.EthernetConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Ethernet connection (OSI LAYER 2)
- class balder.connections.WirelessLanConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Wireless LAN connection (OSI LAYER 2)
- class balder.connections.LLDPConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder LLDP connection (OSI LAYER 2)
- class balder.connections.ProfibusConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder Profibus connection (OSI LAYER 2)
OSI Layer 3: Network Layer¶
- class balder.connections.IpSecConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder IPSec connection (OSI LAYER 3)
- class balder.connections.IPv4Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder IPv4 connection (OSI LAYER 3)
- class balder.connections.IPv6Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder IPv6 connection (OSI LAYER 3)
- balder.connections.IPConnection¶
alias of <_balder.connection.Connection object at 0x7f91550cf3d0>
- class balder.connections.ICMPv4Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder ICMP IPv4 connection (OSI LAYER 3)
- class balder.connections.ICMPv6Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder ICMP IPv6 connection (OSI LAYER 3)
- balder.connections.ICMPConnection¶
alias of <_balder.connection.Connection object at 0x7f9154ee03d0>
OSI Layer 4: Transport Layer¶
- class balder.connections.TcpIPv4Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder TCP IPv4 connection (OSI LAYER 4)
- class balder.connections.TcpIPv6Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder TCP IPv6 connection (OSI LAYER 4)
- balder.connections.TcpConnection¶
alias of <_balder.connection.Connection object at 0x7f9154e564f0>
- class balder.connections.UdpIPv4Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder UDP IPv4 connection (OSI LAYER 4)
- class balder.connections.UdpIPv6Connection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder UDP IPv6 connection (OSI LAYER 4)
- balder.connections.UdpConnection¶
alias of <_balder.connection.Connection object at 0x7f9154e56c40>
OSI Layer 4: Session Layer¶
- class balder.connections.PptpConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder PPTP connection (OSI LAYER 5)
OSI Layer 5: Presentation Layer¶
- class balder.connections.TelnetConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder TELNET connection (OSI LAYER 6)
OSI Layer 5: Application Layer¶
- class balder.connections.HttpConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder HTTP connection (OSI LAYER 7)
- class balder.connections.ImapConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder IMAP connection (OSI LAYER 7)
- class balder.connections.LdapConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder LDAP connection (OSI LAYER 7)
- class balder.connections.NtpConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder NTP connection (OSI LAYER 7)
- class balder.connections.RpcConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder RPC connection (OSI LAYER 7)
- class balder.connections.SmtpConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder SMTP connection (OSI LAYER 7)
- class balder.connections.SntpConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder SNTP connection (OSI LAYER 7)
- class balder.connections.SshConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder SSH connection (OSI LAYER 7)
- class balder.connections.DnsConnection(from_device: Optional[Type[_balder.device.Device]] = None, to_device: Optional[Type[_balder.device.Device]] = None, from_device_node_name: Optional[str] = None, to_device_node_name: Optional[str] = None)¶
Balder DNS connection (OSI LAYER 7)