pvl.dhcp.config: loosen up TOKEN even further to permit unquoted IP addresses and ethernet addresses
--- a/pvl/dhcp/config.py Mon Mar 02 00:15:17 2015 +0200
+++ b/pvl/dhcp/config.py Mon Mar 02 00:19:39 2015 +0200
@@ -3,8 +3,7 @@
import string
# simplified model of lexer chars
-TOKEN_START = string.ascii_letters
-TOKEN = TOKEN_START + string.digits + '-_.'
+TOKEN = string.ascii_letters + string.digits + '-_.:'
class DHCPConfigError(Exception):
def __init__ (self, parser, error, line=None):
@@ -76,9 +75,7 @@
if isinstance(value, int):
return str(value)
- elif not value:
- return ''
- elif value[0] in TOKEN_START and all(c in TOKEN for c in value):
+ elif all(c in TOKEN for c in value):
return str(value)
else:
# quoted
--- a/pvl/dhcp/tests.py Mon Mar 02 00:15:17 2015 +0200
+++ b/pvl/dhcp/tests.py Mon Mar 02 00:19:39 2015 +0200
@@ -85,10 +85,20 @@
filename "/debian/wheezy/pxelinux.0";
include "hosts/test.conf";
+
+ host test {
+ fixed-address 192.0.2.1;
+ hardware ethernet 00:11:22:33:44:55;
+ }
}
""")), (('group', ), [
('next-server', 'boot.test'),
('filename', "/debian/wheezy/pxelinux.0"),
('include', "hosts/test.conf"),
- ], []))
+ ], [
+ (('host', 'test'), [
+ ('fixed-address', '192.0.2.1'),
+ ('hardware', 'ethernet', '00:11:22:33:44:55'),
+ ], [])
+ ]))