bit more logging

This commit is contained in:
brent s. 2020-05-18 05:24:43 -04:00
parent 80765e58ed
commit 1655dd1e89
Signed by: bts
GPG Key ID: 8C004C2F93481F6B

View File

@ -1,4 +1,5 @@
import ipaddress import ipaddress
import logging
import socket import socket
## ##
import netaddr import netaddr
@ -8,6 +9,10 @@ from . import ra
from . import utils from . import utils




# TODO: more logging
logger = logging.getLogger()


class IP(object): class IP(object):
type = None type = None
version = None version = None
@ -88,12 +93,15 @@ class Assignment(object):
_iface_txt = self.xml.attrib['iface'].strip() _iface_txt = self.xml.attrib['iface'].strip()
self.iface = _iface_txt.strip() self.iface = _iface_txt.strip()
ipr = IPRoute() ipr = IPRoute()
logger.debug('Looking for iface {0}'.format(self.iface))
self.iface_idx = ipr.link_lookup(ifname = self.iface)[0] self.iface_idx = ipr.link_lookup(ifname = self.iface)[0]
logger.debug('Found iface {0} at idx {1}'.format(self.iface, self.iface_idx))
# Link-Local address # Link-Local address
ll = ipr.get_addr(index = self.iface_idx, ll = ipr.get_addr(index = self.iface_idx,
family = socket.AF_INET6, family = socket.AF_INET6,
scope = 253)[0]['attrs'] scope = 253)[0]['attrs']
addrs = dict(ll)['IFA_ADDRESS'] addrs = dict(ll)['IFA_ADDRESS']
logger.debug('Link-Local address for {0}: {1}'.format(addrs))
if isinstance(addrs, (list, tuple)): if isinstance(addrs, (list, tuple)):
addr = addrs[0] addr = addrs[0]
else: else: