Comment 0 for bug 1655049

Distro: Ubuntu 16.04
MAAS version:

For some node MAC addresses (I have a relatively old servers) I am unable to open MAAS dashboard page or Nodes page due to

"list index out of range"

error.

2017-01-09T15:39:21+0100 [maasserver.websockets.websockets#debug] Opening connection with IPv6Address(TCP, '::1', 53172)
2017-01-09T15:39:21+0100 [maasserver.websockets.protocol#critical] Error on request (18) machine.list: list index out of range

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 824, in worker
    return target()
  File "/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
    task()
  File "/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
    task()
--- <exception caught here> ---
  File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 246, in inContext
    result = inContext.theWork()
  File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 262, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 857, in callInContext
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 225, in wrapper
    result = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 603, in call_within_transaction
    return func_outside_txn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 422, in retrier
    return func(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/machine.py", line 182, in list
    return super(MachineHandler, self).list(params)
  File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 358, in list
    for obj in objs
  File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 358, in <listcomp>
    for obj in objs
  File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 205, in full_dehydrate
    return self.dehydrate(obj, data, for_list=for_list)
  File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/machine.py", line 187, in dehydrate
    obj, data, for_list=for_list)
  File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/node.py", line 118, in dehydrate
    data["pxe_mac_vendor"] = obj.get_pxe_mac_vendor()
  File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 3021, in get_pxe_mac_vendor
    return get_vendor_for_mac(boot_interface.mac_address.get_raw())
  File "/usr/lib/python3/dist-packages/maasserver/utils/mac.py", line 20, in get_vendor_for_mac
    return data.oui.registration().org
  File "/usr/lib/python3/dist-packages/netaddr/eui/__init__.py", line 478, in oui
    return OUI(self.value >> 24)
  File "/usr/lib/python3/dist-packages/netaddr/eui/__init__.py", line 98, in __init__
    self._parse_data(data, offset, size)
  File "/usr/lib/python3/dist-packages/netaddr/eui/__init__.py", line 145, in _parse_data
    record['org'] = line.split(None, 2)[2]
builtins.IndexError: list index out of range

For now I have worked around the issue by catching IndexError in "/usr/lib/python3/dist-packages/maasserver/utils/mac.py". After this workaround the Nodes page started working but Dashboard page required similar fix in "/usr/lib/python3/dist-packages/provisioningserver/utils/network.py" in line 923

But this probably needs some investigation and fix - without the workaround I cannot use MAAS.