Skip to main content

Requisition

Declare one requisition per document: its nodes, interfaces, services, categories and assets, plus an optional foreign source (scan interval, detectors, policies). Targets /rest/requisitions/{name} and /rest/foreignSources/{name}, and triggers the import with PUT /rest/requisitions/{name}/import. requisition convert brings existing provision.pl XML in, apply ships edits out, and requisition import / status cover the lifecycle.

YAML​

Unknown keys fail the parse at every level.

FieldTypeDefaultDescription
apiVersionstringrequiredprovisioning.opennms.org/v1
kindstringrequiredRequisition
metadata.namestringrequiredForeign-source name. Used in both REST paths. Must not be empty.
metadata.x-onmsctl-unmodeledmapnoneWritten by convert. Stripped before apply. See Unmodeled XML is recorded, not applied.
spec.foreignSourceobjectnoneScan interval, detectors and policies. Omit it to inherit Horizon's default foreign source.
spec.nodeslist of nodesrequiredMay be []. Order does not matter; nodes are matched by foreignId. No two nodes may share a foreignId.

Fields of a node:

FieldTypeDefaultDescription
foreignIdstringrequiredStable identifier in the source of truth, such as a CMDB id or hostname. Must not be empty.
labelstringrequiredDisplay name. Becomes Horizon's node label. Must not be empty.
locationstringDefault locationMonitoring (Minion) location that polls the node. An empty string is the same as omitting it.
interfaceslist of interfaces[]Order does not matter; interfaces are matched by ip. No two interfaces on one node may share an ip.
categorieslist of strings[]A set: order does not matter and duplicates collapse.
assetsmap of string to string{}Free-form asset record, such as building: HQ.

Fields of an interface:

FieldTypeDefaultDescription
ipstringrequiredInterface address. Must not be empty.
snmpPrimarystringnoneP (primary SNMP interface for data collection), S (secondary) or N (not eligible for SNMP). Any other value fails the parse.
serviceslist of strings[]Service names known to provisiond, such as ICMP, SNMP, HTTP. A set: order does not matter and duplicates collapse.

Fields of spec.foreignSource:

FieldTypeDefaultDescription
scanIntervalstringnoneHumanized interval such as 1d or 30m.
detectorslist of detectors[]Ordered. provisiond runs them top-down, so reordering is a change.
policieslist of policies[]Ordered. Evaluated in list order, so reordering is a change.

An empty foreignSource: {} is valid. It still pins a custom foreign source for the requisition.

Fields of a detector or policy:

FieldTypeDefaultDescription
namestringrequiredEntry name. Must not be empty.
classstringrequired on policiesJava class. Optional on detectors so convert can keep a name-only entry from sparse XML. Must not be empty on a policy.
parameterslist[]{key, value} string pairs. Order does not matter. Both fields are required.

Pinned vs portable foreignSource​

Include spec.foreignSource (detectors and policies) and the YAML owns both the requisition and its foreign source. Omit it and the requisition inherits Horizon's default foreign source. The example below shows the pinned style with every modeled field.

warning

Omitting spec.foreignSource deletes an existing custom foreign source of the same name. apply sends DELETE /rest/foreignSources/{name} and the requisition falls back to Horizon's default. The custom detectors and policies are gone from the server. Run onmsctl requisition export <name> first to keep a copy.

Unmodeled XML is recorded, not applied​

convert keeps XML that the YAML model doesn't represent under metadata.x-onmsctl-unmodeled, for review in the local YAML only. apply strips the annotation before the diff and the wire body, so its values are never sent to Horizon.

Server fields onmsctl does not model​

export omits requisition fields the YAML model does not represent. On an update, apply keeps the server's values for them, so editing an exported requisition never drops them:

LevelKept from the serverMatched by
Nodemeta-data, parent-foreign-source, parent-foreign-id, parent-node-label, building, cityforeignId
Interfacemeta-data, category, descr, status, managedip within its node
Servicemeta-data, categoryservice name within its interface

A node, interface or service new in the document starts without them. One the document removes is removed with them. onmsctl cannot set or remove these fields; change them in Horizon.

Apply​

onmsctl apply -f examples/requisition-acme-prod.yaml --dry-run # preview the action per document
onmsctl apply -f examples/requisition-acme-prod.yaml # write + auto-import

Expected output:

$ onmsctl apply -f examples/requisition-acme-prod.yaml --dry-run
+-------------+-----------+--------+---------+-----------------------+
| kind | name | action | status | message |
+====================================================================+
| Requisition | acme-prod | create | Skipped | dry-run: would create |
+-------------+-----------+--------+---------+-----------------------+

Apply reads the deployed requisition and foreign source, then compares them with the document. When nothing differs, it sends no write and triggers no import. Otherwise it writes the foreign source (create, update or delete), posts the requisition, and triggers the import.

apply picks rescanExisting automatically from what changed:

  • A rescan runs for changes that affect what provisiond discovers: a node added or removed, interfaces, services, SNMP primary, location, detectors and policies.
  • No rescan runs for pure metadata: labels, categories, assets and scanInterval. A new scanInterval takes effect at the next scheduled scan.
  • A change the classifier does not recognize triggers a rescan.

Import completion is asynchronous. Block with requisition import --wait (exit 10 on --timeout, default 30m), or watch last-import change in requisition status <fs>. status does not report whether an import succeeded.

Two documents with the same metadata.name abort the plan before any write. A foreignId that appears in more than one requisition is a warning, not an error.

Order: Requisition applies after SnmpConfig and before Maintenance, so a maintenance window in the same apply can refer to nodes this apply imports. The import is asynchronous, so such a reference may still need a follow-up apply.

Diff​

--diff prints one block per requisition that would change, on stderr: the decided rescanExisting, the foreign-source changes, and the per-node changes.

onmsctl apply -f examples/requisition-acme-prod.yaml --dry-run --diff

Expected output (stderr, trimmed):

Requisition/acme-prod (create)
rescanExisting: true

~ foreignSource: updating
spec.foreignSource.detectors[0].name: "DNS" → "ICMP"
...

Inspect and delete​

onmsctl requisition list
onmsctl requisition status acme-prod # deployed state
onmsctl requisition import acme-prod # re-import without re-POST
onmsctl requisition import acme-prod --rescan-existing # re-evaluate existing nodes
onmsctl requisition import acme-prod --wait --timeout 5m # block on the async import
onmsctl requisition delete acme-prod --yes # purge pending + deployed

Expected output:

$ onmsctl requisition list
poc-scale
selfmonitor

Lifecycle and read verbs: requisition list|status|import|export|delete, node|interface list|get, service|category list, and asset list|get. requisition asset set is a write: it changes an imported node's asset field immediately. requisition delete <fs> purges both pending and deployed snapshots. In a terminal it asks for confirmation. In a non-interactive run it refuses unless you pass --yes (-y).

Read-only inspection:

onmsctl requisition node list acme-prod
onmsctl requisition interface list acme-prod <foreign-id>
onmsctl requisition service list acme-prod <foreign-id> <ip>
onmsctl requisition category list acme-prod <foreign-id>

Export​

Export what's already deployed, the reverse of apply:

onmsctl requisition export acme-prod > acme-prod.yaml # one, to stdout
onmsctl requisition export --out ./yaml/ # all, one <fs>.yaml each
onmsctl requisition export acme-prod --include-defaults # inline the default FS

Without --include-defaults, a requisition with no custom foreign source exports in portable style, without spec.foreignSource. With it, the export inlines Horizon's default foreign source and adds a snapshot-timestamp comment.

Convert​

Migrate provision.pl-shape XML, requisitions plus their matching foreign sources:

onmsctl requisition convert --from ./reqs/ --foreign-sources-dir ./fs/ --out ./yaml/
  • --from reads every *.xml in the directory as a requisition.
  • --foreign-sources-dir pairs each requisition with the foreign-source XML of the same basename.
  • --out writes one <foreign-source>.yaml per requisition. Without it, convert writes one ----separated stream to stdout.

Convert is a local transform. It issues no HTTP and needs no context, so it runs under --read-only.

The provision.pl migration is covered in the migration guide.

Convert findings​

Findings go to stderr as <code> <severity> [<file>]: <message>.

CodeSeverityMeaning
PR001warningThe XML carries an element or attribute the model does not represent. It is kept under metadata.x-onmsctl-unmodeled.
PR002warningA foreign-source XML file matches no requisition. Rename it to match its requisition, or remove it.
PR003warningA policy parameter type does not match the policy class. Defined in the catalog. The migrator does not emit it today.
PR004infoA requisition has no matching foreign-source XML. The YAML omits spec.foreignSource and inherits Horizon's default on apply.
PR005warningAn interface snmp-primary value is not P, S or N. The attribute is dropped from the YAML.

Print the rationale for one code, without converting:

onmsctl requisition convert --explain PR001

Exit codes:

  • 0: no findings, or info only.
  • 1: warnings present. The YAML is still written.
  • 2: an error-severity finding withheld the YAML, or a usage error such as a missing --from. No current code has error severity.

Errors​

MessageProbable causeRecovery
invalid `kind: Requisition` documentThe document failed the strict parse. The rest of the message names the field.Fix the named field.
unsupported apiVersionapiVersion is not provisioning.opennms.org/v1.Set apiVersion: provisioning.opennms.org/v1.
unknown fieldA key the model does not define, often a typo or an unmodeled XML attribute.Remove or rename the key.
must be a non-empty stringmetadata.name, foreignId, label, ip, a detector or policy name, or a policy class is "".Give the field a value.
unknown variantsnmpPrimary is not P, S or N.Use one of the three letters.
duplicate foreignIdTwo nodes in one document share a foreignId.Give each node its own foreignId.
duplicate interface ipTwo interfaces on one node share an ip.Merge the interfaces.
metadata.name '<name>' declared inTwo documents in one apply target the same requisition. The plan aborts before any write.Keep one document per requisition.
requires --yes in non-interactiverequisition delete ran without a terminal.Re-run with --yes.
missing --from <xml-dir>requisition convert ran without an input directory.Pass --from, or use --explain <code>.
unknown finding code--explain got a code outside PR001 to PR005.Use a code from the findings table.

Example​

examples/requisition-acme-prod.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/no42-org/onmsctl/main/schemas/requisition.schema.json
#
# Composite kind: Requisition example covering every modeled field
# (per task 10.4 of the add-provisioning-capability change).
#
# Pair with `onmsctl apply -f examples/requisition-acme-prod.yaml
# --dry-run` to preview the action against a live Horizon.
apiVersion: provisioning.opennms.org/v1
kind: Requisition
metadata:
name: acme-prod
spec:
# Pinned-style YAML: the requisition carries its own foreign-source
# definition. Operators who want portable YAML can drop this entire
# block; on apply, Horizon's default foreign-source is inherited
# (see design D1 + the portable-vs-pinned section in the README).
foreignSource:
scanInterval: 1d
detectors:
- name: ICMP
class: org.opennms.netmgt.provision.detector.icmp.IcmpDetector
parameters:
- key: timeout
value: "2000"
- key: retries
value: "1"
- name: SNMP
class: org.opennms.netmgt.provision.detector.snmp.SnmpDetector
parameters:
- key: port
value: "161"
- key: timeout
value: "2000"
policies:
- name: Production tag
class: org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy
parameters:
- key: category
value: Production
- key: matchBehavior
value: ALL_PARAMETERS
nodes:
- foreignId: web01
label: web01.acme.com
# Monitoring (Minion) location that polls this node. Omit or leave
# empty for the Default location. Maps to the requisition node's
# `location` attribute in Horizon.
location: labmonkeys-hq
interfaces:
- ip: 10.0.0.1
snmpPrimary: P
services:
- HTTP
- HTTPS
- SNMP
- ip: 10.0.0.2
snmpPrimary: S
services:
- ICMP
categories:
- Production
- Web
# Asset keys are stored verbatim by Horizon but only the
# canonical column names (`city`, `state`, `serialNumber`,
# `rack`, `country`, …) render in the inventory UI. Stick to
# canonical names unless you're using assets purely as
# operator-private metadata.
assets:
city: NYC
rack: R3
serialNumber: SN-12345
- foreignId: db01
label: db01.acme.com
interfaces:
- ip: 10.0.1.1
snmpPrimary: P
services:
- PostgreSQL
- SNMP
categories:
- Production
- Database
assets:
city: NYC
- foreignId: cache01
label: cache01.acme.com
interfaces:
- ip: 10.0.2.1
snmpPrimary: N
categories:
- Production
- Cache