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.
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:
-
Blank 1 (Content-Type header): Drag 'yang-data+json' to this blank. The
Content-Typeheader specifies the format of the data being sent in the request body. Since thepayloadis a Python dictionary that will be serialized to JSON (json=payloadin therequests.putcall) and represents YANG data, the correct MIME type isapplication/yang-data+json. -
Blank 2 (Payload key): Drag 'ietf-interfaces:interface' to this blank. The
payloaddictionary represents the YANG data structure for configuring an interface. According to theietf-interfacesYANG module, when configuring a single interface, the root element or key for the interface object in the JSON payload isietf-interfaces:interface. -
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 subsequentrequests.putcall uses an f-stringf'{base_url}{restconf_url}'to construct the full URL, clearly indicating that the variable's name should bebase_url. -
Blank 4 (enable_function call argument - if_type): Drag 'iana-if-type:ethernetCsmacd' to this blank. The
enable_functionis called with('Loopback1', true, __________), where the third argument isif_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=payloadargument in therequests.putcall 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.putcall. - Choosing 'iana-if-type:softwareLoopback' for interface type: While
softwareLoopbackis a valid IANA interface type, the question emphasizes 'ports on a switch'.ethernetCsmacdis 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
Community Discussion
No community discussion yet for this question.