[lc_ldap,attributs] On ajoute sshFingerprint et gpgFingerprint, on rend possible l'ajout d'attribut obtionnel optionnel quand le cardinal précédent de l'attribut est 0
This commit is contained in:
parent
a629e4c82f
commit
1403cfdb7b
3 changed files with 22 additions and 3 deletions
18
attributs.py
18
attributs.py
|
@ -94,7 +94,9 @@ class Attr(object):
|
||||||
def validate(self, ldif):
|
def validate(self, ldif):
|
||||||
"""validates:
|
"""validates:
|
||||||
vérifie déjà que ce qu'on a rentré est parsable"""
|
vérifie déjà que ce qu'on a rentré est parsable"""
|
||||||
own_values = ldif[self.__class__.__name__]
|
if not self.__class__.__name__ in CRANS_ATTRIBUTES:
|
||||||
|
raise ValueError('Attribut %s inconnu' % self.__class__.__name__)
|
||||||
|
own_values = ldif.get(self.__class__.__name__, [])
|
||||||
self._check_cardinality(own_values)
|
self._check_cardinality(own_values)
|
||||||
self._check_uniqueness()
|
self._check_uniqueness()
|
||||||
self._check_users_restrictions(own_values)
|
self._check_users_restrictions(own_values)
|
||||||
|
@ -594,6 +596,18 @@ class mail(Attr):
|
||||||
# XXX - to be implemented
|
# XXX - to be implemented
|
||||||
#def parse_value(self, mail, ldif):
|
#def parse_value(self, mail, ldif):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
|
class sshFingerprint(Attr):
|
||||||
|
singlevalue = False
|
||||||
|
optional = True
|
||||||
|
legend = "Clef ssh de la machine"
|
||||||
|
can_modify = ["parent", "Nounou"]
|
||||||
|
|
||||||
|
class gpgFingerprint(Attr):
|
||||||
|
singlevalue = False
|
||||||
|
optional = True
|
||||||
|
legend = "Clef gpg d'un adhérent"
|
||||||
|
can_modify = ["self", "Nounou"]
|
||||||
|
|
||||||
class cn(Attr):
|
class cn(Attr):
|
||||||
singlevalue = True
|
singlevalue = True
|
||||||
|
@ -639,8 +653,10 @@ CRANS_ATTRIBUTES= {
|
||||||
'chbre' : chbre,
|
'chbre' : chbre,
|
||||||
'droits' : droits,
|
'droits' : droits,
|
||||||
'solde' : solde,
|
'solde' : solde,
|
||||||
|
'gpgFingerprint' : gpgFingerprint,
|
||||||
'mid' : mid,
|
'mid' : mid,
|
||||||
'host' : host,
|
'host' : host,
|
||||||
|
'sshFingerprint' : sshFingerprint,
|
||||||
'macAddress': macAddress,
|
'macAddress': macAddress,
|
||||||
'ipHostNumber': ipHostNumber,
|
'ipHostNumber': ipHostNumber,
|
||||||
'hostAlias' : hostAlias,
|
'hostAlias' : hostAlias,
|
||||||
|
|
|
@ -232,6 +232,8 @@ def human_to_ldap(filtre):
|
||||||
# Comme parenthèse fermante.
|
# Comme parenthèse fermante.
|
||||||
if neg:
|
if neg:
|
||||||
argument = "!(%s)" % argument
|
argument = "!(%s)" % argument
|
||||||
|
|
||||||
|
# Surtout ça
|
||||||
if operateur == "&|":
|
if operateur == "&|":
|
||||||
argument += ')'
|
argument += ')'
|
||||||
ext_stack += "(%s)" % argument
|
ext_stack += "(%s)" % argument
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
# Valentin Samir <samir@crans.org>
|
# Valentin Samir <samir@crans.org>
|
||||||
# Daniel Stan <dstan@crans.org>
|
# Daniel Stan <dstan@crans.org>
|
||||||
# Vincent Le Gallic <legallic@crans.org>
|
# Vincent Le Gallic <legallic@crans.org>
|
||||||
|
# Pierre-Elliott Bécue <becue@crans.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -614,7 +615,7 @@ class machine(CransLdapObject):
|
||||||
ufields = ['mid', 'macAddress', 'host', 'midType']
|
ufields = ['mid', 'macAddress', 'host', 'midType']
|
||||||
ofields = []
|
ofields = []
|
||||||
mfields = ['info', 'blacklist', 'hostAlias', 'exempt',
|
mfields = ['info', 'blacklist', 'hostAlias', 'exempt',
|
||||||
'portTCPout', 'portTCPin', 'portUDPout', 'portUDPin']
|
'portTCPout', 'portTCPin', 'portUDPout', 'portUDPin','sshFingerprint']
|
||||||
xfields = ['ipHostNumber']
|
xfields = ['ipHostNumber']
|
||||||
|
|
||||||
def __init__(self, conn, dn, mode='ro', ldif = None):
|
def __init__(self, conn, dn, mode='ro', ldif = None):
|
||||||
|
@ -649,7 +650,7 @@ class adherent(proprio):
|
||||||
ofields = proprio.ofields + ['charteMA', 'adherentPayant', 'typeAdhesion',
|
ofields = proprio.ofields + ['charteMA', 'adherentPayant', 'typeAdhesion',
|
||||||
'canonicalAlias', 'solde', 'contourneGreylist',
|
'canonicalAlias', 'solde', 'contourneGreylist',
|
||||||
'rewriteMailHeaders', 'derniereConnexion',
|
'rewriteMailHeaders', 'derniereConnexion',
|
||||||
'homepageAlias']
|
'homepageAlias','gpgFingerprint']
|
||||||
mfields = proprio.mfields + ['carteEtudiant', 'mailAlias', 'droits' ]
|
mfields = proprio.mfields + ['carteEtudiant', 'mailAlias', 'droits' ]
|
||||||
xfields = ['etudes', 'postalAddress']
|
xfields = ['etudes', 'postalAddress']
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue