
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.
37 lines
1 KiB
Python
37 lines
1 KiB
Python
# -*- 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)
|