QuestionQ18

Controller-Based Network Automation

An engineer needs to onboard a new switch in Cisco Catalyst Center PnP for Day-0 provisioning. The engineer must retrieve an authentication token and POST the device serial number/PID to the PnP import intent endpoint so that it appears in the PnP queue. Not every option is used.

Drag & Drop
import requests

requests.packages.urllib3.disable_warnings()

base = "https://198.51.100.10"
auth = ("dnac", "Cisco12345")

# Get token
t = requests.post(f"{base}/dna/system/api/v1/auth/token", auth=auth, verify=False)
t.raise_for_status()
token = t.json()["Token"]

headers = {"": token, "": "application/json"}
payload = [
    {"serialNumber": "FGL1234ABC", "pid": "C9300-24T", "siteName": "Global/Branch1"}
]

resp = requests.(
    f"{base}/dna//api/v1/onboarding/pnp-device/import",
    headers=headers,
    json=payload,
    verify=False,
)
resp.raise_for_status()
print("PnP device imported.")
Explanation

Cisco Catalyst Center uses the x-auth-token header to send the token returned by its authentication endpoint. Importing a Plug and Play device supplies a JSON serial-number/PID payload by POST to the intent API endpoint /dna/intent/api/v1/onboarding/pnp-device/import; therefore the request also uses Content-Type: application/json.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!