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 to construct the input configuration for a TAPI link object.
19 from typing import Dict
20 from model.python.tapi_node import TapiNode
21 from model.python.tapi_node_edge_point import TapiNodeEdgePoint
22 from model.python.top import Top
25 class LinkConfig(Top):
27 Class containing methods creating an link configuration object.
30 __topology_reference = "unknown"
31 __name_prefix: str = "unknown"
32 __consumer: TapiNode = None
33 __provider: TapiNode = None
35 __data: dict = {"link": {
42 def __init__(self, topology_reference: str, name_prefix: str,
43 provider: TapiNode, consumer: TapiNode):
45 self.__topology_reference = topology_reference
46 self.__name_prefix = name_prefix
47 self.__consumer = consumer
48 self.__provider = provider
50 self.data = {"link": {
53 "topology-uuid": topology_reference,
54 "node-uuid": consumer.data()["uuid"],
55 "node-edge-point-uuid":
56 self.consumer_node_edge_point().identifier()
60 "topology-uuid": topology_reference,
61 "node-uuid": provider.data()["uuid"],
62 "node-edge-point-uuid":
63 self.provider_node_edge_point().identifier()
67 def configuration(self) -> Dict[str, Dict[str, Dict]]:
69 Getter returning the configuration.
70 :return Link identifier as string
72 return {"configuration": {
73 "topology-reference:": self.__topology_reference,
74 "name_prefix": self.__name_prefix,
75 "provider": self.__provider.json(),
76 "consumer": self.__consumer.json()
79 def data(self) -> Dict[str, Dict]:
81 Getter returning the link data of the link.
82 :return Link confguation data as json object
86 def identifier(self) -> str:
88 Getter returning the link configuration identifier of the link.
89 :return Link identifier as string
92 self.__consumer.identifier(),
93 self.__provider.identifier(),
96 def name(self) -> str:
98 Getter returning the name of the link.
99 :return Link name as string
103 self.__name_prefix.upper(),
104 self.__consumer.name(),
106 self.__provider.name(),
111 def json(self) -> dict:
113 Getter for the json represention of this object.
114 :return JSON object of link configuration
118 def consumer_node_edge_point(self) -> TapiNodeEdgePoint:
119 name_prefix = self.__name_prefix
121 # exception for O-RAN Fronthaul Management plane to SMO
122 if self.__consumer.function() == "o-ran-sc-topology-common:smo" and \
123 self.__provider.function() == "o-ran-sc-topology-common:o-ru" and \
124 name_prefix == "ofh-netconf": # "open-fronthaul-m-plane-netconf":
125 name_prefix = "oam-netconf"
127 # exception for O-RAN Gateway plane to SMO
128 if self.__consumer.function() == "o-ran-sc-topology-common:smo" and \
129 name_prefix == "o1-netconf": # "open-fronthaul-m-plane-netconf":
130 name_prefix = "oam-netconf"
132 # exception for O-RU to FHGW
133 if self.__provider.function() == "o-ran-sc-topology-common:fronthaul-gateway" and \
134 name_prefix == "eth-ofh": # "open-fronthaul-m-plane-netconf":
135 name_prefix = "ofh-netconf"
137 # exception for O-RU to FHGW
138 if self.__consumer.function() == "o-ran-sc-topology-common:fronthaul-gateway" and \
139 name_prefix == "ofh-netconf": # "open-fronthaul-m-plane-netconf":
140 name_prefix = "eth-ofh"
142 cep_name = name_prefix.lower() + "-consumer"
143 return self.__consumer.node_edge_point_by_cep_name(cep_name, self.__provider.local_id())
145 def provider_node_edge_point(self) -> TapiNodeEdgePoint:
146 name_prefix = self.__name_prefix
148 cep_name = name_prefix.lower() + "-provider"
149 # exception for f1-c and f1-u
150 split = name_prefix.lower().split("-")
152 cep_name = "-".join([split[0], split[2], "provider"])
154 return self.__provider.node_edge_point_by_cep_name(cep_name, self.__consumer.local_id())