launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11328
[Merge] lp:~julian-edwards/maas/broken-leases-parser-bug-1042047 into lp:maas
Julian Edwards has proposed merging lp:~julian-edwards/maas/broken-leases-parser-bug-1042047 into lp:maas.
Requested reviews:
MAAS Maintainers (maas-maintainers)
Related bugs:
Bug #1042047 in MAAS: "leases parser doesn't work"
https://bugs.launchpad.net/maas/+bug/1042047
For more details, see:
https://code.launchpad.net/~julian-edwards/maas/broken-leases-parser-bug-1042047/+merge/121364
Fix a couple of problems with the lease parser after real-world testing.
1. It was missing some additional keywords that can appear in the lease blocks, that should be ignored. Ideally there would be a way of ignoring everything except the actual ones we're interested it.
2. The Regex that swallows arguments to the keywords was too strict in the case of 'thing = "quoted thing"' because it didn't swallow the quotes. jtv says that there could be a nested block but that's not going to happen in this file, so I relaxed the swallowing so it stops at the semicolon.
--
https://code.launchpad.net/~julian-edwards/maas/broken-leases-parser-bug-1042047/+merge/121364
Your team MAAS Maintainers is requested to review the proposed merge of lp:~julian-edwards/maas/broken-leases-parser-bug-1042047 into lp:maas.
=== modified file 'src/provisioningserver/dhcp/leases_parser.py'
--- src/provisioningserver/dhcp/leases_parser.py 2012-07-09 14:10:57 +0000
+++ src/provisioningserver/dhcp/leases_parser.py 2012-08-27 05:58:21 +0000
@@ -38,15 +38,15 @@
ip = Regex("[0-9]{1,3}(\.[0-9]{1,3}){3}")
mac = Regex("[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}")
hardware_type = Regex('[A-Za-z0-9_-]+')
-args = Regex('[^"{;]+') | QuotedString('"')
+args = Regex('[^;]+') | QuotedString('"')
expiry = Regex('[0-9]\s+[0-9/-]+\s+[0-9:]+') | 'never'
hardware = CaselessKeyword("hardware") + hardware_type("type") + mac("mac")
ends = CaselessKeyword("ends") + expiry("expiry")
other_statement = (
oneOf(
- ['starts', 'tstp', 'tsfp', 'uid', 'binding'], caseless=True) +
- args
+ ['starts', 'tstp', 'tsfp', 'cltt', 'uid', 'binding', 'set', 'next'],
+ caseless=True) + args
)
lease_statement = (hardware | ends | other_statement) + Suppress(';')
=== modified file 'src/provisioningserver/dhcp/tests/test_leases_parser.py'
--- src/provisioningserver/dhcp/tests/test_leases_parser.py 2012-07-09 12:31:50 +0000
+++ src/provisioningserver/dhcp/tests/test_leases_parser.py 2012-08-27 05:58:21 +0000
@@ -79,8 +79,12 @@
ends never;
tstp 6 2010/01/02 05:00:00;
tsfp 6 2010/01/02 05:00:00;
+ cltt 1 2010/01/02 05:00:00;
binding state free;
+ next binding state free;
hardware ethernet %(mac)s;
+ uid "\001\000\234\002\242\2020";
+ set vendorclass = "PXEClient:Arch:00000:UNDI:002001";
}
""" % params))
self.assertEqual({params['ip']: params['mac']}, leases)
Follow ups