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 O-Cloud resource pool for O-RAN distributed units
20 By default all O-RAN-DUs associated with the towers around are deployed here.
21 Maybe dedicated hardware is required to host O-DUs, but it is expected
22 that the O-Cloud mechanism and concepts can be applied here.
24 import xml.etree.ElementTree as ET
25 from typing import Any, cast
27 import network_generation.model.python.hexagon as Hexagon
28 from network_generation.model.python.cube import Cube
29 from network_generation.model.python.geo_location import GeoLocation
30 from network_generation.model.python.hexagon import Hex
31 from network_generation.model.python.o_ran_node import (
36 from network_generation.model.python.o_ran_termination_point import (
39 from network_generation.model.python.tower import Tower
41 # Define the "IORanDu" interface
42 IORanCloudDu = IORanNode
45 # Implements a concrete O-RAN Node class
46 class ORanCloudDu(ORanNode):
49 data: dict[str, Any] = cast(dict[str, Any], default_value),
50 **kwargs: dict[str, Any]
52 o_ran_cloud_du_data: IORanCloudDu = self._to_o_ran_cloud_du_data(data)
54 super().__init__(cast(dict[str, Any], o_ran_cloud_du_data), **kwargs)
55 self._towers: list[Tower] = self._calculate_towers()
57 def _to_o_ran_cloud_du_data(self, data: dict[str, Any]) -> IORanCloudDu:
58 result: IORanCloudDu = default_value
59 for key, key_type in IORanCloudDu.__annotations__.items():
61 result[key] = data[key] # type: ignore
64 def _calculate_towers(self) -> list[Tower]:
65 hex_ring_radius: int = (
66 self.parent.parent.parent.parent
67 .spiral_radius_profile.oRanDuSpiralRadiusOfTowers
69 hex_list: list[Hex] = Cube.spiral(self.position, hex_ring_radius)
70 result: list[Tower] = []
71 for index, hex in enumerate(hex_list):
72 s: str = "00" + str(index)
75 self.name.replace("O-Cloud-DU", "Tower"),
76 s[len(s) - 2: len(s)],
79 network_center: GeoLocation = (
80 self.parent.parent.parent.parent.center
82 newGeo = Hexagon.hex_to_geo_location(
83 self.layout, hex, network_center
89 "geoLocation": newGeo,
91 "layout": self.layout,
99 def towers(self) -> list[Tower]:
102 def termination_points(self) -> list[ORanTerminationPoint]:
103 result: list[ORanTerminationPoint] = super().termination_points()
104 phy_tp: str = "-".join([self.name, "phy".upper()])
105 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
106 for interface in ["o2"]:
107 id: str = "-".join([self.name, interface.upper()])
109 ORanTerminationPoint(
110 {"id": id, "name": id, "supporter": phy_tp, "parent": self}
115 def to_topology_nodes(self) -> list[dict[str, Any]]:
116 result: list[dict[str, Any]] = super().to_topology_nodes()
117 for tower in self.towers:
118 result.extend(tower.to_topology_nodes())
121 def to_topology_links(self) -> list[dict[str, Any]]:
122 result: list[dict[str, Any]] = super().to_topology_links()
123 for tower in self.towers:
124 result.extend(tower.to_topology_links())
127 def toKml(self) -> ET.Element:
128 o_ran_cloud_du: ET.Element = ET.Element("Folder")
129 open: ET.Element = ET.SubElement(o_ran_cloud_du, "open")
131 name: ET.Element = ET.SubElement(o_ran_cloud_du, "name")
132 name.text = self.name
133 for tower in self.towers:
134 o_ran_cloud_du.append(tower.toKml())
135 return o_ran_cloud_du
137 def toSvg(self) -> ET.Element:
138 return ET.Element("to-be-implemented")