Add PartOf
This commit is contained in:
parent
a429621e42
commit
bfabf37420
7
main.py
7
main.py
@ -39,6 +39,9 @@ def enforce_list(key: str, dict_: dict):
|
||||
abort(f"{key} is not a list. Offending dict: {dict_}")
|
||||
|
||||
|
||||
def add_part_of(args, unit_file: IniFile):
|
||||
unit_file["Unit"]["PartOf"] = args.target
|
||||
|
||||
def write_file(ini_file: IniFile, path: Path):
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
ini_file.write(f)
|
||||
@ -79,6 +82,7 @@ def write_network_units(args, yaml_dict):
|
||||
unit_file = IniFile()
|
||||
unit_file["Unit"] = {}
|
||||
unit_file["Unit"]["Description"] = f"{network_name.capitalize()} network"
|
||||
add_part_of(args, unit_file)
|
||||
|
||||
unit_file["Network"] = {}
|
||||
if "name" in network:
|
||||
@ -105,6 +109,7 @@ def write_service_units(args, yaml_dict):
|
||||
unit_file = IniFile()
|
||||
unit_file["Unit"] = {}
|
||||
unit_file["Unit"]["Description"] = f"{service_name.capitalize()} container"
|
||||
add_part_of(args, unit_file)
|
||||
# currently decreases reliability instead of increasing it
|
||||
# if "depends_on" in service:
|
||||
# enforce_list("depends_on", service)
|
||||
@ -180,6 +185,8 @@ def parse_args():
|
||||
parser.add_argument("compose_file")
|
||||
parser.add_argument("-o", "--output-dir", help="output directory for unit files",
|
||||
default="/etc/containers/systemd", type=Path)
|
||||
parser.add_argument("-t", "--target",
|
||||
help="Add PartOf dependency to all unit files", default="containers.target")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user