From: demx8as6 Date: Mon, 21 Feb 2022 14:54:33 +0000 (+0100) Subject: Create a script to generate a Topology X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=53faeefe83be6374deaea9a8b24589f59be951e0;p=oam.git Create a script to generate a Topology - create root python to be called IssueID: OAM-249 Change-Id: Ifdd7b0a5d7dd3041f12c49c3fd9fc435558bff6e Signed-off-by: demx8as6 --- diff --git a/code/network-topology-instance-generator/tapi_topology_generator.py b/code/network-topology-instance-generator/tapi_topology_generator.py new file mode 100644 index 0000000..8c632c1 --- /dev/null +++ b/code/network-topology-instance-generator/tapi_topology_generator.py @@ -0,0 +1,45 @@ +# Copyright 2022 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 + +""" +Module as entry point to generatate a TAPI topology json +""" +import sys +from controller.parameter_validator import ParameterValidator +from controller.network_generator import TopologyGenerator +from view.network_viewer import NetworkViewer + +validator: ParameterValidator = ParameterValidator(sys.argv) + +if validator.is_valid(): + configuration = validator.configuration() + generator = TopologyGenerator(configuration) + network = generator.generate() + viewer = NetworkViewer(network) + + filename: str = "output/network.json" + if configuration['network']['name']: + filename = "output/" + configuration['network']['name'] + ".json" + viewer.json().save(filename) + # viewer.json().showAsJson() + + filename: str = "output/network.svg" + if configuration['network']['name']: + filename = "output/" + configuration['network']['name'] + ".svg" + viewer.svg(filename) + +else: + print(validator.error_message())