Chapter 8

Automation and Artificial Intelligence

CCNP Enterprise Core (350-401 ENCOR) Study GuideDomain 6.0 · Automation and Artificial Intelligence · 15% of the exam · 7 objectives

Domain 6.0 — Automation and Artificial Intelligence (15%). Objectives 6.1–6.7: interpret Python; construct valid JSON; describe YANG; describe Catalyst Center and SD-WAN Manager APIs; interpret REST API response codes and payloads; construct an EEM applet; compare agent vs agentless orchestration. In v1.2 this domain was renamed from "Automation" — the AI content is new, and it is about what AI does with network data, not about writing AI models.

Automation is the chapter where the network stops being something you type at and starts being something you program. The skills are small and concrete: read a Python script, write a JSON document that parses, describe a YANG model, call an API and read its response, write an EEM applet that acts when an event fires. None of them requires writing a large program — each requires reading and writing small, exact things.

6.1 Interpret basic Python components and scripts

Python on the exam is reading, not writing. The components to recognise: variables (names bound to values), types — string (str), integer (int), float, boolean (True/False), list (ordered, mutable, []), dictionary (key-value pairs, {}), tuple (ordered, immutable) — and control flow: if/elif/else, for loops, while loops.

Python typeExampleNotes
str"SW1"Text; double or single quotes
int / float42 / 3.14Numbers; division of ints can produce a float
boolTrue / FalseCapitalised — true is a NameError
list["SW1", "SW2"]Ordered, mutable; append() changes it in place
dict{"name": "SW1"}Key-value pairs; keys are usually strings

The exam's favourite Python traps are the small ones. devices.append("SW3") changes the list in place and returns None — so print(len(devices)) after appending to a two-item list prints 3, not 2, and assigning the result of append() to a variable gives you None. Indentation is syntax: a mis-indented line is not a style problem, it is a different program (or an error). A for loop over a dictionary iterates its keys, not its values.

Check yourself

A script contains devices = ["SW1", "SW2"] followed by devices.append("SW3") and then print(len(devices)). What does it print, and why?

Answer: 3. append() mutates the list in place — the list now has three items, and len() counts them. The trap is thinking append() returns a new list; it returns None and changes the original.

6.2 Construct valid JSON-encoded files

Definition

JSON. A text format for structured data: objects hold key-value pairs ({"key": value}), arrays hold ordered items ([item, item]), and values are strings, numbers, true/false, null, objects, or arrays. Keys are always double-quoted strings.

Figure 8.1 — The shape of a JSON document
Figure 8.1 — The shape of a JSON document: objects hold pairs, arrays hold items.

Three defects make JSON invalid, and the exam rotates through them: single quotes around keys or strings (JSON requires double quotes), a trailing comma after the last item in an object or array, and an unquoted key. {"name": "SW1", "enabled": true} is valid; {'name': 'SW1'}, {"name": "SW1",}, and {name: "SW1"} are not. Python's True is JSON's true — the capitalisation differs, and a payload with True in it is not JSON. Read a JSON fragment the way a parser does: every opening brace needs a closing brace, every key needs double quotes, and the last item never takes a comma.

6.3 YANG: model, data, and protocol — three layers, three jobs

YANG is a data modelling language: it describes what data exists, its types, and its structure — not how to move it. Three layers, three jobs: the model (YANG) defines the data, the data itself is encoded (XML for NETCONF, JSON or XML for RESTCONF), and the protocol (NETCONF/RESTCONF) moves it. Confusing the layers is the exam's YANG trap: YANG does not transport anything, and NETCONF does not define any data.

YANG node typeMeaning
leafA single value (e.g. an interface name)
leaf-listA list of single values
containerGroups related nodes; no value of its own
listMultiple entries, each keyed (e.g. interfaces, keyed by name)
choice / caseAlternatives — only one branch is used

Read a YANG tree the way you read a file path: a container holds a list, the list holds entries keyed by name, each entry holds leaves. The path to a value — /interfaces/interface[name='GigabitEthernet1']/description — is how a NETCONF or RESTCONF call names the thing it wants.

6.4 APIs for Catalyst Center and SD-WAN Manager

Figure 8.2 — The API request flow: authenticate, then call
Figure 8.2 — The API request flow: authenticate, then call. Read the code first, the payload second.

Catalyst Center APIs are RESTful: authenticate first (POST /dna/system/api/v1/auth/token with basic auth) to receive a token, then call intent APIs with that token in the X-Auth-Token header — for example, GET /dna/intent/api/v1/network-device lists devices. SD-WAN Manager APIs follow the same pattern with a different base: authentication returns a session token (or cookie), and calls go to /dataservice/<resource> — /dataservice/device, /dataservice/template/device, and similar. The exam tests the structure, not memorised URLs: authenticate first, present the token on every call, and read the resource path as a description of what the call returns.

