X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=code%2Fnetwork-generator%2Fnetwork_generation%2Fmodel%2Fpython%2Fo_ran_termination_point.py;h=03ecd2afa3264f0196de6b9fc6871ee724045682;hb=HEAD;hp=e7fe98a794e947cf757619c2a4e024a327a7b55b;hpb=7004840bca352043aec43d36df79436b90bcbd5a;p=oam.git diff --git a/code/network-generator/network_generation/model/python/o_ran_termination_point.py b/code/network-generator/network_generation/model/python/o_ran_termination_point.py index e7fe98a..03ecd2a 100644 --- a/code/network-generator/network_generation/model/python/o_ran_termination_point.py +++ b/code/network-generator/network_generation/model/python/o_ran_termination_point.py @@ -12,33 +12,78 @@ # See the License for the specific language governing permissions and # limitations under the License. -#!/usr/bin/python +# !/usr/bin/python """ An abstract Class for O-RAN TerminationPoint """ -from abc import abstractmethod -from network_generation.model.python.o_ran_object import IORanObject, ORanObject +from typing import Any, cast + +from network_generation.model.python.o_ran_object import ( + IORanObject, + ORanObject, +) # Define the "IORanObject" interface -class IORanTerminationPointData(IORanObject): - def __init__(self, supporter: str = None, parent=None, **kwargs): - super().__init__(**kwargs) - self.supporter = supporter - self.parent = parent - - -# Define an O-RAN Termination Point (ietf-interface, onf:logical-termination-point) class -class ORanTerminationPoint(ORanObject, IORanTerminationPointData): - def __init__(self, tp: IORanTerminationPointData = None, **kwargs): - super().__init__(tp, **kwargs) - self.supporter = tp["supporter"] if tp and "supporter" in tp else None - self.parent = tp["parent"] if tp and "parent" in tp else None - - def to_topology(self): - result: dict[str, dict] = {"tp-id": self.name} - if self.supporter: +class IORanTerminationPoint(IORanObject): + supporter: str + parent: Any + + +default_value: IORanTerminationPoint = cast( + IORanTerminationPoint, + { + **ORanObject.default(), + **{ + "supporter": "TerminationPointLayer", + "parent": None, + }, + }, +) + + +# Define an O-RAN Termination Point +# (ietf-interface, onf:logical-termination-point) class +class ORanTerminationPoint(ORanObject): + @staticmethod + def default() -> dict[str, Any]: + return cast(dict[str, Any], default_value) + + def __init__( + self, data: dict[str, Any] = default(), **kwargs: dict[str, Any] + ) -> None: + itp: IORanTerminationPoint = self._to_itp_data(data) + super().__init__(cast(dict[str, Any], itp), **kwargs) + self._supporter: str = str(itp["supporter"]) + self._parent: Any = itp["parent"] + + def _to_itp_data(self, data: dict[str, Any]) -> IORanTerminationPoint: + result: IORanTerminationPoint = default_value + for key, key_type in IORanTerminationPoint.__annotations__.items(): + if key in data: + result[key] = data[key] # type: ignore + return result + + @property + def supporter(self) -> str: + return self._supporter + + @supporter.setter + def supporter(self, value: str) -> None: + self._supporter = value + + @property + def parent(self) -> Any: + return self._utilization + + @parent.setter + def parent(self, value: Any) -> None: + self._parent = value + + def to_topology(self) -> dict[str, Any]: + result: dict[str, Any] = {"tp-id": self.name} + if self.supporter and type(self.parent) is not int: network_ref: str = "" match str(type(self.parent)): case "": @@ -52,10 +97,13 @@ class ORanTerminationPoint(ORanObject, IORanTerminationPointData): case "": network_ref = self.parent.parent.parent.parent.parent.id case "": - network_ref = self.parent.parent.parent.parent.parent.parent.id + network_ref = ( + self.parent.parent.parent.parent.parent.parent.id + ) case _: print("unknown: implement " + str(type(self.parent))) - network_ref = "unknown: implement " + str(type(self.parent)) + network_ref = "unknown: implement " + str( + type(self.parent)) result["supporting-termination-point"] = [ {