maintnote is a Python 3.10+ library and command-line tool (CLI) for network maintenance notifications.
It implements IETF draft-gunter-calext-maintenance-notifications-00 (Maintenance Notification Improvements Using iCalendar).
Network operators usually send maintenance notifications as free-form emails that make automation unreliable.
This specification puts structured X-MAINTNOTE-* fields inside standard RFC 5545 iCalendar (.ics) events.
With maintnote, software developers, network engineers, and DevOps engineers can generate, validate, and automate maintenance windows.
maintnote uses only the Python standard library at runtime and includes full mypy --strict type annotations (py.typed).
Two roles use maintnote:
- Provider: A carrier, internet exchange, or cloud operator that creates and updates maintenance notifications for customer accounts.
- Consumer: A customer network operations center (NOC), DevOps pipeline, or ticketing service that parses notifications, tracks state, and runs automation.
Each notification identifies one maintenance event with a unique UID and a SEQUENCE number that increases on each update.
It also lists one or more affected service objects, an impact level, and an optional lifecycle status.
- RFC 5545 and
X-MAINTNOTE-*parsing and validation- Parse and validate all mandatory and optional properties:
X-MAINTNOTE-PROVIDER,X-MAINTNOTE-ACCOUNT,X-MAINTNOTE-MAINTENANCE-ID,X-MAINTNOTE-OBJECT-ID(with optionalALTREPURIs),X-MAINTNOTE-IMPACT, andX-MAINTNOTE-STATUS. - Keep unknown
x-nameoriana-tokenimpact values as sent, and mapeffective_impacttoImpact.OUTAGE(Section 2.5.5). - Omit the
METHODproperty by default so email clients do not automatically add notifications to personal calendars (Section 2.3.1). - Support per-recipient
METHODopt-in for providers andMETHODremoval for consumers. - Support
LANGUAGEproperty parameters and 75-octet line folding that is safe for UTF-8 (Section 5.1). - Accept common third-party quirks in lenient mode (
strict=False) and return structured warnings.
- Parse and validate all mandatory and optional properties:
- Provider and consumer workflow engine (Section 3)
- Run all five lifecycle stages: Initial (3.1), Updated (3.2), Cancelled (3.3), Open or
IN-PROCESS(3.4), and Closed orCOMPLETED(3.5). - Keep
UIDvalues stable across updates, increaseSEQUENCEnumbers, and ignore duplicate or stale notifications. - Isolate object IDs by
(provider, object_id)so identical circuit IDs from different carriers do not collide. - Connect custom storage (
StateStore), ticketing (TicketHandler), and out-of-band checks (OutOfBandVerifier). - Use the built-in
InMemoryStateStore,SQLiteStateStore, andInMemoryTicketHandlerclasses directly.
- Run all five lifecycle stages: Initial (3.1), Updated (3.2), Cancelled (3.3), Open or
- Email, OpenPGP,
ALTREP, and CalDAV transport (Section 5.2)- Build and parse RFC 5322 emails with
text/calendar(.ics) attachments. - Sign and verify RFC 3156
multipart/signedOpenPGP emails over raw MIME bytes. - Get external JSON metadata (for example, PeeringDB data) from
ALTREPURIs over HTTPS with redirect and private-IP protection. - Discover, query, get, publish, and delete events on a CalDAV server over TLS (RFC 4791).
- Build and parse RFC 5322 emails with
- Built-in CLI (
maintnote)- Validate, parse, generate, transition, remove
METHOD, and extract notifications from.icsand.emlfiles. - Support
--jsonoutput andstdin(-) for shell scripts and DevOps pipelines.
- Validate, parse, generate, transition, remove
Install maintnote from PyPI:
pip install maintnoteFrom a cloned repository, install the package with test, lint, and type-check tools (pytest, pytest-cov, ruff, and mypy):
pip install -e ".[dev]"From a cloned repository, install the documentation tools (mkdocs and mkdocs-material):
pip install -e ".[docs]"Use MaintenanceProvider to create an initial notification and move it through each lifecycle state:
from datetime import datetime, timezone
from maintnote import (
Impact,
MaintenanceProvider,
Organizer,
ServiceObject,
dumps,
)
provider = MaintenanceProvider(
provider="example.com",
organizer=Organizer("noc@example.com", cn="Example NOC"),
)
# Section 3.1: Initial notification (SEQUENCE=0, STATUS=TENTATIVE, no METHOD)
initial = provider.create_initial(
account="137.035999173",
maintenance_id="WorkOrder-31415",
objects=[
ServiceObject(
object_id="2718281828459",
altrep="https://example.org/maintenance?id=2718281828459",
),
ServiceObject(object_id="2001:db8::d06:f00d"),
],
dtstart=datetime(2026, 10, 10, 8, 0, tzinfo=timezone.utc),
dtend=datetime(2026, 10, 10, 10, 0, tzinfo=timezone.utc),
summary="Core optical linecard upgrade",
impact=Impact.OUTAGE,
)
# Section 3.2: Confirm and reschedule (same UID, SEQUENCE=1)
confirmed = provider.confirm(
initial,
dtstart=datetime(2026, 10, 12, 8, 0, tzinfo=timezone.utc),
dtend=datetime(2026, 10, 12, 10, 0, tzinfo=timezone.utc),
)
# Section 3.4: Open the maintenance window (SEQUENCE=2, STATUS=IN-PROCESS)
opened = provider.open_window(confirmed, description="Maintenance window is now open.")
# Section 3.5: Close the maintenance window (SEQUENCE=3, STATUS=COMPLETED)
closed = provider.close_window(opened, description="Work complete; services restored.")
# Section 3.3: Cancel an active maintenance window instead
cancelled = provider.cancel(confirmed, description="Maintenance no longer required.")
print(dumps(initial))Use MaintenanceConsumer with SQLiteStateStore to track (provider, uid) state, check SEQUENCE order, and call a ticket handler:
from maintnote import (
InMemoryTicketHandler,
MaintenanceConsumer,
SQLiteStateStore,
dumps,
)
store = SQLiteStateStore("maintenances.db")
handler = InMemoryTicketHandler(prefix="OPS")
consumer = MaintenanceConsumer(store=store, handler=handler)
result = consumer.process(dumps(initial))
print(result.action, result.ticket_id, result.priority, result.assign_to_remediation_queue)
# WorkflowAction.INITIAL OPS-0001 TicketPriority.CRITICAL False
store.close()Call build_notification_email() to attach an .ics notification to an email.
Call extract_notifications_from_email() to parse received emails:
from maintnote import build_notification_email, extract_notifications_from_email
msg = build_notification_email(
initial,
sender="noc@example.com",
recipient="ops@customer.example",
)
notifications = extract_notifications_from_email(msg, strip_method=True)Run maintnote directly on .ics and .eml files, or pass - to read from stdin:
# Validate a maintenance notification and print JSON diagnostics
maintnote validate examples/samples/01_initial.ics --json
# Parse a notification and show its fields
maintnote parse examples/samples/01_initial.ics
# Generate an initial notification and transition it to open and closed
maintnote generate --action initial \
--provider example.com --account 137.035999173 \
--maintenance-id WorkOrder-31415 --object-id acme-widgets-as-a-service \
--impact OUTAGE --summary "Router upgrade" \
--organizer noc@example.com --organizer-cn "Example NOC" \
--dtstart 2026-10-10T08:00:00Z --dtend 2026-10-10T10:00:00Z \
-o initial.ics
maintnote generate --action open --from-file initial.ics -o open.ics
maintnote generate --action close --from-file open.ics -o close.ics
# Remove METHOD before you forward a notification to personal calendars (Section 2.3.1)
maintnote strip-method examples/samples/legacy_with_method.ics
# Extract notifications from an email file
maintnote extract-email examples/samples/legacy_provider.eml --strip-method --jsonPython example scripts, sample .ics and .eml files, and a CLI walkthrough are in examples/:
| Example | Purpose |
|---|---|
examples/provider_lifecycle.py |
Run the provider lifecycle from initial notification through completion |
examples/consumer_pipeline.py |
Extract emails, track state in SQLite, and reject stale notifications |
examples/multi_customer_batch.py |
Send one maintenance notification to more than one account with per-account METHOD settings and cancel the batch |
examples/multi_provider_automation.py |
Isolate (provider, object_id) pairs, use a custom TicketHandler, test OUTAGE fallback, and run OutOfBandVerifier |
examples/signed_email_and_sanitization.py |
Sign and verify RFC 3156 OpenPGP emails, detect tampering, and remove METHOD from emails |
examples/caldav_and_altrep_demo.py |
Run an offline mock CalDAV server (PROPFIND, PUT with ETag, REPORT, GET, DELETE) and test ALTREP SSRF checks |
examples/localization_and_lenient_parsing.py |
Use LocalizationStrings, LANGUAGE parameters, VTIMEZONE, VALARM, and lenient diagnostics |
examples/cli_walkthrough.sh |
Run every maintnote CLI subcommand against the files in examples/samples/ |
Read the full guides in docs/:
- Overview
- Getting Started
- Specification Compliance Matrix
- Provider and Consumer Workflows
- Security and Transport
- API Reference
Run the local checks before you open a Pull Request:
# Run unit and integration tests
PYTHONPATH=src pytest -v
# Check lint rules and formatting
ruff check src tests
ruff format --check src tests
# Run strict static type checks
MYPYPATH=src mypy src testsTo run lint, type checks, and tests with one command, run:
make checkTo build the documentation in strict mode, run:
make docsRead CONTRIBUTING.md for the full Pull Request and coding rules.
This project uses the GNU General Public License v3.0 or later (GPL-3.0-or-later).
Read LICENSE for the full license text.