Exam tip

Tokens expire. A 401 on a call that worked yesterday usually means the token aged out, not that the API changed. Re-authenticate, then retry — and never hard-code a token into a script, because the script will break on exactly the schedule the token expires on.

6.5 Interpret REST API response codes and payloads

CodeMeaningWhat to do
200 OKThe request succeededRead the payload
201 CreatedA resource was createdRead the payload for its identifier
204 No ContentSuccess, deliberately no payloadDo not expect a body
400 Bad RequestThe request was malformedCheck the payload/URL you sent
401 UnauthorizedAuthentication failed or the token expiredRe-authenticate
403 ForbiddenAuthenticated, but not permittedCheck the token's scope — a new login will not help
404 Not FoundThe resource does not exist at that URICheck the URI, not the credentials
500 Internal Server ErrorThe server failedRetry later; the fault is not yours

Read a response in order: code first, payload second. The code tells you which class of outcome happened; the payload tells you the detail. A 403 is not an authentication failure — re-authenticating will not fix a scope problem. A 404 is not a credential problem — checking the password will not fix a wrong URI. And a 204 with no payload is a success, not a failure: the exam's Deep Dive turns on exactly that, a call that returns nothing because there was nothing to return.

Check yourself

A script that worked yesterday now gets 401 on every Catalyst Center call, and the credentials have not changed. What is the most likely cause, and what is the fix?

Answer: The token expired. Catalyst Center tokens are short-lived. Re-authenticate with POST /dna/system/api/v1/auth/token and present the new token — do not change the credentials or the URLs.

6.6 EEM applets: automate configuration, troubleshooting, or data collection

An EEM (Embedded Event Manager) applet is a small program that lives on the device: when an event fires, it runs a list of actions. The structure is always the same: event manager applet <name>, an event line (what triggers it — a syslog pattern, a timer, a CLI pattern, an interface state change), and action lines (what it does — run a CLI command, send a syslog message, send an email, reload). Timer events fire on schedule, not on syslog — a common exam confusion: a timer watchdog applet runs every N seconds whether or not anything was logged.

event manager applet BACKUP-ROUTE-DOWN
 event syslog pattern "LINEPROTO-5-UPDOWN.*GigabitEthernet1.*down"
 action 1.0 cli command "enable"
 action 2.0 cli command "show ip route 10.2.0.0 255.255.0.0"
 action 3.0 syslog msg "EEM: branch route check run"

The exam's EEM question is usually a trace: given an event and a list of actions, what happens, in what order — or a construction: given a requirement ("when this syslog message appears, collect this output"), which event line and which actions build it. Read the event line first: it decides when. Then read the actions in numbered order: they decide what.

6.7 Agent vs agentless orchestration

Figure 8.3 — Two orchestration models: resident agent vs reach-in controller
Figure 8.3 — Two orchestration models: resident agent vs reach-in controller.
PropertyAgent-based (Puppet, Chef)Agentless (Ansible, Terraform)
Software on the deviceYes — a resident agentNo — nothing installed
DirectionAgent pulls desired state on scheduleController pushes a change over SSH/API, then leaves
EnforcementContinuous — drift is corrected automaticallyAt run time — drift persists until the next run
Works when the device is offlineAgent enforces cached state locallyNo — the controller cannot reach it
Best forLong-lived servers, continuous complianceNetwork devices, one-off changes, provisioning

The exam's shortcut: "agent on the device, pulls config" is agent-based; "SSH/API from a controller, nothing installed" is agentless. Ansible is the agentless example the exam uses most; Puppet and Chef are the agent-based pair. Terraform is agentless and declarative — it describes the desired end state and works out the steps — which is a different axis from agent/agentless, and the exam keeps the two axes separate: declarative vs imperative is about how you describe the change; agent vs agentless is about how it is delivered.

Deep Dive — the round trip of one RESTCONF change

The chapter's Deep Dive follows one RESTCONF change — setting an interface description on a Catalyst Center-managed device — on a full round trip: the script builds the JSON payload from a YANG path, authenticates, sends the PUT, reads the 200, and then verifies with a second GET. Then it replays the same call with three failure stamps: a 401 (expired token — re-authenticate), a 400 (a trailing comma in the JSON — fix the payload), and a 204 (success with deliberately no payload — do not treat the empty body as a failure). The lesson is the chapter's refrain: code first, payload second, and a success with no body is still a success.

Configuration Workshop — automate one change

  1. Read a script. Take a short Python script that lists interfaces from a JSON file and trace it line by line: what does each variable hold after each line? Predict the output before running it.
  2. Write valid JSON. Build a JSON document describing two devices (name, management IP, enabled flag). Introduce each of the three classic defects in turn — single quotes, trailing comma, unquoted key — and confirm the parser rejects each one.
  3. Map a YANG path. From a YANG tree for interfaces, write the path to one interface's description, then build the matching RESTCONF GET URI and the JSON payload for a PUT that changes it.
  4. EEM applet. Write an applet that fires on a syslog pattern for an interface going down, runs show ip interface brief, and logs a message. Test it by shutting the interface in a lab.
  5. Choose the tool. For each of four requirements — continuous compliance on servers, one-off provisioning of fifty switches, a change that must survive device reboots, a device that is usually offline — pick agent-based or agentless and justify it in one sentence.
Try it yourself

Run the workshop's JSON exercise against a real parser (python3 -m json.tool) — the parser is the authority, not your eye. Then call a public test API with curl and read the response code before the body, until the order is a habit.

Common mistakes and exam traps — Automation and AI

TrapTruth
append() returns a new listIt mutates in place and returns None.
Single quotes are fine in JSONJSON requires double quotes. Single quotes are a Python literal, not JSON.
YANG transports configurationYANG models data. NETCONF/RESTCONF transport it.
A 403 means re-authenticate403 is Forbidden — authenticated but not permitted. Re-authenticating will not help.
A 204 response is a failure204 is success with deliberately no payload.
Ansible needs an agent on the deviceAnsible is agentless — SSH/API from a controller.

End-of-chapter check questions (multiple choice)

Answer these without looking back, then check against the key. Each question has one correct answer. These questions are written fresh for this guide — they are not the book's mock-test questions.

1

A script builds a list of four interface names, appends one more, and then prints the length of the list. What prints?

A) 4 B) 5 C) None D) An error, because append returns a new list

2

Which of these payloads is valid JSON?

A) {"device": "R1", "up": True} B) {"device": "R1", "up": true} C) {"device": "R1", "up": true,} D) {device: "R1", "up": true}

3

What is the role of YANG in the model/data/protocol stack?

A) It transports configuration to devices B) It models the data — what exists, its types, and its structure C) It authenticates API calls D) It encodes data as JSON

4

Which HTTP verb and datastore combination reads the running configuration via RESTCONF?

A) POST against the candidate datastore B) GET against the running datastore C) DELETE against the startup datastore D) PUT against the candidate datastore

5

A Catalyst Center API call returns 401, although the same script worked yesterday and the credentials are unchanged. What is the most likely cause?

A) The API URL changed B) The token expired — re-authenticate and retry C) The token's scope is too narrow D) The server is down

6

A RESTCONF call returns 204 No Content. What does that mean?

A) The request failed B) The resource does not exist C) Success, deliberately with no payload D) Authentication failed

7

What is the difference between a 401 and a 403 response?

A) They are the same B) 401 is authentication failed or token expired; 403 is authenticated but not permitted C) 401 is not permitted; 403 is authentication failed D) 401 means the resource is missing; 403 means the server failed

8

An EEM applet uses a timer watchdog event. When does it fire?

A) Only when the matching syslog message appears B) On schedule, every N seconds, whether or not anything was logged C) Only when an interface changes state D) Once, at device boot

9

Which orchestration tool is agentless, reaching devices over SSH or an API with nothing installed on them?

A) Puppet B) Chef C) Ansible D) None of these

10

What does the AI-assisted assurance workflow in Catalyst Center do with streaming telemetry?

A) It writes Python scripts for the administrator B) It triages issues, suggests root causes, and drafts remediation from the telemetry C) It replaces the need for any monitoring D) It trains a model on the device itself

Answer key

Q1: B — append() mutates the list in place, so four items become five.
Q2: B — Double-quoted keys, lowercase true, no trailing comma. A uses Python's capitalised True, C has a trailing comma, D has an unquoted key.
Q3: B — YANG models the data; NETCONF/RESTCONF transport it.
Q4: B — GET against the running datastore reads the running configuration.
Q5: B — The token expired; re-authenticate and retry.
Q6: C — 204 is success with deliberately no payload.
Q7: B — 401 is authentication; 403 is authorisation (permitted to authenticate, not to do this).
Q8: B — Timer events fire on schedule, not on syslog.
Q9: C — Ansible is agentless.
Q10: B — AI assurance triages issues and suggests root causes from telemetry; it does not replace monitoring.

Chapter 8 — based on the Cisco 350-401 ENCOR v1.2 exam objectives for Domain 6.0. Unofficial study material — not affiliated with or endorsed by Cisco Systems, Inc.

Want the full CCNP Enterprise Core (350-401 ENCOR) package?

Read this guide free. Then prove you're ready with 900 original practice questions, instant explanations, 36 interactive PBQ labs, and 3 months of online access — plus the downloadable PDF of this guidebook.

Get CCNP ENCOR Full Access — $10