1 # Copyright 2022 highstreet technologies GmbH
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 Module containing a class representing a TAPI Connection Node Edge Point
20 from typing import Dict, Union
21 from lxml import etree
22 from model.python.svg.connection_edge_point import ConnectionEdgePoint
23 from model.python.svg.svg import Svg
24 from model.python.top import Top
27 class TapiConnectionEdgePoint(Top):
29 Class representing a TAPI Connection Node Edge Point object
34 "protocol": "unknown",
38 "node-edge-point": "unknown",
39 "interface": "unknown"
44 def __init__(self, configuration: Dict[str, str]):
45 super().__init__(configuration)
46 self.__configuration = configuration
48 "uuid": str(uuid.uuid4()),
50 "value-name": "connection-edge-point-name",
53 "operational-state": "ENABLED",
54 "lifecycle-state": "INSTALLED",
55 "termination-state": self.termination_state(),
56 "termination-direction": self.termination_direction(),
57 "layer-protocol-name": "ETH",
58 "layer-protocol-qualifier": self.protocol(),
60 "connection-port-role": "SYMMETRIC",
61 "connection-port-direction": "BIDIRECTIONAL",
63 "parent-node-edge-point": {
64 # TODO "topology-uuid": "?",
65 "node-uuid": self.parent()["node"],
66 "node-edge-point-uuid": self.parent()["node-edge-point"]
71 def configuration(self) -> dict:
73 Getter for a json object representing the TAPI Node Edge Point intiail
75 :return TAPI Node Edge Point configuration as json object.
77 return self.__configuration
79 def data(self) -> dict:
81 Getter for a json object representing the TAPI Node Edge Point.
82 :return TAPI Node Edge Point as json object.
86 def identifier(self) -> str:
88 Getter returning the TAPI Node Edge Point identifier.
89 :return Object identifier as UUID.
91 return self.__data["uuid"]
93 def json(self) -> dict:
95 Getter for a json object representing the TAPI Node Edge Point.
96 :return TAPI Node Edge Point as json object.
100 def name(self) -> str:
102 Getter a human readable identifier of the TAPI Node Edge Point.
103 :return TAPI Node Edge Point name as String.
105 items = (self.parent()["interface"],
106 self.protocol().split(":")[1],
108 return "-".join(items).lower()
110 def protocol(self) -> str:
112 Getter a human readable identifier of the TAPI Connection Edge Point protocol.
113 :return protocol label.
115 protocol = self.__configuration['protocol'].lower()
116 if protocol == "otf":
117 protocol = "fronthaul-gateway"
118 return ":".join(["o-ran-sc-topology-common", self.__configuration['protocol'].lower()])
120 def role(self) -> str:
122 Getter a human readable identifier of the TAPI Node Edge Point role.
125 return self.__configuration['role'].lower()
127 def parent(self) -> Dict:
129 Getter returning the identifier the the TAPI Node hosting the Node
131 :return Identifier of the TAPI Node containing this NEP.
133 return self.__configuration["parent"]
135 def svg(self, x: int, y: int) -> etree.Element:
137 Getter for a xml Element object representing the TAPI Node Edge Point.
138 :return TAPI Node Edge Point as SVG object.
140 return ConnectionEdgePoint(self, x, y).svg_element()
142 def termination_direction(self) -> str:
144 Getter returning the TAPI Node Edge Point direction.
145 :return TAPI Node Edge Point direction as String.
151 if self.__configuration['role'].lower() in mapping:
152 return mapping[self.__configuration['role'].lower()]
153 return "BIDIRECTIONAL"
155 def termination_state(self) -> str:
157 Getter returning the TAPI Node Edge Point state.
158 :return TAPI Node Edge Point state as String.
160 return "LT_PERMENANTLY_TERMINATED"