-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcircuit.py
More file actions
42 lines (37 loc) · 1.51 KB
/
Copy pathcircuit.py
File metadata and controls
42 lines (37 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from l1node import L1Node
class Circuit:
"""Circuit class to hold a possible
L1 Circuit. The circuit is used for L1 Topology
and maps multiple L3 interfaces"""
def __init__(self, label : str , target: L1Node, link_num: int = 1):
"""
:param label: Circuit ID/Label
:param target: The Target L1 Node object
:param link_num: Defaults to 1, used in visualization if multiple links exits btw nodes
:return: returns nothing"""
self.label = label
self.target = target
self.link_num = link_num
self.interfaces = []
self._failed = False
def __repr__(self):
return self.label
def failCircuit(self):
"""Change state of a circuit and the associated interfaces
for both itself and his neighbour L1node if there
#TODO Find a way to fail circuits for a pair node without
any circuits as the Graph for L1 is directed"""
self._failed = True
for interface in self.interfaces:
interface.failInterface()
def unfailCircuit(self):
"""Change state of a circuit and the associated interfaces
for both itself and his neighbour L1node if there
#TODO Find a way to fail circuits for a pair node without
any circuits as the Graph for L1 is directed"""
self._failed = False
for interface in self.interfaces:
interface.unfailInterface()
def get_interfaces(self):
"""Return all L3 interfaces"""
return self.interfaces