[dhcp] COnfiguration pour le dhcp failover

Omapi et dhcp-failover.conf sont générés en utilisant le module
python puis inclus dans la conf générale.
On distingue dans groups.xml un dhcp primaire et secondaire.
À priori, il n'est pas possible d'avoir plusieurs secondaire, d'où
l'avertissement dans dhcp-failover.conf si jamais cela arrive.
This commit is contained in:
Valentin Samir 2013-05-28 18:51:04 +02:00
parent 7f450a4e87
commit 80e87b27a1
8 changed files with 97 additions and 30 deletions

View file

@ -0,0 +1,37 @@
# -*- mode: python; encoding: utf-8 -*-
info["owner"] = "root"
info["group"] = "root"
info["perms"] = 0600
comment_start = "#"
header("Configuration pour le cluster dhcp pour %s" % admhostname)
include("ip")
import config
if len(config.dhcp_servers) > 2:
print "####################################################################"
print "## ATTENTION LA CONFIGURATION NE PEUT PAS GÉRER PLUS DE DEUX DHCP ##"
print "####################################################################"
myip = admip()
herip = admipof([name for name in config.dhcp_servers if name != admhostname][0].split('.',1)[0])
print 'failover peer "dhcp-failover" {'
if has("dhcp-server-primary"):
print """ primary;
split 128;
mclt 3600;"""
elif has("dhcp-server-secondary"):
print " secondary;"
print """ address %s;
port 647;
peer address %s;
peer port 647;
max-response-delay 30;
max-unacked-updates 10;
load balance max seconds 3;
}
""" % (myip, herip)

View file

@ -0,0 +1,21 @@
# -*- mode: python; encoding: utf-8 -*-
info["owner"] = "root"
info["group"] = "root"
info["perms"] = 0600
comment_start = "#"
header("Configuration pour omapi pour %s" % admhostname)
include("secrets")
print """
omapi-port 9991;
key omapi_key {
algorithm HMAC-MD5;
secret "%s";
};
omapi-key omapi_key;
""" % secrets.dhcp_omapi_keys.get(admhostname, '')