Ajout de l'attribut __slots__ aux classes pour économiser de la ram
This commit is contained in:
parent
61bf832112
commit
d8bac8d47e
5 changed files with 174 additions and 47 deletions
103
attributs.py
103
attributs.py
|
@ -196,6 +196,7 @@ class AttrsList(list):
|
|||
self._commit()
|
||||
|
||||
class AttrsDict(dict):
|
||||
__slots__ = ("_conn", "_parent", "_iterator")
|
||||
def __init__(self, conn, uldif={}, Parent=None):
|
||||
super(AttrsDict, self).__init__(uldif)
|
||||
self._conn = conn
|
||||
|
@ -250,10 +251,10 @@ class Attr(object):
|
|||
* ``val`` : valeur de l'attribut
|
||||
* ``ldif`` : objet contenant l'attribut (permet de faire les validations sur l'environnement)
|
||||
"""
|
||||
__slots__ = ("value", "conn", "parent")
|
||||
legend = "Human-readable description of attribute"
|
||||
singlevalue = False
|
||||
optional = True
|
||||
conn = None
|
||||
unique = False
|
||||
concurrent = True
|
||||
historique = "full" # valeurs possibles "full", "partial", "info", None
|
||||
|
@ -386,6 +387,7 @@ def crans_attribute(classe):
|
|||
|
||||
@crans_attribute
|
||||
class objectClass(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = False
|
||||
legend = "entité"
|
||||
|
@ -408,7 +410,7 @@ class objectClass(Attr):
|
|||
|
||||
|
||||
class intAttr(Attr):
|
||||
|
||||
__slots__ = ()
|
||||
python_type = int
|
||||
|
||||
def __add__(self, obj):
|
||||
|
@ -432,7 +434,7 @@ class intAttr(Attr):
|
|||
return unicode(self.value)
|
||||
|
||||
class floatAttr(Attr):
|
||||
|
||||
__slots__ = ()
|
||||
python_type = float
|
||||
|
||||
def __add__(self, obj):
|
||||
|
@ -454,7 +456,7 @@ class floatAttr(Attr):
|
|||
return unicode(self.value)
|
||||
|
||||
class boolAttr(Attr):
|
||||
|
||||
__slots__ = ()
|
||||
python_type = bool
|
||||
|
||||
def parse_value(self, val):
|
||||
|
@ -472,6 +474,7 @@ class boolAttr(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class aid(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u"Identifiant de l'adhérent"
|
||||
|
@ -489,6 +492,7 @@ class aid(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class uid(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
option = False
|
||||
legend = u"L'identifiant canonique de l'adhérent"
|
||||
|
@ -499,6 +503,7 @@ class uid(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class preferedLanguage(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
option = True
|
||||
legend = u"La langue préférée de l'adhérent"
|
||||
|
@ -508,6 +513,7 @@ class preferedLanguage(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class nom(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
legend = "Nom"
|
||||
|
@ -526,6 +532,7 @@ class nom(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class prenom(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
legend = u"Prénom"
|
||||
|
@ -538,6 +545,7 @@ class prenom(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class compteWiki(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u"Compte WiKi"
|
||||
|
@ -551,6 +559,7 @@ class compteWiki(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class tel(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
legend = u"Téléphone"
|
||||
|
@ -564,6 +573,7 @@ class tel(Attr):
|
|||
raise ValueError("Numéro de téléphone invalide (%r)" % tel)
|
||||
|
||||
class yearAttr(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
|
||||
|
@ -575,6 +585,7 @@ class yearAttr(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class paiement(yearAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Paiement"
|
||||
can_modify = [cableur, nounou, tresorier]
|
||||
category = 'perso'
|
||||
|
@ -582,6 +593,7 @@ class paiement(yearAttr):
|
|||
|
||||
@crans_attribute
|
||||
class carteEtudiant(Attr):
|
||||
__slots__ = ()
|
||||
legend = u"Carte d'étudiant"
|
||||
category = 'perso'
|
||||
can_modify = [cableur, nounou, tresorier]
|
||||
|
@ -592,6 +604,7 @@ class carteEtudiant(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class derniereConnexion(intAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Dernière connexion"
|
||||
can_modify = [nounou, cableur, soi] # il faut bien pouvoir le modifier pour le mettre à jour
|
||||
ldap_name = "derniereConnexion"
|
||||
|
@ -601,6 +614,7 @@ class generalizedTimeFormat(Attr):
|
|||
une donnée de temps suivant la RFC 4517
|
||||
|
||||
"""
|
||||
__slots__ = ("_stamp",)
|
||||
default = "19700101000000Z"
|
||||
|
||||
def __float__(self):
|
||||
|
@ -649,6 +663,7 @@ class generalizedTimeFormat(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class debutAdhesion(generalizedTimeFormat):
|
||||
__slots__ = ()
|
||||
legend = u"Date de début de l'adhésion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
|
@ -657,6 +672,7 @@ class debutAdhesion(generalizedTimeFormat):
|
|||
|
||||
@crans_attribute
|
||||
class finAdhesion(generalizedTimeFormat):
|
||||
__slots__ = ()
|
||||
legend = u"Date de fin de l'adhésion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
|
@ -664,6 +680,7 @@ class finAdhesion(generalizedTimeFormat):
|
|||
|
||||
@crans_attribute
|
||||
class debutConnexion(generalizedTimeFormat):
|
||||
__slots__ = ()
|
||||
legend = u"Date de début de la connexion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
|
@ -671,6 +688,7 @@ class debutConnexion(generalizedTimeFormat):
|
|||
|
||||
@crans_attribute
|
||||
class finConnexion(generalizedTimeFormat):
|
||||
__slots__ = ()
|
||||
legend = u"Date de fin de la connexion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
|
@ -678,6 +696,7 @@ class finConnexion(generalizedTimeFormat):
|
|||
|
||||
@crans_attribute
|
||||
class mail(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = False
|
||||
unique = True
|
||||
|
@ -733,6 +752,7 @@ class mail(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class canonicalAlias(mail):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -747,6 +767,7 @@ class canonicalAlias(mail):
|
|||
|
||||
@crans_attribute
|
||||
class mailAlias(mail):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -757,6 +778,7 @@ class mailAlias(mail):
|
|||
|
||||
@crans_attribute
|
||||
class mailExt(mail):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -774,6 +796,7 @@ class mailExt(mail):
|
|||
|
||||
@crans_attribute
|
||||
class mailInvalide(boolAttr):
|
||||
__slots__ = ()
|
||||
optional = True
|
||||
legend = u"Mail invalide"
|
||||
can_modify = [bureau, nounou]
|
||||
|
@ -781,6 +804,7 @@ class mailInvalide(boolAttr):
|
|||
|
||||
@crans_attribute
|
||||
class contourneGreylist(boolAttr):
|
||||
__slots__ = ()
|
||||
optionnal = True
|
||||
legend = u"Contourner la greylist"
|
||||
category = 'mail'
|
||||
|
@ -792,6 +816,7 @@ class contourneGreylist(boolAttr):
|
|||
|
||||
@crans_attribute
|
||||
class etudes(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u"Études"
|
||||
|
@ -801,6 +826,7 @@ class etudes(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class chbre(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
unique = True
|
||||
|
@ -824,6 +850,7 @@ class chbre(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class droits(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u"Droits sur les serveurs"
|
||||
|
@ -851,6 +878,7 @@ class droits(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class solde(floatAttr):
|
||||
__slots__ = ()
|
||||
python_type = float
|
||||
singlevalue = True
|
||||
concurrent = False
|
||||
|
@ -869,6 +897,7 @@ class solde(floatAttr):
|
|||
return u"%.2f" % self.value
|
||||
|
||||
class dnsAttr(Attr):
|
||||
__slots__ = ()
|
||||
category = 'dns'
|
||||
ldap_name = "dnsAttr"
|
||||
python_type = unicode
|
||||
|
@ -883,6 +912,7 @@ class dnsAttr(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class host(dnsAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
unique = True
|
||||
optional = False
|
||||
|
@ -902,6 +932,7 @@ class host(dnsAttr):
|
|||
|
||||
@crans_attribute
|
||||
class hostAlias(host):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
unique = True
|
||||
optional = True
|
||||
|
@ -911,6 +942,7 @@ class hostAlias(host):
|
|||
|
||||
@crans_attribute
|
||||
class macAddress(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
legend = u"Adresse physique de la carte réseau"
|
||||
|
@ -933,6 +965,7 @@ class macAddress(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class ipHostNumber(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -954,6 +987,7 @@ class ipHostNumber(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class ip6HostNumber(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -977,6 +1011,7 @@ class ip6HostNumber(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class mid(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
unique = True
|
||||
|
@ -986,6 +1021,7 @@ class mid(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class rid(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -1017,6 +1053,7 @@ class rid(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class ipsec(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u'Clef wifi'
|
||||
|
@ -1036,6 +1073,7 @@ class ipsec(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class puissance(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u"puissance d'émission pour les bornes wifi"
|
||||
|
@ -1045,6 +1083,7 @@ class puissance(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class canal(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u'Canal d\'émission de la borne'
|
||||
|
@ -1054,6 +1093,7 @@ class canal(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class hotspot(boolAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u'Hotspot'
|
||||
|
@ -1063,6 +1103,7 @@ class hotspot(boolAttr):
|
|||
|
||||
@crans_attribute
|
||||
class positionBorne(Attr):
|
||||
__slots__ = ()
|
||||
legend = u"Position de la borne"
|
||||
category = "wifi"
|
||||
can_modify = [nounou]
|
||||
|
@ -1072,12 +1113,14 @@ class positionBorne(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class nvram(Attr):
|
||||
__slots__ = ()
|
||||
legend = u"Configuration speciale"
|
||||
optional = True
|
||||
can_modify = [nounou]
|
||||
ldap_name = "nvram"
|
||||
|
||||
class portAttr(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u'Ouverture de port'
|
||||
|
@ -1114,26 +1157,31 @@ class portAttr(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class portTCPout(portAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Port TCP ouvert vers l'extérieur"
|
||||
ldap_name = "portTCPout"
|
||||
|
||||
@crans_attribute
|
||||
class portTCPin(portAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Port TCP ouvert depuis l'extérieur"
|
||||
ldap_name = "portTCPin"
|
||||
|
||||
@crans_attribute
|
||||
class portUDPout(portAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Port UDP ouvert vers l'extérieur"
|
||||
ldap_name = "portUDPout"
|
||||
|
||||
@crans_attribute
|
||||
class portUDPin(portAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Port UDP ouvert depuis l'extérieur"
|
||||
ldap_name = "portUDPin"
|
||||
|
||||
@crans_attribute
|
||||
class exempt(Attr):
|
||||
__slots__ = ()
|
||||
legend = u"Exemption vers une IP"
|
||||
ldap_name = "exempt"
|
||||
python_type = netaddr.IPNetwork
|
||||
|
@ -1147,6 +1195,7 @@ class exempt(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class nombrePrises(intAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Nombre de prises ethernet de la machine"
|
||||
singlevalue = True
|
||||
optional = True
|
||||
|
@ -1156,6 +1205,7 @@ class nombrePrises(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class prise(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u"Prise sur laquelle est branchée la machine"
|
||||
|
@ -1165,6 +1215,7 @@ class prise(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class cid(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -1177,6 +1228,7 @@ class cid(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class responsable(Attr):
|
||||
__slots__ = ('__value', '_value')
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u"Responsable du club"
|
||||
|
@ -1222,6 +1274,7 @@ class responsable(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class imprimeurClub(Attr):
|
||||
__slots__ = ("__value", "_value")
|
||||
optional = True
|
||||
legend = u"Imprimeur du club"
|
||||
category = "perso"
|
||||
|
@ -1262,6 +1315,7 @@ class imprimeurClub(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class blacklist(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u"Blackliste"
|
||||
|
@ -1314,7 +1368,7 @@ class blacklist(Attr):
|
|||
@crans_attribute
|
||||
class historique(Attr):
|
||||
"""Un historique est usuellement de la forme JJ/MM/AAAA HH:mm:ss, action comm"""
|
||||
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
concurrent = False
|
||||
optional = True
|
||||
|
@ -1339,6 +1393,7 @@ class historique(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class info(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u"Quelques informations"
|
||||
|
@ -1349,6 +1404,7 @@ class info(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class homepageAlias(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u'Un alias pour la page personnelle'
|
||||
|
@ -1358,6 +1414,7 @@ class homepageAlias(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class charteMA(boolAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend= "Signale si l'adhérent a signé la charte de membres actifs"
|
||||
|
@ -1367,6 +1424,7 @@ class charteMA(boolAttr):
|
|||
|
||||
@crans_attribute
|
||||
class homeDirectory(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue=True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -1392,6 +1450,7 @@ class homeDirectory(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class loginShell(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = "Le shell de l'adherent"
|
||||
|
@ -1408,6 +1467,7 @@ class loginShell(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class uidNumber(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -1417,6 +1477,7 @@ class uidNumber(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class gidNumber(intAttr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = "Le gid du compte de l'adhérent"
|
||||
|
@ -1425,6 +1486,7 @@ class gidNumber(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class gecos(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = "Le gecos"
|
||||
|
@ -1433,6 +1495,7 @@ class gecos(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class userPassword(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = "Le mot de passe"
|
||||
|
@ -1459,6 +1522,7 @@ class userPassword(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class sshFingerprint(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = "Clef ssh de la machine"
|
||||
|
@ -1506,6 +1570,7 @@ class sshFingerprint(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class gpgFingerprint(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -1517,6 +1582,7 @@ class gpgFingerprint(Attr):
|
|||
class gpgMail(mail):
|
||||
"""Attribut servant à stocker un mail allant de paire avec
|
||||
l'un des uid dans la clef gpg pointée par gpgFingerprint"""
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
unique = True
|
||||
|
@ -1532,6 +1598,7 @@ class gpgMail(mail):
|
|||
|
||||
@crans_attribute
|
||||
class cn(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
category = 'id'
|
||||
|
@ -1539,6 +1606,7 @@ class cn(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class dn(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = False
|
||||
unique = True
|
||||
|
@ -1547,6 +1615,7 @@ class dn(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class postalAddress(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
can_modify = [soi, cableur, nounou, bureau]
|
||||
|
@ -1556,6 +1625,7 @@ class postalAddress(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class controle(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = True
|
||||
optional = True
|
||||
legend = u"Contrôle"
|
||||
|
@ -1570,6 +1640,7 @@ class controle(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class fid(intAttr):
|
||||
__slots__ = ()
|
||||
legend = u"Id de facture"
|
||||
category = 'factures'
|
||||
optional = False
|
||||
|
@ -1578,6 +1649,7 @@ class fid(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class modePaiement(Attr):
|
||||
__slots__ = ()
|
||||
legend = u"Mode de paiement"
|
||||
category = 'factures'
|
||||
optional = False
|
||||
|
@ -1592,11 +1664,13 @@ class modePaiement(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class recuPaiement(Attr):
|
||||
__slots__ = ()
|
||||
ldap_name = "recuPaiement"
|
||||
can_modify = [cableur, nounou]
|
||||
|
||||
@crans_attribute
|
||||
class article(Attr):
|
||||
__slots__ = ()
|
||||
singlevalue = False
|
||||
optional = True
|
||||
legend = u"Articles"
|
||||
|
@ -1640,26 +1714,31 @@ class article(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class dnsIpv6(boolAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "dnsIpv6"
|
||||
legend = "Détermine si l'ipv6 apparait dans le dns"
|
||||
can_modify = [nounou, parent, cableur]
|
||||
|
||||
@crans_attribute
|
||||
class rewriteMailHeaders(boolAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "rewriteMailHeaders"
|
||||
|
||||
@crans_attribute
|
||||
class machineAlias(boolAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "machineAlias"
|
||||
|
||||
@crans_attribute
|
||||
class issuerCN(Attr):
|
||||
__slots__ = ()
|
||||
ldap_name = "issuerCN"
|
||||
can_modify = [nounou]
|
||||
legend = "Common Name de l'éméteur du certificat"
|
||||
|
||||
@crans_attribute
|
||||
class serialNumber(Attr):
|
||||
__slots__ = ()
|
||||
ldap_name = "serialNumber"
|
||||
python_type = int
|
||||
can_modify = [nounou]
|
||||
|
@ -1667,18 +1746,21 @@ class serialNumber(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class start(intAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "start"
|
||||
can_modify = [nounou]
|
||||
legend = "Date de début"
|
||||
|
||||
@crans_attribute
|
||||
class end(intAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "end"
|
||||
can_modify = [nounou]
|
||||
legend = "Date de fin"
|
||||
|
||||
@crans_attribute
|
||||
class crlUrl(Attr):
|
||||
__slots__ = ()
|
||||
ldap_name = "crlUrl"
|
||||
optional = True
|
||||
can_modify = [parent, nounou]
|
||||
|
@ -1686,6 +1768,7 @@ class crlUrl(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class revocked(boolAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "revocked"
|
||||
singlevalue = True
|
||||
optional = True
|
||||
|
@ -1694,6 +1777,7 @@ class revocked(boolAttr):
|
|||
|
||||
@crans_attribute
|
||||
class encrypted(boolAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "encrypted"
|
||||
singlevalue = True
|
||||
optional = True
|
||||
|
@ -1702,6 +1786,7 @@ class encrypted(boolAttr):
|
|||
|
||||
@crans_attribute
|
||||
class privatekey(Attr):
|
||||
__slots__ = ()
|
||||
ldap_name = "privatekey"
|
||||
python_type = str
|
||||
can_modify = [parent, nounou]
|
||||
|
@ -1710,6 +1795,7 @@ class privatekey(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class csr(Attr):
|
||||
__slots__ = ("data",)
|
||||
ldap_name = "csr"
|
||||
python_type = str
|
||||
can_modify = [parent, nounou]
|
||||
|
@ -1739,6 +1825,7 @@ class csr(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class certificat(Attr):
|
||||
__slots__ = ("data",)
|
||||
ldap_name = "certificat"
|
||||
binary = True
|
||||
python_type = str
|
||||
|
@ -1799,6 +1886,7 @@ class certificat(Attr):
|
|||
|
||||
@crans_attribute
|
||||
class certificatUsage(intAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "certificatUsage"
|
||||
singlevalue = True
|
||||
can_modify = [parent, nounou]
|
||||
|
@ -1806,6 +1894,7 @@ class certificatUsage(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class selector(intAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "selector"
|
||||
singlevalue = True
|
||||
can_modify = [parent, nounou]
|
||||
|
@ -1813,6 +1902,7 @@ class selector(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class matchingType(intAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "matchingType"
|
||||
singlevalue = True
|
||||
can_modify = [parent, nounou]
|
||||
|
@ -1820,6 +1910,7 @@ class matchingType(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class xid(intAttr):
|
||||
__slots__ = ()
|
||||
ldap_name = "xid"
|
||||
category = 'id'
|
||||
unique = True
|
||||
|
@ -1830,6 +1921,7 @@ class xid(intAttr):
|
|||
|
||||
@crans_attribute
|
||||
class hostCert(dnsAttr):
|
||||
__slots__ = ()
|
||||
optional = False
|
||||
can_modify = [parent, nounou]
|
||||
ldap_name = "hostCert"
|
||||
|
@ -1850,6 +1942,7 @@ class shadowExpire(intAttr):
|
|||
Durée de validité du mot de passe d'un compte.
|
||||
On l'utilise en mettant sa valeur à 0 pour désactiver un compte
|
||||
"""
|
||||
__slots__ = ()
|
||||
optinal = True
|
||||
can_modify = [nounou, bureau]
|
||||
ldap_name = "shadowExpire"
|
||||
|
|
|
@ -82,6 +82,7 @@ def ldif_to_uldif(ldif):
|
|||
class lc_ldap(ldap.ldapobject.LDAPObject, object):
|
||||
"""Connexion à la base ldap crans, chaque instance représente une connexion
|
||||
"""
|
||||
__slots__ = ("lockholder", "conn", "dn", "droits", "current_login", "_username_given")
|
||||
def __init__(self, dn=None, user=None, cred=None, uri=variables.uri,
|
||||
readonly_dn=None, readonly_password=None):
|
||||
"""Initialise la connexion ldap,
|
||||
|
|
|
@ -86,6 +86,7 @@ class LdapLockHolder:
|
|||
"""
|
||||
Système de gestion des locks pour une instance de lc_ldap.
|
||||
"""
|
||||
__slots__ = ("locks", "host", "pid", "conn", "timeout")
|
||||
def __init__(self, conn):
|
||||
"""
|
||||
On crée la connexion, et on crée un dico vide.
|
||||
|
|
107
objets.py
107
objets.py
|
@ -66,14 +66,6 @@ import cranslib.deprecated
|
|||
|
||||
#: Champs à ignorer dans l'historique
|
||||
HIST_IGNORE_FIELDS = ["modifiersName", "entryCSN", "modifyTimestamp", "historique"]
|
||||
crans_account_attribs = [attributs.uid, attributs.canonicalAlias, attributs.solde,
|
||||
attributs.contourneGreylist, attributs.derniereConnexion,
|
||||
attributs.homepageAlias, attributs.loginShell, attributs.gecos,
|
||||
attributs.uidNumber, attributs.homeDirectory,
|
||||
attributs.gidNumber, attributs.userPassword,
|
||||
attributs.mailAlias, attributs.cn, attributs.rewriteMailHeaders,
|
||||
attributs.mailExt, attributs.compteWiki, attributs.droits,
|
||||
attributs.shadowExpire]
|
||||
|
||||
def new_cransldapobject(conn, dn, mode='ro', uldif=None, lockId=None):
|
||||
"""Crée un objet :py:class:`CransLdapObject` en utilisant la classe correspondant à
|
||||
|
@ -107,6 +99,7 @@ class CransLdapObject(object):
|
|||
Cette classe ne devrait pas être utilisée directement."""
|
||||
|
||||
""" Qui peut faire quoi ? """
|
||||
__slots__ = ("in_context", "conn", "lockId", "attrs", "_modifs", "dn", "parent_dn", "mode")
|
||||
can_be_by = { variables.created: [attributs.nounou],
|
||||
variables.modified: [attributs.nounou],
|
||||
variables.deleted: [attributs.nounou],
|
||||
|
@ -218,9 +211,9 @@ class CransLdapObject(object):
|
|||
# Sortie du context manager
|
||||
self.in_context = False
|
||||
# On rend les écriture impossible
|
||||
self.save = self._out_of_context
|
||||
self.create = self._out_of_context
|
||||
self.delete = self._out_of_context
|
||||
#self.save = self._out_of_context
|
||||
#self.create = self._out_of_context
|
||||
#self.delete = self._out_of_context
|
||||
# On retombe en read only
|
||||
self.mode = 'ro'
|
||||
# On purge les lock de l'objet
|
||||
|
@ -805,6 +798,7 @@ class ObjectFactory(object):
|
|||
Cette classe n'est jamais instanciée.
|
||||
|
||||
"""
|
||||
__slots__ = ()
|
||||
_classes = {}
|
||||
|
||||
@classmethod
|
||||
|
@ -830,6 +824,7 @@ def crans_object(classe):
|
|||
|
||||
@crans_object
|
||||
class InetOrgPerson(CransLdapObject):
|
||||
__slots__ = ()
|
||||
ldap_name = "inetOrgPerson"
|
||||
def __repr__(self):
|
||||
return str(self.__class__.__name__) + " : cn=" + str(self['cn'][0])
|
||||
|
@ -837,16 +832,33 @@ class InetOrgPerson(CransLdapObject):
|
|||
|
||||
class proprio(CransLdapObject):
|
||||
u""" Un propriétaire de machine (adhérent, club…) """
|
||||
__slots__ = ("_machines", "_factures", "full")
|
||||
can_be_by = { variables.created: [attributs.nounou, attributs.bureau, attributs.cableur],
|
||||
variables.modified: [attributs.nounou, attributs.bureau, attributs.soi, attributs.cableur],
|
||||
variables.deleted: [attributs.nounou, attributs.bureau,],
|
||||
}
|
||||
|
||||
attribs = [attributs.nom, attributs.chbre, attributs.paiement, attributs.info,
|
||||
|
||||
crans_account_attribs = [attributs.uid, attributs.canonicalAlias, attributs.solde,
|
||||
attributs.contourneGreylist, attributs.derniereConnexion,
|
||||
attributs.homepageAlias, attributs.loginShell, attributs.gecos,
|
||||
attributs.uidNumber, attributs.homeDirectory,
|
||||
attributs.gidNumber, attributs.userPassword,
|
||||
attributs.mailAlias, attributs.cn, attributs.rewriteMailHeaders,
|
||||
attributs.mailExt, attributs.compteWiki, attributs.droits,
|
||||
attributs.shadowExpire]
|
||||
default_attribs = [attributs.nom, attributs.chbre, attributs.paiement, attributs.info,
|
||||
attributs.blacklist, attributs.controle, attributs.historique,
|
||||
attributs.debutAdhesion, attributs.finAdhesion, attributs.debutConnexion,
|
||||
attributs.finConnexion]
|
||||
|
||||
@property
|
||||
def attribs(self):
|
||||
if u'cransAccount' in self['objectClass']:
|
||||
return self.default_attribs + self.crans_account_attribs
|
||||
else:
|
||||
return self.default_attribs
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.__class__.__name__) + " : nom=" + str(self['nom'][0])
|
||||
|
||||
|
@ -854,9 +866,6 @@ class proprio(CransLdapObject):
|
|||
super(proprio, self).__init__(*args, **kwargs)
|
||||
self._machines = None
|
||||
self._factures = None
|
||||
if u'cransAccount' in self['objectClass']:
|
||||
self.attribs = self.attribs + crans_account_attribs
|
||||
self.full = True
|
||||
|
||||
def delete_compte(self, mail):
|
||||
# Je pense qu'en pratique cette vérification ne sert à rien puisqu'on se fera jetter à la tentative de modification
|
||||
|
@ -880,7 +889,6 @@ class proprio(CransLdapObject):
|
|||
self['mailExt']=[]
|
||||
self['uid' ]=[]
|
||||
self._modifs['objectClass'] = [u'adherent']
|
||||
self.attribs = list(set(self.attribs).difference(crans_account_attribs))
|
||||
self.full = False
|
||||
|
||||
|
||||
|
@ -907,9 +915,6 @@ class proprio(CransLdapObject):
|
|||
if os.path.exists("/var/mail/" + login):
|
||||
raise ValueError('Création du compte impossible : /var/mail/%s existant' % str(login))
|
||||
|
||||
if not self.full:
|
||||
self.attribs = self.attribs + crans_account_attribs
|
||||
self.full = True
|
||||
self['uid' ] = [login]
|
||||
self['homeDirectory'] = [home]
|
||||
self['mail'] = [login + u"@crans.org"]
|
||||
|
@ -1094,6 +1099,7 @@ class proprio(CransLdapObject):
|
|||
|
||||
class machine(CransLdapObject):
|
||||
u""" Une machine """
|
||||
__slots__ = ("_proprio", "_certificats")
|
||||
can_be_by = { variables.created: [attributs.nounou, attributs.bureau, attributs.cableur, attributs.parent, attributs.respo],
|
||||
variables.modified: [attributs.nounou, attributs.bureau, attributs.cableur, attributs.parent, attributs.respo],
|
||||
variables.deleted: [attributs.nounou, attributs.bureau, attributs.cableur, attributs.parent, attributs.respo],
|
||||
|
@ -1272,6 +1278,7 @@ class machine(CransLdapObject):
|
|||
|
||||
class AssociationCrans(proprio):
|
||||
""" Association crans (propriétaire particulier)."""
|
||||
__slots__ = ()
|
||||
def save(self):
|
||||
pass
|
||||
|
||||
|
@ -1285,7 +1292,7 @@ class AssociationCrans(proprio):
|
|||
|
||||
class BaseInvites(proprio):
|
||||
u"""Un artefact de la base ldap"""
|
||||
|
||||
__slots__ = ()
|
||||
def __repr__(self):
|
||||
return str(self.__class__.__name__)
|
||||
|
||||
|
@ -1295,7 +1302,11 @@ class BaseInvites(proprio):
|
|||
@crans_object
|
||||
class adherent(proprio):
|
||||
u"""Adhérent crans."""
|
||||
attribs = proprio.attribs + [attributs.aid, attributs.prenom, attributs.tel,
|
||||
__slots__ = ("_clubs", "_imprimeur_clubs")
|
||||
|
||||
@property
|
||||
def attribs(self):
|
||||
return super(adherent, self).attribs + [attributs.aid, attributs.prenom, attributs.tel,
|
||||
attributs.mail, attributs.mailInvalide, attributs.charteMA,
|
||||
attributs.derniereConnexion, attributs.gpgFingerprint,
|
||||
attributs.carteEtudiant, attributs.etudes,
|
||||
|
@ -1334,23 +1345,32 @@ class adherent(proprio):
|
|||
@crans_object
|
||||
class club(proprio):
|
||||
u"""Club crans"""
|
||||
__slots__ = ()
|
||||
can_be_by = { variables.created: [attributs.nounou, attributs.bureau, attributs.cableur],
|
||||
variables.modified: [attributs.nounou, attributs.bureau, attributs.respo, attributs.cableur],
|
||||
variables.deleted: [attributs.nounou, attributs.bureau],
|
||||
}
|
||||
attribs = proprio.attribs + [attributs.cid, attributs.responsable, attributs.imprimeurClub]
|
||||
ldap_name = "club"
|
||||
|
||||
@property
|
||||
def attribs(self):
|
||||
return super(club, self).attribs + [attributs.cid, attributs.responsable, attributs.imprimeurClub]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(club, self).__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return "Club : " + str(self['nom'][0])
|
||||
|
||||
@crans_object
|
||||
class machineFixe(machine):
|
||||
u"""Machine fixe"""
|
||||
__slots__ = ()
|
||||
ldap_name = "machineFixe"
|
||||
|
||||
class machineMulticast(machine):
|
||||
u"""Machine pour inféré à partir des announces sap"""
|
||||
__slots__ = ()
|
||||
ldap_name = None
|
||||
def save(self):
|
||||
pass
|
||||
|
@ -1368,6 +1388,7 @@ class machineMulticast(machine):
|
|||
@crans_object
|
||||
class machineWifi(machine):
|
||||
u"""Machine wifi"""
|
||||
__slots__ = ()
|
||||
attribs = machine.attribs + [attributs.ipsec]
|
||||
ldap_name = "machineWifi"
|
||||
|
||||
|
@ -1388,6 +1409,7 @@ class machineWifi(machine):
|
|||
|
||||
@crans_object
|
||||
class machineCrans(machine):
|
||||
__slots__ = ()
|
||||
can_be_by = { variables.created: [attributs.nounou],
|
||||
variables.modified: [attributs.nounou],
|
||||
variables.deleted: [attributs.nounou],
|
||||
|
@ -1397,6 +1419,7 @@ class machineCrans(machine):
|
|||
|
||||
@crans_object
|
||||
class borneWifi(machine):
|
||||
__slots__ = ()
|
||||
can_be_by = { variables.created: [attributs.nounou],
|
||||
variables.modified: [attributs.nounou],
|
||||
variables.deleted: [attributs.nounou],
|
||||
|
@ -1407,6 +1430,7 @@ class borneWifi(machine):
|
|||
|
||||
@crans_object
|
||||
class switchCrans(machine):
|
||||
__slots__ = ()
|
||||
can_be_by = { variables.created: [attributs.nounou],
|
||||
variables.modified: [attributs.nounou],
|
||||
variables.deleted: [attributs.nounou],
|
||||
|
@ -1417,6 +1441,7 @@ class switchCrans(machine):
|
|||
|
||||
@crans_object
|
||||
class facture(CransLdapObject):
|
||||
__slots__ = ("_proprio", "_has_frais", "_recuPaiement", "_article_frais")
|
||||
can_be_by = { variables.created: [attributs.nounou, attributs.bureau, attributs.cableur],
|
||||
variables.modified: [attributs.nounou, attributs.bureau, attributs.cableur],
|
||||
variables.deleted: [attributs.nounou, attributs.bureau, attributs.cableur],
|
||||
|
@ -1427,16 +1452,16 @@ class facture(CransLdapObject):
|
|||
attributs.finConnexion, attributs.controle ]
|
||||
ldap_name = "facture"
|
||||
|
||||
_proprio = None
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.__class__.__name__) + " : fid=" + str(self['fid'][0])
|
||||
|
||||
#### GROS HACK pour rester comptatible avec ldap_crans où l'article representant les frais n'est ajouté qu'une fois le paiement reçu
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._proprio = None
|
||||
super(facture, self).__init__(*args, **kwargs)
|
||||
self._has_frais = True if [art for art in self.attrs.get('article', []) if art['code'] != 'FRAIS'] else False
|
||||
self._recuPaiement = True if self['recuPaiement'] else False
|
||||
self._article_frais = None
|
||||
|
||||
def __getitem__(self,attr, default=None):
|
||||
ret = super(facture, self).__getitem__(attr, default)
|
||||
|
@ -1451,7 +1476,6 @@ class facture(CransLdapObject):
|
|||
raise EnvironmentError("Paiement déjà effectué pour cette facture, impossible de modifier son contenu")
|
||||
return super(facture, self).__setitem__(attr, value)
|
||||
|
||||
_article_frais = None
|
||||
def _frais(self, mode=None):
|
||||
if mode is None:
|
||||
mode = self['modePaiement'][0]
|
||||
|
@ -1536,11 +1560,12 @@ class facture(CransLdapObject):
|
|||
|
||||
@crans_object
|
||||
class baseCert(CransLdapObject):
|
||||
__slots__ = ("_machine",)
|
||||
can_be_by = { variables.created: [attributs.nounou, attributs.bureau, attributs.parent],
|
||||
variables.modified: [attributs.nounou, attributs.bureau, attributs.parent],
|
||||
variables.deleted: [attributs.nounou, attributs.bureau, attributs.parent],
|
||||
}
|
||||
attribs = [ attributs.xid, attributs.certificat, attributs.hostCert, attributs.historique,
|
||||
default_attribs = [ attributs.xid, attributs.certificat, attributs.hostCert, attributs.historique,
|
||||
attributs.info, attributs.csr ]
|
||||
|
||||
tlsa_attribs = [ attributs.certificatUsage, attributs.selector, attributs.matchingType,
|
||||
|
@ -1550,11 +1575,24 @@ class baseCert(CransLdapObject):
|
|||
|
||||
private_attribs = [ attributs.privatekey, attributs.encrypted ]
|
||||
|
||||
@property
|
||||
def attribs(self):
|
||||
attribs = list(self.default_attribs)
|
||||
if "TLSACert" in self['objectClass']:
|
||||
attribs.extend(self.tlsa_attribs)
|
||||
if 'x509Cert' in self['objectClass']:
|
||||
attribs.extend(self.x509_attribs)
|
||||
if "privateKey" in self['objectClass']:
|
||||
attribs.extend(self.private_attribs)
|
||||
return attribs
|
||||
ldap_name = "baseCert"
|
||||
|
||||
protected_issuer = [u'CAcert Class 3 Root', u'CA Cert Signing Authority']
|
||||
|
||||
_machine = None
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._machine = None
|
||||
super(baseCert, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
if self['info']:
|
||||
|
@ -1562,14 +1600,6 @@ class baseCert(CransLdapObject):
|
|||
else:
|
||||
return "Certificat : xid=" + str(self['xid'][0])
|
||||
|
||||
def update_attribs(self):
|
||||
if "TLSACert" in self['objectClass']:
|
||||
self.attribs.extend(self.tlsa_attribs)
|
||||
if 'x509Cert' in self['objectClass']:
|
||||
self.attribs.extend(self.x509_attribs)
|
||||
if "privateKey" in self['objectClass']:
|
||||
self.attribs.extend(self.private_attribs)
|
||||
|
||||
def _check_setitem(self, attr, values):
|
||||
"""
|
||||
Vérifie des contraintes non liées à LDAP lors d'un __setitem__,
|
||||
|
@ -1589,7 +1619,7 @@ class baseCert(CransLdapObject):
|
|||
if u"privateKey" in self['objectClass']:
|
||||
return
|
||||
self._modifs['objectClass'].append(u"privateKey")
|
||||
self.attribs.extend(self.private_attribs)
|
||||
#self.attribs.extend(self.private_attribs)
|
||||
self['encrypted']=encrypted
|
||||
self['privatekey']=privatekey
|
||||
|
||||
|
@ -1599,7 +1629,7 @@ class baseCert(CransLdapObject):
|
|||
if u"TLSACert" in self['objectClass']:
|
||||
return
|
||||
self._modifs['objectClass'].append(u"TLSACert")
|
||||
self.attribs.extend(self.tlsa_attribs)
|
||||
#self.attribs.extend(self.tlsa_attribs)
|
||||
self['certificatUsage']=certificatUsage
|
||||
self['matchingType']=matchingType
|
||||
self['selector']=0
|
||||
|
@ -1610,7 +1640,7 @@ class baseCert(CransLdapObject):
|
|||
if u"x509Cert" in self['objectClass']:
|
||||
return
|
||||
self._modifs['objectClass'].append(u"x509Cert")
|
||||
self.attribs.extend(self.x509_attribs)
|
||||
#self.attribs.extend(self.x509_attribs)
|
||||
self['issuerCN'] = issuerCN
|
||||
self['start'] = start
|
||||
self['end'] = end
|
||||
|
@ -1639,6 +1669,7 @@ class baseCert(CransLdapObject):
|
|||
|
||||
@crans_object
|
||||
class service(CransLdapObject):
|
||||
__slots__ = ()
|
||||
ldap_name = "service"
|
||||
|
||||
|
||||
|
|
|
@ -398,6 +398,7 @@ def services_to_restart(conn, old_attrs={}, new_attrs={}, created_object=[], del
|
|||
# Identique à la classe dans ldap_crans.py
|
||||
class Service:
|
||||
""" Définit un service à redémarrer """
|
||||
__slots__ = ("nom", "args", "start")
|
||||
def __init__(self, nom, args=[], start=[]):
|
||||
"""
|
||||
Nom du service
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue