Debian Codegraph @

tools/render-template

raw symbols SCIP
1 #!/usr/bin/env python3
2
3 import os
4 import sys
5 import argparse
6
7
8 def main():
9 _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
10 sys.path.insert(0, _tdir)
11 from cloudinit import templater, util # pylint: disable=E0401
12
13 VARIANTS = [
14 "almalinux",
15 "alpine",
16 "amazon",
17 "aosc",
18 "arch",
19 "azurelinux",
20 "benchmark",
21 "centos",
22 "cloudlinux",
23 "debian",
24 "dragonfly",
25 "eurolinux",
26 "fedora",
27 "freebsd",
28 "gentoo",
29 "mariner",
30 "miraclelinux",
31 "netbsd",
32 "openbsd",
33 "openeuler",
34 "OpenCloudOS",
35 "openmandriva",
36 "photon",
37 "raspberry-pi-os",
38 "rhel",
39 "suse",
40 "rocky",
41 "TencentOS",
42 "ubuntu",
43 "unknown",
44 "virtuozzo",
45 ]
46 parser = argparse.ArgumentParser()
47 platform = util.system_info()
48 parser.add_argument(
49 "--variant",
50 default=platform["variant"],
51 action="store",
52 help="define the variant.",
53 choices=VARIANTS,
54 )
55 parser.add_argument(
56 "--prefix",
57 action="store",
58 default=sys.prefix,
59 help="define the prefix. Default: " + sys.prefix,
60 )
61 parser.add_argument(
62 "--is-yaml",
63 action="store_true",
64 default=False,
65 help=(
66 "Rendered template is not expected to be valid yaml by default."
67 " Add this flag for extra validation."
68 ),
69 )
70 parser.add_argument(
71 "template",
72 nargs="?",
73 action="store",
74 default="./config/cloud.cfg.tmpl",
75 help="Path to the cloud.cfg template",
76 )
77 parser.add_argument(
78 "output",
79 nargs="?",
80 action="store",
81 default="-",
82 help="Output file. Use '-' to write to stdout",
83 )
84
85 args = parser.parse_args(sys.argv[1:])
86 templater.render_template(
87 args.variant, args.template, args.output, args.is_yaml, prefix=args.prefix
88 )
89
90
91 if __name__ == "__main__":
92 main()