Compare commits
2 Commits
2669a7a185
...
689d377683
Author | SHA1 | Date | |
---|---|---|---|
689d377683 | |||
30ac033863 |
23
main.py
23
main.py
@ -66,10 +66,13 @@ def write_build_unit(args, yaml_dict: dict, service_name: str):
|
||||
|
||||
|
||||
def write_network_units(args, yaml_dict):
|
||||
for network_name in yaml_dict.get("networks", []):
|
||||
networks = yaml_dict.get("networks", {})
|
||||
if "default" not in networks:
|
||||
networks["default"] = None
|
||||
for network_name in networks:
|
||||
out_file = args.output_dir / f"{network_name}.network"
|
||||
print(f'Generating network "{network_name}" ({out_file})')
|
||||
network = yaml_dict["networks"].get(network_name)
|
||||
network = networks.get(network_name)
|
||||
if network is None:
|
||||
network = {}
|
||||
|
||||
@ -101,11 +104,12 @@ def write_service_units(args, yaml_dict):
|
||||
unit_file = IniFile()
|
||||
unit_file["Unit"] = {}
|
||||
unit_file["Unit"]["Description"] = f"{service_name.capitalize()} container"
|
||||
if "depends_on" in service:
|
||||
enforce_list("depends_on", service)
|
||||
for dependency in service["depends_on"]:
|
||||
unit_file["Unit"].setdefault("Requires", []).append(f"{dependency}.service")
|
||||
unit_file["Unit"].setdefault("After", []).append(f"{dependency}.service")
|
||||
# currently decreases reliability instead of increasing it
|
||||
# if "depends_on" in service:
|
||||
# enforce_list("depends_on", service)
|
||||
# for dependency in service["depends_on"]:
|
||||
# unit_file["Unit"].setdefault("Requires", []).append(f"{dependency}.service")
|
||||
# unit_file["Unit"].setdefault("After", []).append(f"{dependency}.service")
|
||||
|
||||
unit_file["Container"] = {}
|
||||
if "container_name" in service:
|
||||
@ -147,6 +151,11 @@ def write_service_units(args, yaml_dict):
|
||||
if "volumes" in service:
|
||||
enforce_list("volumes", service)
|
||||
unit_file["Container"]["Volume"] = service["volumes"]
|
||||
if "networks" in service:
|
||||
enforce_list("networks", service)
|
||||
unit_file["Container"]["Network"] = service["networks"]
|
||||
else:
|
||||
unit_file["Container"]["Network"] = ["default"]
|
||||
if "devices" in service:
|
||||
unit_file["Container"]["AddDevice"] = service["devices"]
|
||||
if "userns_mode" in service:
|
||||
|
Loading…
Reference in New Issue
Block a user