QuestionQ19
Device-Level Network AutomationDrag the code from the bottom into the missing-code boxes to build an ncclient request that captures operational IPv4 routing data from a Cisco IOS XE device. Not every option is used.
Drag & Drop
data = ''' < xmlns="urn:ietf:params:xml:ns:yang:ietf-routing"> <routing-instance> <name>default</name> <ribs> <rib> <name>ipv4-default</name> <routes> </routes> </rib> </ribs> </routing-instance> </routing-state> ''' with manager.(host=HOST, password=PASSWORD, port=PORT, username=USERNAME,hostkey_verify=False, device_params={'name':'iosxe'}) as m: c = m.get(filter=("subtree", )) routing = xmltodict.parse(c)["rpc-reply"]["data"] routes = routing["routing-state"][""]["ribs"]["rib"]["routes"]["route"] for route in routes: print("\n destination: {}".format(route["destination-prefix"])) print(" nexthop int: {}".format(route["next-hop"]["outgoing-interface"])) print(" nexthop addr: {}".format(route["next-hop"]["next-hop-address"]))
Community Discussion