Fixed typo en config.json and changed gennet output to match what is expected in starlark

This commit is contained in:
Alberto Soutullo
2023-02-22 16:47:40 +01:00
parent 823c637e82
commit 850de89c16
2 changed files with 13 additions and 11 deletions

View File

@@ -45,7 +45,8 @@ class networkType(Enum):
NW_DATA_FNAME = "network_data.json"
NODE_PREFIX, SUBNET_PREFIX, CONTAINER_PREFIX = "node", "subnetwork", "container"
EXTERNAL_NODES_PREFIX, NODE_PREFIX, SUBNET_PREFIX, CONTAINER_PREFIX = \
"nodes", "node", "subnetwork", "containers"
### I/O related fns ##############################################################
@@ -256,6 +257,7 @@ def generate_and_write_files(ctx: typer, G):
json_dump = {}
json_dump[CONTAINER_PREFIX] = {}
json_dump[EXTERNAL_NODES_PREFIX] = {}
inv = {}
for key, val in node2container.items():
if val[1] not in inv:
@@ -272,19 +274,19 @@ def generate_and_write_files(ctx: typer, G):
# write the per node toml for the i^ith node of appropriate type
node_type, i = node_types_enum[i], i+1
write_toml(ctx.params["output_dir"], node, generate_toml(topics, node_type))
json_dump[node] = {}
json_dump[node]["static_nodes"] = []
json_dump[EXTERNAL_NODES_PREFIX][node] = {}
json_dump[EXTERNAL_NODES_PREFIX][node]["static_nodes"] = []
for edge in G.edges(node):
json_dump[node]["static_nodes"].append(edge[1])
json_dump[node][SUBNET_PREFIX] = node2subnet[node]
json_dump[node]["image"] = nodeTypeToDocker.get(node_type)
json_dump[EXTERNAL_NODES_PREFIX][node]["static_nodes"].append(edge[1])
json_dump[EXTERNAL_NODES_PREFIX][node][SUBNET_PREFIX] = node2subnet[node]
json_dump[EXTERNAL_NODES_PREFIX][node]["image"] = nodeTypeToDocker.get(node_type)
# the per node tomls will continue for now as they include topics
json_dump[node]["node_config"] = f"{node}.toml"
json_dump[EXTERNAL_NODES_PREFIX][node]["node_config"] = f"{node}.toml"
# logs ought to continue as they need to be unique
json_dump[node]["node_log"] = f"{node}.log"
json_dump[EXTERNAL_NODES_PREFIX][node]["node_log"] = f"{node}.log"
port_shift, cid = node2container[node]
json_dump[node]["port_shift"] = port_shift
json_dump[node]["container_id"] = cid
json_dump[EXTERNAL_NODES_PREFIX][node]["port_shift"] = port_shift
json_dump[EXTERNAL_NODES_PREFIX][node]["container_id"] = cid
write_json(ctx.params["output_dir"], json_dump) # network wide json