From b6948c6bf9a550ef22fcb6607587e39a3879b74f Mon Sep 17 00:00:00 2001 From: Martin Skorupski Date: Wed, 18 Oct 2023 17:28:50 +0200 Subject: [PATCH] Create concrete classes for O-RAN Nodes - keep o-ran-object more abstract and move more specifics to O-RAN-Node Issue-ID: OAM-368 Change-Id: I0e26617ca7a57f3174831bd2545c2a5f92d23a31 Signed-off-by: Martin Skorupski --- code/network-generator/model/python/o_ran_node.py | 110 ++++++++++++++++++++- .../network-generator/model/python/o_ran_object.py | 102 +------------------ 2 files changed, 112 insertions(+), 100 deletions(-) diff --git a/code/network-generator/model/python/o_ran_node.py b/code/network-generator/model/python/o_ran_node.py index 2320ffa..e5a819e 100644 --- a/code/network-generator/model/python/o_ran_node.py +++ b/code/network-generator/model/python/o_ran_node.py @@ -19,18 +19,124 @@ An abstract Class for O-RAN Node """ from abc import abstractmethod from typing import Any, Dict + +from model.python.geo_location import GeoLocation from model.python.o_ran_object import IORanObject, ORanObject +import model.python.hexagon as Hexagon +from model.python.hexagon import Hex, Layout, Point +from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile +from model.python.type_definitions import ( + AddressType, +) + + +# Define the "IORanObject" interface +class IORanNode(IORanObject): + def __init__( + self, + address: AddressType = None, + geoLocation: GeoLocation = None, + url: str = None, + position: Hex = None, + layout: Layout = None, + spiralRadiusProfile: SpiralRadiusProfile = None, + parent = None, + **kwargs + ): + super().__init__(**kwargs) + self.address = address + self.geoLocation = geoLocation + self.url = url + self.position = position + self.layout = layout + self.spiralRadiusProfile = spiralRadiusProfile, + self.parent = parent # Define an abstract O-RAN Node class -class ORanNode(ORanObject): - def __init__(self, of: IORanObject = None, **kwargs): +class ORanNode(ORanObject, IORanNode): + def __init__(self, of: IORanNode = None, **kwargs): super().__init__(of, **kwargs) + self.address = of["address"] if of and "address" in of else None + self.geoLocation = ( + of["geoLocation"] if of and "geoLocation" in of else GeoLocation() + ) + self.url = of["url"] if of and "url" in of else self.id + self.position = of["position"] if of and "position" in of else Hex(0,0,0) + self.layout = of["layout"] if of and "layout" in of else Layout(Hexagon.layout_flat, Point(1,1), Point(0,0)) + self.spiralRadiusProfile = of["spiralRadiusProfile"] if of and "spiralRadiusProfile" in of else SpiralRadiusProfile() + self.parent = of["parent"] if of and "parent" in of else None self._terminationPoints = [] + @property + def address(self): + return self._address + + @address.setter + def address(self, value): + self._address = value + + @property + def geoLocation(self): + return self._geographicalLocation + + @geoLocation.setter + def geoLocation(self, value): + self._geographicalLocation = value + + @property + def url(self): + return self._url + + @url.setter + def url(self, value): + self._url = value + + @property + def position(self): + return self._position + + @position.setter + def position(self, value): + self._position = value + + @property + def layout(self): + return self._layout + + @layout.setter + def layout(self, value): + self._layout = value + + @property + def spiralRadiusProfile(self): + return self._spiralRadiusProfile + + @spiralRadiusProfile.setter + def spiralRadiusProfile(self, value): + self._spiralRadiusProfile = value + + @property + def parent(self): + return self._parent + + @parent.setter + def parent(self, value): + self._parent = value + @property def terminationPoints(self): return self._terminationPoints + def json(self): + result: Dict = super().json() + result["address"] = self.address + result["geoLocation"] = self.geoLocation + result["url"] = self.url + result["layout"] = self.layout + result["spiralRadiusProfile"] = self.spiralRadiusProfile + result["parent"] = self.parent + return result + def toTopology(self): result:Dict[str, Any] = { "node-id": self.name, diff --git a/code/network-generator/model/python/o_ran_object.py b/code/network-generator/model/python/o_ran_object.py index fc112da..82c7473 100644 --- a/code/network-generator/model/python/o_ran_object.py +++ b/code/network-generator/model/python/o_ran_object.py @@ -17,125 +17,31 @@ """ An abstract Class for O-RAN Objects """ -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import Dict -import model.python.hexagon as Hexagon -from model.python.hexagon import Hex, Layout, Point -from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile from model.python.top import ITop, Top -from model.python.type_definitions import ( - AddressType, -) from model.python.geo_location import GeoLocation # Define the "IORanObject" interface class IORanObject(ITop): - def __init__( - self, - address: AddressType = None, - geoLocation: GeoLocation = None, - url: str = None, - position: Hex = None, - layout: Layout = None, - spiralRadiusProfile: SpiralRadiusProfile = None, - parent = None, - **kwargs - ): + def __init__(self, **kwargs): super().__init__(**kwargs) - self.address = address - self.geoLocation = geoLocation - self.url = url - self.position = position - self.layout = layout - self.spiralRadiusProfile = spiralRadiusProfile, - self.parent = parent # Define an abstract O-RAN Object class class ORanObject(Top, IORanObject): def __init__(self, of: IORanObject = None, **kwargs): super().__init__(**kwargs) - self.address = of["address"] if of and "address" in of else None - self.geoLocation = ( - of["geoLocation"] if of and "geoLocation" in of else GeoLocation() - ) - self.url = of["url"] if of and "url" in of else self.id - self.position = of["position"] if of and "position" in of else Hex(0,0,0) - self.layout = of["layout"] if of and "layout" in of else Layout(Hexagon.layout_flat, Point(1,1), Point(0,0)) - self.spiralRadiusProfile = of["spiralRadiusProfile"] if of and "spiralRadiusProfile" in of else SpiralRadiusProfile() - self.parent = of["parent"] if of and "parent" in of else None - - @property - def address(self): - return self._address - - @address.setter - def address(self, value): - self._address = value - - @property - def geoLocation(self): - return self._geographicalLocation - - @geoLocation.setter - def geoLocation(self, value): - self._geographicalLocation = value - - @property - def url(self): - return self._url - - @url.setter - def url(self, value): - self._url = value - - @property - def position(self): - return self._position - - @position.setter - def position(self, value): - self._position = value - - @property - def layout(self): - return self._layout - - @layout.setter - def layout(self, value): - self._layout = value - - @property - def spiralRadiusProfile(self): - return self._spiralRadiusProfile - - @spiralRadiusProfile.setter - def spiralRadiusProfile(self, value): - self._spiralRadiusProfile = value - - @property - def parent(self): - return self._parent - - @parent.setter - def parent(self, value): - self._parent = value def json(self): - result :Dict = super().json() - result['address'] = self.address - result['geoLocation'] = self.geoLocation - result['url'] = self.url - result['layout'] = self.layout - result['spiralRadiusProfile'] = self.spiralRadiusProfile - result['parent'] = self.parent + result: Dict = super().json() return result def __str__(self): return str(self.json()) - + @abstractmethod def toTopology(self): pass -- 2.16.6