[binding] Corrections de bugs dans l'implémentation de l'ipv6

This commit is contained in:
Pierre-Elliott Bécue 2013-02-25 01:55:46 +01:00
parent d8e716f22b
commit 92195b6aa8
3 changed files with 12 additions and 5 deletions

View file

@ -609,6 +609,13 @@ rid_machines_speciales = {
4097: '91.121.84.138', 4097: '91.121.84.138',
} }
ipv6_machines_speciales = {
# freebox
4096: 'fe80::210:5aff:feaf:a979',
# ovh
4097: 'fe80::219:d1ff:fea2:b611',
}
# Les préfixes ipv6 # Les préfixes ipv6
prefix = { 'subnet' : [ '2a01:240:fe3d::/48' ], prefix = { 'subnet' : [ '2a01:240:fe3d::/48' ],
'serveurs' : [ '2a01:240:fe3d:4::/64'], 'serveurs' : [ '2a01:240:fe3d:4::/64'],

View file

@ -2863,7 +2863,7 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
net = self.netv6() net = self.netv6()
try: try:
self._set('macAddress', [mac]) self._set('macAddress', [mac])
if self.netv6() != 'special': if net.size > 1:
self.ipv6(ip6tools.mac_to_ipv6(net, netaddr.EUI(mac))) self.ipv6(ip6tools.mac_to_ipv6(net, netaddr.EUI(mac)))
else: else:
self.ipv6(config.ipv6_machines_speciales[int(self.rid())]) self.ipv6(config.ipv6_machines_speciales[int(self.rid())])
@ -3357,18 +3357,18 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
if nettype != 'special': if nettype != 'special':
return netaddr.IPNetwork(config.prefix[nettype][0]) return netaddr.IPNetwork(config.prefix[nettype][0])
else: else:
return 'special' return netaddr.IPNetwork(config.ipv6_machines_speciales[int(self.rid())])
def ipv6(self, ipv6=None): def ipv6(self, ipv6=None):
"""Retourne l'adresse IPv6 correspondant à la machine""" """Retourne l'adresse IPv6 correspondant à la machine"""
if ipv6 == None: if ipv6 == None:
return unicode(self._data.get('ip6HostNumber', [''])[0]) return netaddr.IPAddress(self._data.get('ip6HostNumber', [''])[0])
ipv6 = str(ipv6) ipv6 = str(ipv6)
net = self.netv6() net = self.netv6()
if net == 'special': if net.size == 1:
ipv6_t = config.ipv6_machines_speciales[int(self.rid())] ipv6_t = config.ipv6_machines_speciales[int(self.rid())]
else: else:
ipv6_t = str(ip6tools.mac_to_ipv6(net, netaddr.EUI(self.mac()))) ipv6_t = str(ip6tools.mac_to_ipv6(net, netaddr.EUI(self.mac())))

View file

@ -342,7 +342,7 @@ def list_machines(machines) :
return tableau(data, return tableau(data,
titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse IPv6', u'Adresse MAC', u'Limitation'], titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse IPv6', u'Adresse MAC', u'Limitation'],
largeur = [5, 5, 4, '*', 24, 17, 19, 10], largeur = [5, 5, 4, '*', 15, 22, 17, 10],
alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c', 'c']) alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c', 'c'])
def list_bornes(bornes) : def list_bornes(bornes) :