crans_bcfg2/Python/etc/dhcp3/omapi.conf
2015-05-14 07:19:56 +02:00

31 lines
662 B
Python

# -*- mode: python; encoding: utf-8 -*-
info["owner"] = "root"
info["group"] = "root"
info["mode"] = 0600
comment_start = "#"
header("Configuration pour omapi pour %s" % admhostname)
import dhcp
import os
import base64
if not dhcp.dhcp_omapi_keys.get(admhostname, False):
host = admhostname
key = base64.encodestring(os.urandom(64)).replace('\n','')
with open('/etc/crans/secrets/dhcp/dhcp.key', 'a+') as f:
f.write("%s %s\n" % (host, key))
f.close()
reload(dhcp)
out("""
omapi-port 9991;
key omapi_key {
algorithm HMAC-MD5;
secret "%s";
};
omapi-key omapi_key;
""" % (dhcp.dhcp_omapi_keys.get(admhostname, ''),))