1 # Copyright 2023 highstreet technologies GmbH
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # inspired by https://github.com/rochacbruno/python-project-template
20 from network_generation.base import NetworkGenerator
21 from network_generation.model.python.o_ran_network import ORanNetwork
22 from network_generation.parameter_validator import ParameterValidator
23 from network_generation.view.network_viewer import NetworkViewer
26 CLI interface for network_generation project.
27 Module as entry point to generate an ietf topology json
31 def main() -> None: # pragma: no cover
33 The main function executes on commands:
34 `python -m network_generation`.
37 validator: ParameterValidator = ParameterValidator(sys.argv)
39 if validator.is_valid():
40 configuration: dict = validator.configuration()
41 generator: NetworkGenerator = NetworkGenerator(
42 configuration["network"]
44 network: ORanNetwork = generator.generate()
45 viewer: NetworkViewer = NetworkViewer(network)
47 output_folder: str = configuration["outputFolder"]
48 # If folder doesn't exist, then create it.
49 if not os.path.isdir(output_folder):
50 os.makedirs(output_folder)
52 name: str = str(configuration["network"]["name"]).lower()
53 filename: str = "/".join([output_folder, name])
56 if configuration["generationTasks"]["topology"]["enabled"] is True:
59 configuration["generationTasks"]["topology"]["compressed"]
62 # dir structure for day0 configuration
63 # Note: compressed option ignored
64 if configuration["generationTasks"]["network_dir"]["enabled"] is True:
70 if configuration["generationTasks"]["svg"]["enabled"] is True:
73 configuration["generationTasks"]["svg"]["compressed"]
77 if configuration["generationTasks"]["kml"]["enabled"] is True:
80 configuration["generationTasks"]["kml"]["compressed"]
84 print(validator.error_message())