1 # Copyright 2023 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.
18 An abstract Class for O-RAN TerminationPoint
20 from typing import Any, cast
22 from network_generation.model.python.o_ran_object import (
28 # Define the "IORanObject" interface
29 class IORanTerminationPoint(IORanObject):
34 default_value: IORanTerminationPoint = cast(
35 IORanTerminationPoint,
37 **ORanObject.default(),
39 "supporter": "TerminationPointLayer",
46 # Define an O-RAN Termination Point
47 # (ietf-interface, onf:logical-termination-point) class
48 class ORanTerminationPoint(ORanObject):
50 def default() -> dict[str, Any]:
51 return cast(dict[str, Any], default_value)
54 self, data: dict[str, Any] = default(), **kwargs: dict[str, Any]
56 itp: IORanTerminationPoint = self._to_itp_data(data)
57 super().__init__(cast(dict[str, Any], itp), **kwargs)
58 self._supporter: str = str(itp["supporter"])
59 self._parent: Any = itp["parent"]
61 def _to_itp_data(self, data: dict[str, Any]) -> IORanTerminationPoint:
62 result: IORanTerminationPoint = default_value
63 for key, key_type in IORanTerminationPoint.__annotations__.items():
65 result[key] = data[key] # type: ignore
69 def supporter(self) -> str:
70 return self._supporter
73 def supporter(self, value: str) -> None:
74 self._supporter = value
77 def parent(self) -> Any:
78 return self._utilization
81 def parent(self, value: Any) -> None:
84 def to_topology(self) -> dict[str, Any]:
85 result: dict[str, Any] = {"tp-id": self.name}
86 if self.supporter and type(self.parent) is not int:
88 match str(type(self.parent)):
89 case "<class 'model.python.o_ran_smo.ORanSmo'>":
90 network_ref = self.parent.parent.id
91 case "<class 'model.python.o_ran_near_rt_ric.ORanNearRtRic'>":
92 network_ref = self.parent.parent.parent.id
93 case "<class 'model.python.o_ran_cu.ORanCu'>":
94 network_ref = self.parent.parent.parent.parent.id
95 case "<class 'model.python.o_ran_du.ORanDu'>":
96 network_ref = self.parent.parent.parent.parent.parent.id
97 case "<class 'model.python.o_ran_cloud_du.ORanCloudDu'>":
98 network_ref = self.parent.parent.parent.parent.parent.id
99 case "<class 'model.python.o_ran_ru.ORanRu'>":
101 self.parent.parent.parent.parent.parent.parent.id
104 print("unknown: implement " + str(type(self.parent)))
105 network_ref = "unknown: implement " + str(
108 result["supporting-termination-point"] = [
110 "network-ref": network_ref,
111 "node-ref": self.parent.name,
112 "tp-ref": self.supporter,