Create ietf-network-topology json
[oam.git] / code / network-generator / model / python / tower.py
index 7def5e6..d012e32 100644 (file)
@@ -19,9 +19,11 @@ A Class representing a Tower to mount O-RAN RUs
 It can be interpreted as 'resource pool' for physical network
 functions.
 """
+from typing import overload
 from model.python.o_ran_object import IORanObject
 from model.python.o_ran_ru import ORanRu
 from model.python.o_ran_node import ORanNode
+from model.python.o_ran_termination_point import ORanTerminationPoint
 import xml.etree.ElementTree as ET
 
 
@@ -79,6 +81,36 @@ class Tower(ORanNode):
     def o_ran_rus(self) -> list[ORanRu]:
         return self._o_ran_rus
 
+    @property
+    def termination_points(self) -> list[ORanTerminationPoint]:
+        result: list[ORanTerminationPoint] = super().termination_points
+        phy_tp: str = "-".join([self.name, "phy".upper()])
+        result.append({"tp-id": phy_tp})
+        for interface in ["e2", "o1", "ofhm", "ofhc", "ofhu","ofhs"]:
+            result.append(              {
+                "tp-id": "-".join([self.name, interface.upper()]),
+                "supporting-termination-point": [
+                  {
+                    "network-ref": type(self.parent.parent.parent.parent),
+                    "node-ref":self.name,
+                    "tp-ref": phy_tp
+                  }
+                ]
+              })
+        return result
+
+    def to_topology_nodes(self) -> list[dict[str, dict]]:
+        result: list[dict[str, dict]] = super().to_topology_nodes()
+        for o_ran_ru in self.o_ran_rus:
+            result.extend(o_ran_ru.to_topology_nodes())    
+        return result
+
+    def to_topology_links(self) -> list[dict[str, dict]]:
+        result: list[dict[str, dict]] = super().to_topology_links()
+        for o_ran_ru in self.o_ran_rus:
+            result.extend(o_ran_ru.to_topology_links())    
+        return result
+    
     def toKml(self) -> ET.Element:
         tower: ET.Element = ET.Element("Folder")
         open: ET.Element = ET.SubElement(tower, "open")