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: Union[Type[_balder.connection.Connection], _balder.connection.Connection, _balder.cnnrelations.or_connection_relation.OrConnectionRelation, _balder.cnnrelations.and_connection_relation.AndConnectionRelation]) None ¶
with this method you can extend the internal based_on list with the transferred elements. Any number of
Connection()
objects or relations withConnection()
objects can be given to this method. They will all be added to the internal OR relation.- Parameters
args – all connection items that should be added here
- classmethod based_on(connection: Union[_balder.connection.Connection, Type[_balder.connection.Connection], _balder.cnnrelations.and_connection_relation.AndConnectionRelation, _balder.cnnrelations.or_connection_relation.OrConnectionRelation]) _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 you can define logical statements with the | and the & operator. For example:
Connection1() or Connection2() and Connection3()
.- Parameters
connection – all connection items for which this connection is based on
- property based_on_elements: _balder.cnnrelations.or_connection_relation.OrConnectionRelation¶
returns a copy of the internal based_on_connection
- 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.
- clone_without_based_on_elements() _balder.connection.Connection ¶
This method returns a copied version of this element, while all _based_on_connections are removed (the copied element has an empty list here).
- Returns
a python copied object of this item
- contained_in(other_conn: Connection | AndConnectionRelation | OrConnectionRelation, ignore_metadata=False) bool ¶
This method helps to find out whether this connection-tree fits within another 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
- cut_into_all_possible_pieces() List[_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!
- cut_into_all_possible_subtree_branches() List[_balder.connection.Connection] ¶
This method returns a list of all possible connection tree branches. A branch is a single connection, while this method returns a list of all possible singles where every single connection has this connection as head.
- 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.
- 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
- classmethod filter_connections_that_are_contained_in(cnns_from: List[Union[_balder.connection.Connection, _balder.cnnrelations.and_connection_relation.AndConnectionRelation, _balder.cnnrelations.or_connection_relation.OrConnectionRelation]], are_contained_in: _balder.connection.Connection, ignore_metadata: bool = False) List[_balder.connection.Connection] ¶
This method filters the connection elements from the first list to include only those connections that are contained within the provided connection
are_contained_in
.- Parameters
cnns_from – a list of connections
are_contained_in – the connection, the connection elements should be contained in
ignore_metadata – True, if the metadata should be ignored
- Returns
a list with the filtered connections
- 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)
- get_intersection_with_other_single(other_conn: Union[_balder.connection.Connection, _balder.cnnrelations.and_connection_relation.AndConnectionRelation, _balder.cnnrelations.or_connection_relation.OrConnectionRelation]) List[_balder.connection.Connection] ¶
A helper method that returns an intersection between the two connections (self and the given one).
- Parameters
other_conn – the other single connection object (could be a relation too, but note that them needs to be single elements!)
- 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 AND relation!). In that 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: Type[_balder.device.Device], start_device_node_name: Optional[str] = None, end_device: Optional[Type[_balder.device.Device]] = None, end_device_node_name: Optional[str] = None) bool ¶
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)
start_device_node_name – the node name that start device should have or None if it should be ignored
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)
end_device_node_name – the node name that start device should have or None if it should be ignored
- Returns
returns true if the given direction is possible
- intersection_with(other_conn: Union[_balder.connection.Connection, Type[_balder.connection.Connection], _balder.cnnrelations.and_connection_relation.AndConnectionRelation, _balder.cnnrelations.or_connection_relation.OrConnectionRelation]) Optional[_balder.connection.Connection] ¶
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. The method checks if there are common intersections between the elements of this object and the given connection elements within the single connections. 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() Optional[bool] ¶
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 relation 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: _balder.connection_metadata.ConnectionMetadata¶
returns the connection metadata dictionary
- set_metadata_for_all_subitems(metadata: Optional[_balder.connection_metadata.ConnectionMetadata])¶
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
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 0x7f56fd54c1f0>
- 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 0x7f56fd59ffa0>
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 0x7f56fd558b20>
- 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 0x7f56fd54c370>
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)