* Corrections pour que les rid non désirés ne soient pas pris.
This commit is contained in:
parent
18571ae112
commit
6b55396794
2 changed files with 40 additions and 13 deletions
44
attributs.py
44
attributs.py
|
@ -33,13 +33,16 @@
|
|||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import re, sys, netaddr, time
|
||||
import re
|
||||
import sys
|
||||
import netaddr
|
||||
import time
|
||||
from unicodedata import normalize
|
||||
from crans_utils import format_tel, format_mac, mailexist, validate_name, ip4_of_rid, ip6_of_mac
|
||||
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
import config, annuaires_pg
|
||||
from ridtools import Rid
|
||||
import config
|
||||
import annuaires_pg
|
||||
|
||||
### Les droits
|
||||
# en cas de typo, l'appel d'une variable plante, on préfèrera donc les utiliser en lieu et place
|
||||
|
@ -207,6 +210,9 @@ class aid(intAttr):
|
|||
|
||||
can_view = [nounou, apprenti, 'Cableurs']
|
||||
|
||||
def parse_value(self, val, ldif):
|
||||
self.value = int(val)
|
||||
|
||||
class uid(Attr):
|
||||
singlevalue = True
|
||||
option = False
|
||||
|
@ -468,7 +474,6 @@ class ip6HostNumber(Attr):
|
|||
can_modify = [nounou]
|
||||
|
||||
def parse_value(self, ip, ldif):
|
||||
if ip == '<automatique>':
|
||||
ip = ip6_of_mac(ldif['macAddress'][0], ldif['rid'][0])
|
||||
self.value = netaddr.ip.IPAddress(ip)
|
||||
|
||||
|
@ -479,28 +484,44 @@ class mid(Attr):
|
|||
singlevalue = True
|
||||
optional = False
|
||||
unique = True
|
||||
legend = "Identifiant de machine"
|
||||
legend = u"Identifiant de machine"
|
||||
category = 'id'
|
||||
|
||||
def parse_value(self, mid, ldif):
|
||||
self.value = mid
|
||||
self.value = int(mid)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(int(self.value))
|
||||
return unicode(self.value)
|
||||
|
||||
class rid(Attr):
|
||||
singlevalue = True
|
||||
optional = False
|
||||
unique = True
|
||||
legend = "Identifiant réseau de machine"
|
||||
legend = u"Identifiant réseau de machine"
|
||||
category = 'id'
|
||||
can_modify = [nounou]
|
||||
|
||||
def parse_value(self, rid, ldif):
|
||||
self.value = Rid(rid = int(rid))
|
||||
rid = int(rid)
|
||||
|
||||
# On veut éviter les rid qui recoupent les ipv4 finissant par
|
||||
# .0 ou .255
|
||||
plages = [xrange(rid[a][0], rid[a][1]+1) for a in rid.keys() if 'v6' not in a]
|
||||
|
||||
for plage in plages:
|
||||
if rid in plage:
|
||||
if rid % 256 == 0 or rid % 256 == 255:
|
||||
rid = -1
|
||||
break
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
||||
self.value = rid
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(int(self.value))
|
||||
return unicode(self.value)
|
||||
|
||||
class ipsec(Attr):
|
||||
singlevalue = False
|
||||
|
@ -588,6 +609,9 @@ class cid(intAttr):
|
|||
legend = u"Identifiant du club"
|
||||
category = 'id'
|
||||
|
||||
def parse_value(self, val, ldif):
|
||||
self.value = int(val)
|
||||
|
||||
class responsable(Attr):
|
||||
singlevalue = True
|
||||
optional = True
|
||||
|
|
|
@ -60,7 +60,6 @@ import config
|
|||
import crans_utils
|
||||
from attributs import *
|
||||
from ldap_locks import CransLock
|
||||
import ridtools
|
||||
|
||||
uri = 'ldap://ldap.adm.crans.org/'
|
||||
base_dn = 'ou=data,dc=crans,dc=org'
|
||||
|
@ -325,6 +324,10 @@ class lc_ldap(ldap.ldapobject.LDAPObject):
|
|||
for i in plage:
|
||||
if i in nonfree:
|
||||
continue
|
||||
else:
|
||||
my_id = attrify(i, attr, self, True)
|
||||
if my_id.value != i:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue