From ab8517e130db6c88d0a7370cc6c7e73b152a08d0 Mon Sep 17 00:00:00 2001 From: demx8as6 Date: Sun, 6 Mar 2022 18:16:04 +0100 Subject: [PATCH] Ues json file names as expected by o-ran-sc-topology service - Handle optional name Issue-Id: OAM-258 Change-Id: I603c6cfe93c8edd449ab64c8df2702bd96988641 Signed-off-by: demx8as6 --- .../model/python/tapi_common_context.py | 13 ++++++++++--- .../model/python/tapi_topology.py | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/code/network-topology-instance-generator/model/python/tapi_common_context.py b/code/network-topology-instance-generator/model/python/tapi_common_context.py index 03d779b..75381a8 100644 --- a/code/network-topology-instance-generator/model/python/tapi_common_context.py +++ b/code/network-topology-instance-generator/model/python/tapi_common_context.py @@ -60,14 +60,18 @@ class TapiCommonContext(Top): """ return self.__data - def json(self) -> Dict: + def json(self, running: bool) -> Dict: """ Getter for a json object representing the TAPI Topology Context. :return TAPI Common Context as json object. """ result = self.data().copy() - if self.__context is not None: + if self.__context is not None and running is False: result["tapi-common:context"].update(self.__context.json()) + + if running is True and "tapi-topology:topology-context" in result["tapi-common:context"]: + result["tapi-common:context"].pop("tapi-topology:topology-context") + return result def identifier(self) -> str: @@ -113,7 +117,10 @@ class TapiCommonContext(Top): root.append(desc) title=etree.Element("title") - title.text=self.configuration()["network"]["name"] + if "name" in self.configuration()["network"]: + title.text=self.configuration()["network"]["name"] + else: + title.text="o-ran-sc-topology-view" root.append(title) root.append(self.__context.svg(x, y)) diff --git a/code/network-topology-instance-generator/model/python/tapi_topology.py b/code/network-topology-instance-generator/model/python/tapi_topology.py index 80ac008..e6f7100 100644 --- a/code/network-topology-instance-generator/model/python/tapi_topology.py +++ b/code/network-topology-instance-generator/model/python/tapi_topology.py @@ -47,12 +47,16 @@ class TapiTopology(Top): # constructor def __init__(self, configuration: dict): super().__init__(configuration) + name = "o-ran-sc-topology-view" + if "name" in configuration['network']: + name = configuration['network']['name'] + self.__configuration = configuration self.__data = { "uuid": str(uuid.uuid4()), "name": [{ "value-name": "network-name", - "value": configuration['network']['name']}], + "value": name}], "layer-protocol-name": ["ETH"], "node": [], "link": []} -- 2.16.6