QuestionQ25

Controller-Based Network Automation

An engineer must prepare SD-WAN Day 0 by exporting a WAN-edge bootstrap configuration from vManage. The engineer must authenticate to vManage, obtain the XSRF token, and GET the bootstrap file for a specified device ID. Drag the code snippets into the boxes to construct the artifact. Not all options are used.

Drag & Drop
import requests

requests.packages.urllib3.disable_warnings()

base = "https://203.0.113.40:8443"
username = "netops"
password = "Cisco12345"
device_id = "C8K-EDGE-001"

# Authenticate and get XSRF token
login = requests.post(
    f"{base}/j_security_check",
    headers={"Content-Type": "application/x-www-form-urlencoded"},
    data=f"j_username={username}&j_password={password}",
    verify=False,
)
login.raise_for_status()
xsr f = requests.get(
    f"{base}/dataservice/client/token",
    headers={"Cookie": login.headers.get("Set-Cookie", "")},
    verify=False,
)

xsrf.raise_for_status()

hdrs = {
    "Cookie": login.headers.get("Set-Cookie", ""),
    "X-XSRF-TOKEN": xsrf.text,
    "Accept": "application/json",
}

url = f"{base}/dataservice/?={device_id}"
r = requests.(url, =hdrs, verify=False)
r.raise_for_status()
with open("bootstrap.cfg", "w") as f:
    f.write(r.text)
print("Bootstrap downloaded.")
Explanation

The bootstrap configuration is retrieved from the device/bootstrap/config resource using the device UUID query parameter. A GET request reads and downloads that configuration. Supplying headers=hdrs carries the authenticated session cookie and the X-XSRF-TOKEN needed by vManage. Cisco’s current SD-WAN Manager API likewise defines bootstrap-config retrieval as a GET operation associated with a device UUID.

Learn more

Community Discussion

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