[lc_ldap] On met en place un système de propagation de certaines modifications.
* Quand on modifie un attribut qui devrait en modifier d'autres, on peut invoquer check_changes pour voir ce qui devrait être changé, puis validate_changes pour rendre ces changements effectifs. Il ne reste plus qu'à appeler save pour enregistrer le tout. * Correction de petits problèmes sur les locks : quand save réussissait, ils n'étaient pas virés.
This commit is contained in:
parent
9540bc572c
commit
c2968c6b15
5 changed files with 133 additions and 28 deletions
|
@ -70,6 +70,8 @@ def ip4_of_rid(rid):
|
|||
"""Convertit un rid en son IP associée"""
|
||||
# Au cas où
|
||||
rid = int(rid)
|
||||
if rid == -1:
|
||||
return u""
|
||||
|
||||
net, plage = find_rid_plage(rid)
|
||||
if net == 'Inconnu':
|
||||
|
@ -83,10 +85,13 @@ def ip4_of_rid(rid):
|
|||
try:
|
||||
return netaddr.IPAddress(netaddr.IPNetwork(config.NETs[net][0]).first + rid - plage[0])
|
||||
except KeyError:
|
||||
raise EnvironmentError("Les machines v6-only ne peuvent pas avoir d'ipv4 (%s)" % (net))
|
||||
return u""
|
||||
|
||||
def rid_of_ip4(ipv4):
|
||||
"""Convertit une ipv4 en rid, si possible"""
|
||||
if ipv4 == "":
|
||||
return -1
|
||||
|
||||
# Est-ce une machine spéciale ?
|
||||
for (rid, ip) in config.rid_machines_speciales.iteritems():
|
||||
if str(ipv4) == ip:
|
||||
|
@ -111,8 +116,8 @@ def prefixev6_of_rid(rid):
|
|||
if net == 'Inconnu':
|
||||
raise ValueError("Rid dans aucune plage: %d" % rid)
|
||||
|
||||
# fil-v6 ou wifi-v6, we don't care
|
||||
return netaddr.IPAddress(netaddr.IPNetwork(config.prefix['fil-v6'][0]).first + 2**64*rid)
|
||||
# adherents-v6 ou wifi-adh-v6, we don't care
|
||||
return netaddr.IPAddress(netaddr.IPNetwork(config.prefix['adherents-v6'][0]).first + 2**64*rid)
|
||||
|
||||
def ip6_of_mac(mac, rid):
|
||||
"""
|
||||
|
@ -120,6 +125,8 @@ def ip6_of_mac(mac, rid):
|
|||
"""
|
||||
# Au cas où
|
||||
rid = int(rid)
|
||||
if rid == -1:
|
||||
return u""
|
||||
|
||||
net, plage = find_rid_plage(rid)
|
||||
if net == 'Inconnu':
|
||||
|
@ -132,7 +139,7 @@ def ip6_of_mac(mac, rid):
|
|||
# hex retourne un str, donc on concatène, suivant la RFC
|
||||
euid64v6 = hex(int(mac[:2], 16)^0b00000010) + mac[2:6] + u'fffe' + mac[6:12]
|
||||
|
||||
# fil-v6 ou wifi-v6, we don't care
|
||||
# adherents-v6 ou wifi-adh-v6, we don't care
|
||||
if net != "special":
|
||||
return netaddr.IPAddress(netaddr.IPNetwork(config.prefix[net][0]).first + int(euid64v6, 16))
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue