[lc_ldap] Création de machines : ipsec si machine wifi, ajout d'une ligne d'historique
This commit is contained in:
parent
c727420624
commit
5942ee143c
1 changed files with 7 additions and 2 deletions
|
@ -49,6 +49,7 @@ import datetime
|
||||||
import copy
|
import copy
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Levenshtein import jaro
|
from Levenshtein import jaro
|
||||||
|
@ -231,7 +232,7 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object):
|
||||||
_,adherents = self.allMachinesAdherents()
|
_,adherents = self.allMachinesAdherents()
|
||||||
return adherents
|
return adherents
|
||||||
|
|
||||||
def newMachine(self, parent, realm, uldif):
|
def newMachine(self, parent, realm, uldif, login=None):
|
||||||
"""Crée une nouvelle machine: ``realm`` peut être:
|
"""Crée une nouvelle machine: ``realm`` peut être:
|
||||||
fil, fil-v6, wifi, wifi-v6, adm, gratuit, personnel-ens, special
|
fil, fil-v6, wifi, wifi-v6, adm, gratuit, personnel-ens, special
|
||||||
--Partiellement implémenté"""
|
--Partiellement implémenté"""
|
||||||
|
@ -248,6 +249,7 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object):
|
||||||
|
|
||||||
elif realm in ["wifi", "wifi-v6"]:
|
elif realm in ["wifi", "wifi-v6"]:
|
||||||
uldif['objectClass'] = [u'machineWifi']
|
uldif['objectClass'] = [u'machineWifi']
|
||||||
|
uldif['ipsec'] = [u''.join( random.choice(filter(lambda x: x != 'l' and x != 'o', string.lowercase) + filter(lambda x: x != '1' and x != '0', string.digits)) for i in range(10))]
|
||||||
assert isinstance(owner, adherent) or isinstance(owner, club)
|
assert isinstance(owner, adherent) or isinstance(owner, club)
|
||||||
|
|
||||||
elif realm in ["fil-adherents", "fil-v6", "personnel-ens"]:
|
elif realm in ["fil-adherents", "fil-v6", "personnel-ens"]:
|
||||||
|
@ -272,10 +274,13 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object):
|
||||||
|
|
||||||
# Tout doit disparaître !!
|
# Tout doit disparaître !!
|
||||||
machine = self._create_entity('mid=%s,%s' % (uldif['mid'][0], parent), uldif)
|
machine = self._create_entity('mid=%s,%s' % (uldif['mid'][0], parent), uldif)
|
||||||
|
login = login or current_user
|
||||||
|
machine.history_add(login, u"inscription")
|
||||||
if machine.may_be(created, self.droits + self._check_parent(machine.dn)):
|
if machine.may_be(created, self.droits + self._check_parent(machine.dn)):
|
||||||
machine.create()
|
machine.create()
|
||||||
else:
|
else:
|
||||||
raise EnvironmentError("Vous n'avez pas le droit de créer cette machine.")
|
raise EnvironmentError("Vous n'avez pas le droit de créer cette machine.")
|
||||||
|
return machine
|
||||||
|
|
||||||
def newAdherent(self, uldif):
|
def newAdherent(self, uldif):
|
||||||
"""Crée un nouvel adhérent"""
|
"""Crée un nouvel adhérent"""
|
||||||
|
@ -530,7 +535,7 @@ class CransLdapObject(object):
|
||||||
|
|
||||||
new_line = u"%s, %s : %s" % (time.strftime("%d/%m/%Y %H:%M"), login, chain)
|
new_line = u"%s, %s : %s" % (time.strftime("%d/%m/%Y %H:%M"), login, chain)
|
||||||
# Attention, le __setitem__ est surchargé, mais pas .append sur l'historique
|
# Attention, le __setitem__ est surchargé, mais pas .append sur l'historique
|
||||||
self["historique"] = self["historique"] + [new_line]
|
self["historique"] = self.get("historique", []) + [new_line]
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
"""Crée l'objet dans la base ldap, cette méthode vise à faire en sorte que
|
"""Crée l'objet dans la base ldap, cette méthode vise à faire en sorte que
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue