diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 51476c77..733c339e 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -2636,9 +2636,19 @@ class Machine(base_classes_crans): if ports == None: return self._data.get(champ, []) - ports = map(int, ports) + # Les ports doivent être de la forme [port][:[port]]. On met + # la spécification sous une forme qui donne un tri intéressant + def parse(x): + try: + liste = x.split(':') + assert(len(liste) == 1 or len(liste) == 2) + return map(lambda x: x and int(x) or '', liste) + except: + raise ValueError(u'Spécification de ports incorrecte : %s' % x) + + ports = map(parse, ports) ports.sort() - self._set(champ, map(str, ports)) + self._set(champ, map(lambda x: ':'.join(map(str, x)), ports)) class MachineFixe(Machine):