[services] Si un dhcp n'est pas joignable, ça n'est pas grâve
This commit is contained in:
parent
2bf07035ab
commit
57944ade6f
1 changed files with 13 additions and 9 deletions
22
services.py
22
services.py
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import ldap
|
||||
import socket
|
||||
import lc_ldap
|
||||
import attributs
|
||||
import objets
|
||||
|
@ -216,16 +217,19 @@ def services_to_restart(conn, old_attrs={}, new_attrs={}):
|
|||
# Cas du dhcp
|
||||
if attr.__class__ in services_to_attrs['dhcp']:
|
||||
for server in config.dhcp_servers:
|
||||
dhcp=dydhcp(server)
|
||||
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]):
|
||||
try:
|
||||
dhcp=dydhcp(server)
|
||||
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]))
|
||||
else:
|
||||
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]))
|
||||
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]))
|
||||
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]))
|
||||
except socket.error:
|
||||
pass
|
||||
|
||||
if service in services_to_time.keys():
|
||||
start = services_to_time[service](attr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue