Added a check for gennet config file, so if when calling from kurtosis if the gennet configuration is missing, it does not create a topology

This commit is contained in:
Alberto Soutullo
2023-01-21 20:32:43 +01:00
parent 4b7e5d90ce
commit 920cb94135

View File

@@ -211,11 +211,15 @@ def generate_and_write_files(dirname, num_topics, num_subnets, G):
def conf_callback(ctx: typer.Context, param: typer.CallbackParam, value: str):
if value:
typer.echo(f"Loading config file: {value}")
typer.echo(f"Loading config file: {value.split('/')[-1]}")
try:
with open(value, 'r') as f: # Load config file
conf = json.load(f)
conf = conf["gennet"]
if "gennet" in conf:
conf = conf["gennet"]
else:
print("Configuration not found. Skipping topology generation.")
sys.exit(1)
ctx.default_map = ctx.default_map or {} # Initialize the default map
ctx.default_map.update(conf) # Merge the config dict into default_map
except Exception as ex: