Example: Device Management / System
10 min
End-to-end walkthrough: export a configuration template from a "golden" Edge and apply it on another, plus manage users, tokens, and certificates.
Setup
from litmussdk.system import templates, users, tokens, certificates1. Export a Configuration Template
The full template captures everything: devices, tags, flows, marketplace registries, NTP, DNS, OPC, etc.
# What can be exported?
items = templates.list_available_configurable_items()
# Export everything
full = templates.download_template_complete()2.6.0 fix: in versions <2.6.0, download_template_complete() raised TypeError on every call. Fixed in 2.6.0 - now works as documented.
For a partial export:
partial = templates.download_template(
dns=True,
ntp=True,
timezone=True,
devices=["device-id-1", "device-id-2"],
flows=["flow-id-1"],
)2. Save and Apply on Another Edge
import json
with open("plant-floor-config.json", "w") as f:
json.dump(full, f, indent=2)
# On another Edge with its own connection:
with open("plant-floor-config.json") as f:
templates.apply_template(json.load(f))For air-gap deployments, see Air gap Features for a programmatic builder.
3. Users and Groups
all_users = users.list_users()
new_user = users.create_user(
username="ops-jane",
email="[email protected]",
full_name="Jane Smith",
password="...",
group_id=group_id,
)
users.delete_user(new_user.id)4. API Tokens (OAuth Clients)
all_tokens = tokens.list_tokens()
new_token = tokens.create_oauth_token(
name="ci-pipeline",
scope="admin",
)
client_id = new_token["client_id"]
client_secret = new_token["client_secret"] # store securely; not retrievable later
tokens.delete_token(new_token["id"])5. Certificates
all_certs = certificates.list_certificates()
certificates.upload_certificate(
cert_path="/path/to/cert.pem",
key_path="/path/to/key.pem",
name="my-https-cert",
)
certificates.delete_certificate(cert_id)6. Network and System Info
from litmussdk.system import network, general
# Network interfaces
interfaces = network.list_interfaces()
# System version and uptime
info = general.get_system_info()
version = general.get_version()7. Events and Audit Log
from litmussdk.system import events
recent = events.list_events(limit=100)
for evt in recent:
print(f"{evt['timestamp']} {evt['type']} {evt['message']}")See Also
- Air gap Features - programmatic template builder for offline deployment
- Managing Connections - if you're sourcing the template from one Edge and applying on another