[attributs] sshFingerping : représentation ldap comme in dict {type, clef, commentaire}
This commit is contained in:
parent
7b7511e493
commit
45947b1871
1 changed files with 31 additions and 0 deletions
31
attributs.py
31
attributs.py
|
@ -1254,6 +1254,37 @@ class sshFingerprint(Attr):
|
|||
legend = "Clef ssh de la machine"
|
||||
can_modify = [parent, nounou]
|
||||
ldap_name = "sshFingerprint"
|
||||
python_type = dict
|
||||
|
||||
def parse_value(self, key):
|
||||
if isinstance(key, self.python_type):
|
||||
if set(key.keys()).issuperset(['type', 'key']):
|
||||
details = [ key['type'], key['key'] ]
|
||||
if 'comm' in key:
|
||||
details.append(key['comm'])
|
||||
else:
|
||||
raise ValueError("sshFingerprint should have a type dans a key field")
|
||||
else:
|
||||
details = key.split()
|
||||
if len(details)<2:
|
||||
raise ValueError("Une clef ssh devrait être de la forme : 'format clef commentaire' comme 'ssh-dss AAAAB3NzaC… root@mon-pc' par exemple")
|
||||
self.value = { 'type' : details[0],
|
||||
'key' : details[1],
|
||||
'comm' : ' '.join(details[2:]),
|
||||
}
|
||||
def __getitem__(self, attr):
|
||||
return self.value.__getitem__(attr)
|
||||
|
||||
def __setitem__(self, attr, values):
|
||||
if attr in ['comm']:
|
||||
ret=self.value.__setitem__(attr, values)
|
||||
self.parse_value(unicode(self))
|
||||
return ret
|
||||
else:
|
||||
raise ValueError("sshFingerprint has no %r editable" % attr)
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%(type)s %(key)s %(comm)s' % self.value
|
||||
|
||||
@crans_attribute
|
||||
class gpgFingerprint(Attr):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue