From 9544e02983cf2c36a3174579d7e9c00fdf26fd0a Mon Sep 17 00:00:00 2001 From: Martin Skorupski Date: Tue, 10 Oct 2023 16:29:27 +0200 Subject: [PATCH] Create an abstract class for O-RAN Functions - ORanFunction.py added to app model. It inherits from Top Issue-ID: OAM-35 Change-Id: Ie3f104b4fa06bc8c26e95886c32a160b72f22b12 Signed-off-by: Martin Skorupski --- .../network-generator/model/python/ORanFunction.py | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 code/network-generator/model/python/ORanFunction.py diff --git a/code/network-generator/model/python/ORanFunction.py b/code/network-generator/model/python/ORanFunction.py new file mode 100644 index 0000000..06a4c81 --- /dev/null +++ b/code/network-generator/model/python/ORanFunction.py @@ -0,0 +1,99 @@ +# Copyright 2023 highstreet technologies GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/usr/bin/python + +""" +An abstract Class for O-RAN Functions +""" +from abc import ABC, abstractmethod +from typing import Dict + +from model.python.Top import ITop, Top +from model.python.TypeDefinitions import ( + AddressType, +) +from model.python.GeoLocation import GeoLocation + + +# Define the "IORanFunction" interface +class IORanFunction(ITop): + def __init__( + self, + address: AddressType = None, + geoLocation: GeoLocation = None, + url: str = None, + **kwargs + ): + super().__init__(**kwargs) + self.address = address + self.geoLocation = geoLocation + self.url = url + + +# Define an abstract O-RAN Function class +class ORanFunction(ABC, Top, IORanFunction): + def __init__(self, of: IORanFunction = 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 + + @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 + + def json(self): + result :Dict = super().json() + result['address'] = self.address + result['geoLocation'] = self.geoLocation.json() + result['url'] = self.url + return result + + def __str__(self): + return str(self.json()) + + @abstractmethod + def toTopology(self): + pass + + @abstractmethod + def toKml(self): + pass + + @abstractmethod + def toSvg(self): + pass -- 2.16.6