Refer to the exhibit.
#! /usr/bin/env python3
from env_lab import dnac
import json
import requests
import urllib3
from requests.auth import HTTPBasicAuth
from prettytable import PrettyTable
dnac_devices = PrettyTable(['Hostname','Platform Id','Software Type','Software Version','UpTime'])
dnac_devices.padding_width = 1
headers ={
'content-type': "application/json",
'x-auth-token': ""
}
def dnac_login(host, username, password):
url = "https://{}/api/system/v1/auth/token".format(host)
response = requests.request("POST", url, auth=HTTPBasicAuth(username, password), headers=headers, verify=False)
return response.json()["Token"]
def network_device_list(dnac,token):
url = "https://{}/api/v1/network-device".format(dnac["host"])
headers["x-auth-token"] = token
response = requests.get(url, headers=headers, verify=False)
data = response.json()
for item in data['response']:
dnac_devices.add_row([item["hostname"],item["platformid"],item["software Type"],item["softwareVersion"],item["upTime"]])
Which code results in the working Python script displaying a list of network devices from the Cisco DNA Center?
A. |
network_device_list(dnac["host"], dnac["username"], dnac["password"])
login = dnac_login(dnac)
print(dnac_devices)
|
|
B. |
login = dnac_login(dnac["host"], dnac["username"], dnac["password"])
network_device_list(dnac, login)
print(dnac_devices)
|
|
C. |
login = dnac_login(dnac["host"], dnac["username"], dnac["password"])
network_device_list(dnac, login)
for item in dnac_devices:
print(dnac_devices.item)
|
|
D. |
network_device_list(dnac["host"], dnac["username"], dnac["password"])
login = dnac_login(dnac)
for item in dnac_devices:
print(dnac_devices.item)
|
|
WARNING
the answers are mixed, do not specify in the comment number or the letter of the answer
please write answer#A instead A, answer#B instead B...