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 A Class representing an O-RAN Service Management and
19 Orchestration Framework (SMO)
21 import xml.etree.ElementTree as ET
22 from typing import Any, cast
24 import network_generation.model.python.hexagon as Hexagon
25 from network_generation.model.python.geo_location import GeoLocation
26 from network_generation.model.python.hexagon import Hex
27 from network_generation.model.python.o_ran_near_rt_ric import ORanNearRtRic
28 from network_generation.model.python.o_ran_node import (
33 from network_generation.model.python.o_ran_termination_point import (
36 from network_generation.model.python.tower import Tower
38 # Define the "IORanSmo" interface
42 # Define an abstract O-RAN Node class
43 class ORanSmo(ORanNode):
45 Class representing an O-RAN Service Management and Operation object.
50 data: dict[str, Any] = cast(dict[str, Any], default_value),
51 **kwargs: dict[str, Any]
53 o_ran_smo_data: IORanSmo = self._to_o_ran_smo_data(data)
54 super().__init__(cast(dict[str, Any], o_ran_smo_data), **kwargs)
55 if self.parent is not None:
56 self._o_ran_near_rt_rics: list[
58 ] = self._calculate_near_rt_rics()
60 def _calculate_near_rt_rics(self) -> list[ORanNearRtRic]:
61 hex_ring_radius: int = (
62 self.parent.spiral_radius_profile.oRanSmoSpiralRadiusOfNearRtRics
63 if self.parent is not None
68 ] = self.parent.spiral_radius_profile.oRanNearRtRicSpiral(
69 self.position, hex_ring_radius
71 result: list[ORanNearRtRic] = []
72 for index, hex in enumerate(hex_list):
73 s: str = "00" + str(index)
75 [self.name.replace("SMO", "NearRtRic"), s[len(s) - 2: len(s)]]
77 network_center: GeoLocation = self.parent.center
78 newGeo = Hexagon.hex_to_geo_location(
79 self.layout, hex, network_center
85 "geoLocation": newGeo,
87 "layout": self.layout,
94 def _to_o_ran_smo_data(self, data: dict[str, Any]) -> IORanSmo:
95 result: IORanSmo = default_value
96 for key, key_type in IORanSmo.__annotations__.items():
98 result[key] = data[key] # type: ignore
102 def o_ran_near_rt_rics(self) -> list[ORanNearRtRic]:
103 return self._o_ran_near_rt_rics
106 def towers(self) -> list[Tower]:
107 result: list[Tower] = []
108 for ric in self.o_ran_near_rt_rics:
109 for tower in ric.towers:
114 def termination_points(self) -> list[ORanTerminationPoint]:
115 result: list[ORanTerminationPoint] = super().termination_points()
116 phy_tp: str = "-".join([self.name, "phy".upper()])
117 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
118 for interface in ["a1", "o1", "o2"]:
119 id: str = "-".join([self.name, interface.upper()])
121 ORanTerminationPoint(
132 def to_topology_nodes(self) -> list[dict[str, Any]]:
133 result: list[dict[str, Any]] = super().to_topology_nodes()
134 for ric in self.o_ran_near_rt_rics:
135 result.extend(ric.to_topology_nodes())
138 def to_topology_links(self) -> list[dict[str, Any]]:
139 result: list[dict[str, Any]] = [] # super().to_topology_links()
140 for ric in self.o_ran_near_rt_rics:
141 result.extend(ric.to_topology_links())
144 def toKml(self) -> ET.Element:
145 smo: ET.Element = ET.Element("Folder")
146 open: ET.Element = ET.SubElement(smo, "open")
148 name: ET.Element = ET.SubElement(smo, "name")
149 name.text = self.name
150 for ric in self.o_ran_near_rt_rics:
151 smo.append(ric.toKml())
154 def toSvg(self) -> ET.Element:
155 return ET.Element("not-implemented-yet-TODO")