Concept and mechanism
Automation starts with clear types and contracts. A Python list comprehension can select names only from records whose Boolean field is enabled; the result depends on expression and filter rather than implicit intent. JSON requires double-quoted names and lowercase false; string false is not Boolean false.
Even syntactically valid JSON can violate a YANG model constraining types, ranges, or structure. If a value is outside its permitted range, changing quotation does not necessarily fix the contract. Retain model version and interpret returned errors before retrying requests through guesswork.
Guided application
In the Catalyst Center API, 202 with taskId enables tracking of an asynchronous operation rather than proving completion. Query terminal state, handle errors, and verify outcomes before handing ownership to RUN. EEM needs another form of attention: action labels sort as strings, so 10.0 can precede 2.0.
Use a consistent convention and rehearse the sequence. Agentless describes an architecture without a dedicated target agent but retains transport, compatibility, and authorized-credential dependencies. In a fictional case, the pipeline declared delivery solely from the first HTTP code and missed a later failure.
Correct the acceptance workflow. AI suggestions also need validation against topology and version, especially before critical changes; a convincing explanation is not evidence of safe execution.
Select targets without erasing information
A fictional APS pipeline receives inventory from two teams. One supplies enabled as a Boolean and the other as text. In Python, string "false" is truthy because it is nonempty.
A filter intended to select active equipment can therefore include a device that should be excluded. Validate type before using the value and distinguish an absent field from explicit false. The exercise shows get("enabled", False) turning both into False, losing the information that a target was not observed.
Identity needs a contract too: building a dictionary by id retains only one entry when two records share a key. Check uniqueness before transformation or use an approved composite identity, such as site and identifier. Do not resolve collisions by choosing the last row without authorization.
Retain expected and selected lists and the reason for each exclusion. Accepting a set depends on coverage of that set rather than success only for targets surviving the parser.
Preserve the baseline and construct interoperable JSON
A change diff is useful only if its previous baseline remains intact. In the lab, baseline.copy() creates another outer dictionary but retains the same nested interfaces list. Editing the candidate also changes the baseline and makes the difference disappear. deepcopy separates this example’s objects; that does not replace retaining the approved artifact and version.
During JSON parsing, the default decoder keeps the last repeated key. A document containing site=A followed by site=B can become only B. An object_pairs_hook identifies repetitions before pairs are lost and can reject that ambiguous document.
Export requires similar care: json.dumps permits NaN by default although an endpoint may require strict JSON. Use allow_nan=False to detect nonfinite values and agree how the contract represents unknown. Do not convert unknown loss to zero merely to pass validation.
Syntax, types, identity and intent are separate checks performed before any request with effects.
Make coverage and failures explicit in code
A for loop visits r1, r2 and r3. After recording r2, it meets a stop condition and executes break. The lab retains r1 and r2, does not visit r3 and does not execute the loop’s else.
That else represents completion without break rather than mandatory cleanup. If reporting must always retain partial state, choose a structure meeting that requirement and test stopping, exceptions and normal completion. A second exercise raises a synthetic TimeoutError for r2.
Its handler records unknown instead of silently passing. The summary therefore retains three targets: two observed and one unknown. A pipeline calculating percentages only over received responses can show 100% despite the gap.
For paginated queries, retain cursors, detect cycles and apply a budget. The fixture whose next points to its own page is rejected. Deduplicating records does not fix pagination that stopped progressing or establish complete inventory.
Read YANG model dependencies
YANG describes a data tree, constraints and operations; it is more than another way to write JSON. A node with config false represents state that does not become configurable by changing HTTP methods. A leaf may depend on when and be mandatory only in its applicable context.
In the teaching model, static mode requires gateway while gateway outside that mode is rejected. A leafref with require-instance true depends on a valid instance in the corresponding context. Text wan9, although well formed, does not automatically identify an existing interface.
A module name alone also cannot guarantee compatibility: revision, features and deviations may alter the supported tree. Retain what the target advertises and check the payload against that contract. The Python lab contains only a handwritten validator illustrating these dependencies; it does not interpret YANG or establish conformance.
For real work, add suitable validation tools and verify the equipment’s exact implementation and revision.
Follow the correct Catalyst Center task
The initial request, progress query and network effect are separate observations. In the consulted Catalyst Center contract, isError=false without endTime does not yet establish completion. A GET returning HTTP 200 can instead carry a completed task with isError=true and failureReason.
Query success does not approve the queried operation. Record the association between change request, taskId, target and parameters. If simultaneous requests produce t1 and t2, a valid t2 result cannot close t1.
The exercise rejects this swap before accepting terminal state. After error-free completion, confirm intended device state and relevant service behavior. Define query limits and intervals; do not create another task merely because the previous one remains pending.
The local model interprets original envelopes using selected fields but does not contact Catalyst Center. Confirm schemas and endpoints on the installed version before adapting the client.
Manage SD-WAN Manager session context
The SD-WAN Manager 20.15 guide describes session-based authentication with a JSESSIONID cookie and associated XSRF token. An HTTP 200 login response can carry an HTML page when authentication fails. Check expected content and the cookie instead of accepting status alone.
The lab uses public pairs S1/X1 and S2/X2: mixing S1 with X2 fails its synthetic contract. Preserve association across requests and manage renewal deliberately. Opening a session for every query without logging out consumes resources and can invalidate other integrations at product limits.
Reuse valid sessions and terminate them when appropriate. Catalyst Center uses a different mechanism, with X-Auth-Token in requests after authentication; separate adapters by product and version. The consulted vendor example includes verify=False and inconsistent cookie spellings.
These details are not carried forward as good practice: retain TLS validation in real integrations and check the effective contract. No real credential is used in this exercise.
Construct EEM with bounds and evidence
A diagnostic applet needs a suitable trigger, action sequence, authorized identity and stopping criteria. For a manually initiated trial, event none avoids tying collection to a timer or every syslog; explicit execution remains subject to authorized scope.
Disable pagination before long commands so --More-- does not prevent reaching the prompt. Preserve required output before the next command: $_cli_result should not be treated as a permanent archive. Check regexp results before using an extracted variable as an interface name, especially if it guides actions with effects.
Size maxrun for intended collection and observe what remains incomplete when the limit is reached. A flap can create many triggers: bound frequency and cost to avoid amplifying the incident. Python models illustrate these decisions but are not an EEM engine.
The lesson snippet is an original reading exercise; AAA, commands, interface and version require review on lab equipment before execution.
Coordinate orchestration and prove what executed
Compare agent and agentless approaches through how state, execution and dependencies are managed. An agent reapplying its catalog may reverse RUN’s manual change; coordinate a temporary exception with the authority still owning that resource.
An agentless runner needs transport and access, but losing that channel does not prove already applied state or all forwarding vanished. Two mechanisms converging one resource to different values can alternate indefinitely despite being individually idempotent.
Define resource authority and handle conflicts explicitly. Also distinguish command generation from application: Ansible resource-module state rendered works offline, so a valid artifact does not prove router compliance. Run python3 content/labs/ccnp-automation-contracts/run.py --output /path/result.json and compare predictions with both retained evidence runs.
The exercise executes Python 3.13.1 over local fixtures; it executes no Cisco controller, NETCONF, RESTCONF, EEM, real YANG engine or network traffic. Hand those limitations to RUN together with checks still required on actual targets.
Exercise files
Exercise package ccnp-automation-contracts, version 2026-10. Extract into a new directory and follow README.en.md. The commands’ content/labs paths are available from the extracted directory. Python 3.13 with standard-library modules. No pip packages are required.
Download ccnp-automation-contracts (ZIP)
SHA-256 (ZIP)
c75c35bc0850732b40c3a3a93ea45a040100aa081112097da8ea7460bc3d1842
# Original reading exercise only. Not executed on IOS XE.
# Review AAA identity, interface, commands and release before a lab trial.
event manager applet DR-DIAG
event none maxrun 30
action 0010 cli command "enable"
action 0020 cli command "terminal length 0"
action 0030 cli command "show interface GigabitEthernet1/0/7"
action 0040 set interface_snapshot "$_cli_result"
action 0050 cli command "show clock"
action 0060 syslog msg "DR diagnostic collection reached final action"
# Invoke manually only within the authorized lab scope.
# A final log alone does not prove output completeness or application health.202 and taskId start tracking; terminal result and validation support handover decisions.
Common pitfalls
Valid JSON as model conformance; 202 as completion; labels as numbers; agentless as no access; AI as approval.
Related topics: Architecture and surviving capacity · Virtualization, VRFs, and overlays · Switching and adjacency formation
Connect intent, context and evidence before accepting the change.
References
- Catalyst Center asynchronous operations · Catalyst Center API 3.1.6
- Python built-in types and mappings · Current primary reference; actual local Python 3.13.1
- Python shallow and deep copying · Current primary reference; actual local Python 3.13.1
- Python JSON encoding and decoding · Current primary reference; actual local Python 3.13.1
- Python control-flow tools · Current primary reference; actual local Python 3.13.1
- YANG 1.1 modeling language · RFC 7950; config, when, mandatory, leafref, features and deviations
- Catalyst Center asynchronous operations · API documentation 2.3.7.9; not a claim that this is the newest release
- SD-WAN Manager authentication · Release 20.15 guide; session and matching XSRF; example TLS-disable code not adopted
- Catalyst Center authentication and authorization · API guide 2.3.7.9; underlying examples note 2.3.5.x
- EEM design practices and execution limits · Document 216091 updated 2026-05-22; IOS/IOS XE 16.x/17.x examples, not runtime-tested here
- Ansible network resource module states · Current primary guide; rendered/gathered/parsed distinctions; no Ansible execution in this block
- Puppet agent reference · Current agent reference; conceptual comparison, no Puppet execution