From 5c0f98dd500f4f65155686a54416fe61c23798f8 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Wed, 5 Dec 2018 11:46:59 +0100 Subject: [PATCH] Move error reporting on ethernet case to util. Make splitting work on any separator not in the expected set of ethernet address characters --- src/hostinfo/dhcpd.py | 2 -- src/hostinfo/dhcpd_ipv6.py | 2 -- src/hostinfo/util.py | 5 ++++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hostinfo/dhcpd.py b/src/hostinfo/dhcpd.py index 13f48e6..04385fb 100755 --- a/src/hostinfo/dhcpd.py +++ b/src/hostinfo/dhcpd.py @@ -267,8 +267,6 @@ def emit_hosts(tree, options, networks, pxeboot=False): for ethernet in util.ethernets(ip.ethernet[0:]): if pxeboot == 'only' and not bool(ip._pxeboot_): continue - if ethernet.lower() != ethernet: - raise util.HostinfoException('%s not lower-case' % ethernet) if ip.never[0]: if match(util.address(ip.never[0])): if not ethernet in never: diff --git a/src/hostinfo/dhcpd_ipv6.py b/src/hostinfo/dhcpd_ipv6.py index 98b7f35..ad2a5ff 100755 --- a/src/hostinfo/dhcpd_ipv6.py +++ b/src/hostinfo/dhcpd_ipv6.py @@ -174,8 +174,6 @@ def emit_hosts(tree, options, networks): for ip in tree._host_._interface_._ipv6_: # Find all hosts that associated with this network for ethernet in util.ethernets(ip.ethernet[0:]): - if ethernet.lower() != ethernet: - raise util.HostinfoException('%s not lower-case' % ethernet) if ip.never[0]: if match(util.address(ip.never[0])): if not ethernet in never: diff --git a/src/hostinfo/util.py b/src/hostinfo/util.py index 4272c04..54f6f83 100755 --- a/src/hostinfo/util.py +++ b/src/hostinfo/util.py @@ -2,6 +2,7 @@ import ipaddr import itertools import types import hostinfo.parser +import re def network(s): if s.network[0] and s.netmask[0]: @@ -32,7 +33,9 @@ def subnet(tree, addr): def ethernets(ether): if ether == None: return [] - return ether.split(',') + if ether.lower() != ether: + raise HostinfoException('%s not lower-case' % ether) + return re.split('[^:0-9a-fA-F]+', ether) def aton(addr): result = long(0) -- GitLab