Cisco
350-901 · Question #54
Refer to the exhibit. What is the output of this IOS-XE configuration program? ``python import sys, requests USER = 'root' PASS = 'Cisco0123' URI = URL + '/restconf/data/ietf-interfaces:interfaces-sta
Sign in or unlock 350-901 to reveal the answer and full explanation for question #54. The question stem and answer options stay visible for context.
Network Automation
Question
Refer to the exhibit. What is the output of this IOS-XE configuration program?
import sys, requests
USER = 'root'
PASS = 'Cisco0123'
URI = URL + '/restconf/data/ietf-interfaces:interfaces-state'
headers = {'Content-Type': 'application/yang-data+json', 'Accept': \
'application/yang-data+json'}
try:
result = requests.get(URI, auth=(USER,PASS), headers=headers)
r_json = result.json()
flagdown=0
for record in r_json["ietf-interfaces:interfaces"]["interface"]:
if(print("0<:5>",format(record["name"]," record["name"],"
if(print("0<:5>",format(record["name"],"
if record["ietf-interfaces:interfaces"]["interface"]:
print("0<:5> ", format(record["name"]," "), end="")
if record["ietf-ip:ipv4"]["address"]:
print("0<:15>", format(record["ietf-ip:ipv4"]["address"][0]["ip"], end=""))
else:
print("0<:15>",format("no IPv4"), end="")
print("0<:9>",format(record["ietf-interfaces:interfaces"]["interface"][0]["admin-status"]," "), end="")
print("0<:9>",format(record["ietf-interfaces:interfaces"]["interface"][0]["oper-status"]," "), end="")
print("0<:9>",format(record["ietf-interfaces:interfaces"]["interface"][0]["enabled"]," "), end="")
flagdown=1
if(flagdown):
print("At least one interface is down")
else:
print("All interfaces are up")
except:
print("Exception: " + str(sys.exc_info()[0]) + "\n" + str(sys.exc_info()[1]))
print("Error: " + str(result.status_code), result.text)
Exhibit
Options
- Ainterface operational status in IPv6 addresses
- Binterface administrative status in IPv4 addresses
- Cinterface operational status in IPv4 addresses
- Dinterface administrative status in IPv6 addresses
Unlock 350-901 to see the answer
You've previewed enough free 350-901 questions. Unlock 350-901 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#RESTCONF#YANG#Python#Interface Management
