Beispiel #1
0
 def net_interfaces(self):
     '''Return a list of all available network interfaces.'''
     return [idev['name'] for idev in util.detect_interfaces()]
Beispiel #2
0
from univention.management.console.log import MODULE

from univention.management.console.modules.setup.util import detect_interfaces

ucr = ConfigRegistry()
ucr.load()

_translation = Translation('univention-management-console-module-setup')
_ = _translation.translate

RE_INTERFACE = re.compile(
    r'^interfaces/(?!(?:primary|restart/auto|handler)$)([^/]+?)(_[0-9]+)?/')
RE_IPV6_ID = re.compile(r'^[a-zA-Z0-9]+\Z')
# VALID_NAME_RE = re.compile(r'^(?![.]{1,2}\Z)[^/ \t\n\r\f]{1,15}\Z')

PHYSICAL_INTERFACES = [dev['name'] for dev in detect_interfaces()]


class DeviceError(ValueError):
    def __init__(self, msg, device=None):
        if device is not None:
            msg = '%s: %s' % (device, msg)
        self.device = device
        ValueError.__init__(self, msg)


class IP4Set(set):
    def add(self, ip):
        set.add(self, ipaddr.IPv4Address(ip))

    def __contains__(self, ip):