Skip to content

Implement graceful shutdown (#8) and classless static routes helper (#31) - #47

Merged
cygnusb merged 1 commit into
masterfrom
issues-and-badges
Jul 25, 2026
Merged

cygnusb merged 1 commit into
masterfrom
issues-and-badges

Conversation

@cygnusb

@cygnusb cygnusb commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Addresses the two open issues plus README badges/coverage.

Closes #8
Closes #31

Issue #31 — classless static routes

  • New 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 append
    arbitrary raw ISC DHCP statements.
  • Verified end to end against real dhcpd: with
    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

  • New Omapi.signal_shutdown() opens the OMAPI control object and sets
    state = 2 (like omshell new control; open; set state = 2; update).
  • ISC dhcpd shuts down without answering, so a dropped connection or read
    timeout is treated as success — use a connection timeout.
  • Verified against real dhcpd: the server actually stops (a fresh connection
    afterwards fails).

Tests (98% coverage)

  • Unit vectors for the encoder (+ error cases)
  • Fake-server tests for the statements argument and signal_shutdown
    (success, invalid handle, rejected state update, connection-drop-as-success)
  • Real-dhcpd integration tests for both (shutdown test kept last as it stops
    the server); the CI integration dhcpd.conf now defines option 249

README / CI

  • Documented both features
  • Added codecov, license and a static python 3.11+ badge (the dynamic
    PyPI pyversions badge self-updates once 1.0 is on PyPI)
  • CI test job uploads coverage.xml to Codecov (non-blocking, fail_ci_if_error: false)

🤖 Generated with Claude Code

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>
@cygnusb
cygnusb merged commit ff66459 into master Jul 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vendor specific routes Support graceful shutdown of dhcpd

1 participant