Commit a3bf0b77 authored by pa's avatar pa 🌊 Committed by root
Browse files

Triming spaces and correcting syntax

parent f5821e93
{
"extensions":
[
"accueil.crans.org",
"adh.crans.org",
"adh-nat.crans.org",
"borne.crans.org",
"infra.crans.org"
]
[
"adh.crans.org",
"adh-nat.crans.org",
"infra.crans.org"
]
}
......@@ -31,6 +31,7 @@ if __name__ == "__main__":
parser.add_argument("-q", "--quiet", help="Diminue la verbosité des logs (à spécifier plusieurs fois pour diminuer la verbosité)", action='count', default=0)
parser.add_argument("-r", "--re2o-server", help="Nom du serveur re2o à contacter", type=str, default=None)
parser.add_argument("-u", "--re2o-user", help="Utilisateur re2o", type=str, default=None)
parser.add_argument("-d", "--do-not-regen", help="Do not regen the mail server", action='store_true')
parser.add_argument("-v", "--verbose", help="Augmente la verbosité des logs (à spécifier plusieurs fois pour augmenter la verbosité)", action='count', default=0)
args = parser.parse_args()
......@@ -91,7 +92,12 @@ if __name__ == "__main__":
template = jinja2.Template(list_template.read())
if args.export:
print('#'*(22+len(extension)))
print(f'########## {extension} ##########')
print('#'*(22+len(extension)))
print(template.render(machines=machines, extension=extension))
else:
with open(os.path.join(path, 'generated', f"dhcp.{extension}.list"), 'w') as generated:
generated.write(template.render(machines=machines, extension=extension))
if not args.do_not_regen:
subprocess.run(['/usr/bin/systemctl', 'restart', 'isc-dhcp-server'])
{% for machine in machines %}
host {{ machine.hostname }}.{{ extension }} {
hardware ethernet {{ machine.mac }}
fixed-address {{ machine.ip }}
hardware ethernet {{ machine.mac }};
fixed-address {{ machine.ip }};
}
{% endfor %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment