Using this new session, a POST request is sent to the
login URL, containing the username and password as
payload and disabling the SSL certificate authenticity
verification by specifying verify=False. At this point, a
session is established to the DevNet Sandbox vManage
instance. This session can be used to interact with the
vManage REST API by getting, creating, modifying, and
deleting data.
The code specifies the API resource that will return a list
of all the devices in the SD-WAN fabric:
dataservice/device. The complete URL to retrieve the
devices in the fabric is built on the next line by
combining the base URL with the new resource. The
DEVICE_URL variable will look like
https://sandboxsdwan.cisco.com:8443/dataservice/devi
ce. Next, the same session that was established earlier is
used to perform a GET request to the device_url
resource. The result of this request is stored in the
variable aptly named DEVICE_RESPONSE, which
contains the same JSON-formatted data that was
obtained in the previous curl and Postman requests,
with extensive information about all the devices that are
part of the SD-WAN fabric. From that JSON data, only
the list of devices that are values of the data key are
extracted and stored in the DEVICE_ITEMS variable.
Next, the header of a rudimentary table is created. This
header contains the fields Host-Name, Device Model,
Device ID, System IP, and Site ID. From the extensive
list of information contained in the DEVICE_ITEMS
variable, only these five fields will be extracted and
displayed to the console for each device in the fabric. The
code next prints a series of delimiting dashes to the
console to increase the readability of the rudimentary
table. The next line of code has a for loop that is used to
iterate over each element of the DEVICE_ITEMS list