[services] Modifs de dydhcp, cf usr-scripts:9a5294c7ee60c1e9d439f1903a1dcda5b5322d41
This commit is contained in:
parent
8f4a7df242
commit
db9bf4540f
1 changed files with 11 additions and 5 deletions
16
services.py
16
services.py
|
@ -6,6 +6,7 @@ import lc_ldap
|
|||
import attributs
|
||||
import objets
|
||||
import variables
|
||||
import config
|
||||
from gen_confs.dhcpd_new import dydhcp
|
||||
|
||||
# liste des attributs dont dépend un service
|
||||
|
@ -210,16 +211,21 @@ def services_to_restart(conn, old_attrs={}, new_attrs={}):
|
|||
|
||||
# Cas du dhcp
|
||||
if attr.__class__ in services_to_attrs['dhcp']:
|
||||
dhcp=dydhcp()
|
||||
if old_attrs.get('ipHostNumber', []) and old_attrs.get('macAddress', []):
|
||||
if new_attrs.get('ipHostNumber', []) and new_attrs.get('macAddress', []):
|
||||
if str(old_attrs['ipHostNumber'][0]) != str(new_attrs['ipHostNumber'][0]) or str(old_attrs['macAddress'][0]) != str(new_attrs['macAddress'][0]):
|
||||
dhcp.del_host(str(old_attrs['ipHostNumber'][0]), str(old_attrs['macAddress'][0]))
|
||||
dhcp.add_host(str(new_attrs['ipHostNumber'][0]), str(new_attrs['macAddress'][0]), str(new_attrs['host'][0]))
|
||||
for server in config.dhcp_servers:
|
||||
dhcp=dydhcp(server)
|
||||
dhcp.del_host(str(old_attrs['ipHostNumber'][0]), str(old_attrs['macAddress'][0]))
|
||||
dhcp.add_host(str(new_attrs['ipHostNumber'][0]), str(new_attrs['macAddress'][0]), str(new_attrs['host'][0]))
|
||||
else:
|
||||
dhcp.del_host(str(old_attrs['ipHostNumber'][0]), str(old_attrs['macAddress'][0]))
|
||||
for server in config.dhcp_servers:
|
||||
dhcp=dydhcp(server)
|
||||
dhcp.del_host(str(old_attrs['ipHostNumber'][0]), str(old_attrs['macAddress'][0]))
|
||||
elif new_attrs.get('ipHostNumber', []) and new_attrs.get('macAddress', []):
|
||||
dhcp.add_host(str(new_attrs['ipHostNumber'][0]), str(new_attrs['macAddress'][0]), str(new_attrs['host'][0]))
|
||||
for server in config.dhcp_servers:
|
||||
dhcp=dydhcp(server)
|
||||
dhcp.add_host(str(new_attrs['ipHostNumber'][0]), str(new_attrs['macAddress'][0]), str(new_attrs['host'][0]))
|
||||
|
||||
if service in services_to_time.keys():
|
||||
start = services_to_time[service](attr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue