From f97be2ce42c6f8cd314ce1ce46b28d4a401f7406 Mon Sep 17 00:00:00 2001 From: Olivier Huber Date: Sun, 31 Jan 2010 23:36:18 +0100 Subject: [PATCH] [./gestion/midtools.py] Bugfixes darcs-hash:20100131223618-8fbb1-81cf2ad482e79ee27cd3584d042fb9b16989b4a7.gz --- gestion/midtools.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gestion/midtools.py b/gestion/midtools.py index bdca2ba8..4c66cb89 100755 --- a/gestion/midtools.py +++ b/gestion/midtools.py @@ -72,8 +72,9 @@ class Mid(object): if self.type is None: raise ValueError("Impossible de convertir l'adresse IP") - self.mid = iptools.QuadToDec(ip) - self.mid -= iptools.param(config.NETs[self.type], True)['network'] + self.mid = int(iptools.QuadToDec(ip)) + self.mid -= int(iptools.param(config.NETs[self.type][0], + True)['network']) self.reste = self.mid & 0x7ff # if self.type == 'ens': # Inutile pour l'instant # self.reste &= 0xff @@ -85,21 +86,18 @@ class Mid(object): if not self.ipv4_dispo: raise ValueError("Pas d'adresse ipv4 disponible pour la machine") - ip = iptools.param(config.NETs[self.type], True)['network'] + ip = iptools.param(config.NETs[self.type][0], True)['network'] ip += self.reste return iptools.DecToQuad(ip) def to_ipv6_vlan(self): """ - Génère le VLAN IPv6 associé à la machine + Génère le préfix IPv6 associé à la machine """ - if priv: - raise ValueError("Pas d'adresse ipv6 disponible pour la machine") + if self.priv: + raise ValueError("Pas de prefix ipv6 disponible pour cette machine") - tp = {'fil': 'fil', 'fil-v6': 'fil', - 'wifi': 'wifi', 'wifi-v6': 'wifi', - 'adm': 'adm'}[self.type] - ip = config.prefix[tp][0].split(":/")[0] + ip = config.prefix['subnet'][0].split(":/")[0] ip += hex(self.mid)[2:] ip += "::/64"