diff --git a/services.py b/services.py index efe0d85..3ff8fc7 100644 --- a/services.py +++ b/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)