nerdexam
CiscoCisco

200-901 · Question #414

200-901 Question #414: Real Exam Question with Answer & Explanation

This question tests the ability to construct a Python script to interact with a network device using RESTCONF, specifically focusing on correct HTTP headers, YANG data model structure, and Python syntax for making API calls.

Understanding and Using APIs

Question

Drag and Drop Question Drag and drop the code from the bottom onto the box where the code is missing to enable ports on a switch by using RESTCONF. Not all options are used. Answer:

Explanation

This question tests the ability to construct a Python script to interact with a network device using RESTCONF, specifically focusing on correct HTTP headers, YANG data model structure, and Python syntax for making API calls.

Approach. The correct interaction involves dragging four specific options to their respective blanks in the Python code:

  1. Blank 1 (Content-Type header): Drag 'yang-data+json' to this blank. The Content-Type header specifies the format of the data being sent in the request body. Since the payload is a Python dictionary that will be serialized to JSON (json=payload in the requests.put call) and represents YANG data, the correct MIME type is application/yang-data+json.

  2. Blank 2 (Payload key): Drag 'ietf-interfaces:interface' to this blank. The payload dictionary represents the YANG data structure for configuring an interface. According to the ietf-interfaces YANG module, when configuring a single interface, the root element or key for the interface object in the JSON payload is ietf-interfaces:interface.

  3. Blank 3 (URL variable definition): Drag 'base_url' to this blank. The line ___________ = 'https://192.168.1.1:8443' defines a variable to hold the base URL of the RESTCONF endpoint. The subsequent requests.put call uses an f-string f'{base_url}{restconf_url}' to construct the full URL, clearly indicating that the variable's name should be base_url.

  4. Blank 4 (enable_function call argument - if_type): Drag 'iana-if-type:ethernetCsmacd' to this blank. The enable_function is called with ('Loopback1', true, __________), where the third argument is if_type. While 'Loopback1' might suggest a software loopback, the question asks to 'enable ports on a switch'. ethernetCsmacd (Ethernet Carrier Sense Multiple Access with Collision Detection) is the IANA interface type for a standard Ethernet port, which is a common type for physical ports on a switch. This choice aligns with configuring a typical physical switch port.

Common mistakes.

  • common_mistake. - Using 'application/xml' for Content-Type: This would be incorrect because the json=payload argument in the requests.put call indicates the payload is being sent as JSON, not XML.
  • Using 'run_function' as a payload key: 'run_function' is not a valid YANG data model element for configuring an interface; it's a generic function name and out of context here.
  • Confusing variable names: Using any other string for the base URL variable (e.g., a non-existent option) would break the URL construction in the requests.put call.
  • Choosing 'iana-if-type:softwareLoopback' for interface type: While softwareLoopback is a valid IANA interface type, the question emphasizes 'ports on a switch'. ethernetCsmacd is a more common and representative type for physical switch ports, aligning with the general intent of configuring network interfaces on a switch. Even though the example name is 'Loopback1', the provided solution prioritizes the common device 'port' type.

Concept tested. This question tests knowledge of RESTCONF API interactions, including proper HTTP headers (Accept and Content-Type for YANG data in JSON format), understanding of YANG data models (specifically the ietf-interfaces module and IANA interface types), Python's requests library for making HTTP PUT requests, URL construction, and basic Python function argument passing.

Topics

#RESTCONF#Network Configuration#Switch Ports#Network APIs

Community Discussion

No community discussion yet for this question.

Full 200-901 PracticeBrowse All 200-901 Questions