Implement graceful shutdown (#8) and classless static routes helper (#31) - #47
Merged
Merged
Conversation
Issue #31 (classless static routes): - add encode_classless_static_routes(): turns (destination_cidr, gateway) pairs into the RFC 3442 / MS option 249 colon-hex byte string dhcpd wants - add_host_supersede() gains an optional `statements` argument for extra raw ISC DHCP statements (verified end to end: the route lands in the lease as `supersede ms-classless-static-routes = 08:0a:c0:00:02:01;`) Issue #8 (graceful shutdown): - add Omapi.signal_shutdown(): opens the OMAPI control object and sets state=2 (like omshell `new control; open; set state = 2; update`). dhcpd shuts down without answering, so a dropped connection or read timeout counts as success (use a connection timeout). Verified: dhcpd actually stops in the container. Tests: unit vectors for the encoder, fake-server tests for the statements argument and signal_shutdown (incl. failure/timeout paths), and real-dhcpd integration tests (routes + shutdown, the shutdown test kept last). 98% coverage. README/CI: - document both features - add codecov, license and static "python 3.11+" badges (the dynamic PyPI pyversions badge self-updates once 1.0 is published) - CI uploads coverage.xml to Codecov (non-blocking) and the integration dhcpd.conf now defines the ms-classless-static-routes option Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the two open issues plus README badges/coverage.
Closes #8
Closes #31
Issue #31 — classless static routes
encode_classless_static_routes([(destination_cidr, gateway), ...])produces the RFC 3442 / Microsoft option 249 colon-hex byte string dhcpd
expects (width byte + significant destination octets + gateway).
add_host_supersede(..., statements=...)gains an optional argument to appendarbitrary raw ISC DHCP statements.
option ms-classless-static-routes code 249 = array of integer 8;defined,the host lands in the lease as
supersede ms-classless-static-routes = 08:0a:c0:00:02:01;.Issue #8 — graceful shutdown
Omapi.signal_shutdown()opens the OMAPIcontrolobject and setsstate = 2(like omshellnew control; open; set state = 2; update).timeout is treated as success — use a connection
timeout.afterwards fails).
Tests (98% coverage)
statementsargument andsignal_shutdown(success, invalid handle, rejected state update, connection-drop-as-success)
the server); the CI integration dhcpd.conf now defines option 249
README / CI
PyPI pyversions badge self-updates once 1.0 is on PyPI)
coverage.xmlto Codecov (non-blocking,fail_ci_if_error: false)🤖 Generated with Claude Code