200-901 · Question #668
Drag and Drop Question Refer to the exhibit. Drag and drop the code snippets from the bottom onto the blanks in the Python script to create multiple VLANs using the Cisco UCS Python SDK. Not all…
The correct answer is UcsHandle; Vlans; FabricVlan; commit. The question tests the ability to correctly use the Cisco UCS Python SDK to connect to a UCS manager, iterate through a list, create managed objects for VLANs, and commit the changes, by filling in the blanks in a Python script.
Question
Exhibit
Answer Area
Drag items
Correct arrangement
- UcsHandle
- Vlans
- FabricVlan
- commit
Explanation
The question tests the ability to correctly use the Cisco UCS Python SDK to connect to a UCS manager, iterate through a list, create managed objects for VLANs, and commit the changes, by filling in the blanks in a Python script.
Approach. 1. First blank (handle initialization): The line handle = ______ ('ucsmanageip', 'ucsadmin', 'ucspw') is instantiating a connection handle to the UCS server. The from ucsmsdk.ucshandle import UcsHandle statement at the top of the script, combined with the documentation in Exhibit 1 showing UcsHandle as the class for UCS related communication, indicates that UcsHandle is the correct choice here. The parameters ('ucsmanageip', 'ucsadmin', 'ucspw') correspond to the IP, username, and password for the UcsHandle constructor. Therefore, 'UcsHandle' should be dragged to the first blank.
2. Second blank (for loop iteration): The line for vlan in ______ : is part of a loop designed to process each VLAN ID. The preceding line vlans = ['10', '20', '30'] defines a Python list named vlans containing the VLAN IDs. In Python, to iterate over a list, you simply use for item in list_name:. Thus, vlans is the correct choice for this blank. Therefore, 'vlans' should be dragged to the second blank.
3. Third blank (VLAN object creation): The line vlan_mo = ______ (parent_mo_or_dn=lan_cloud[0], name='vlan'+vlan, id=vlan) is creating a managed object representing a VLAN. The from ucsmsdk.mometa.fabric.FabricVlan import FabricVlan statement at the top of the script explicitly imports the FabricVlan class, which is used for creating VLAN managed objects. The parameters parent_mo_or_dn, name, and id are all consistent with creating a FabricVlan object. Therefore, 'FabricVlan' should be dragged to the third blank.
4. Fourth blank (committing changes): The line handle.______ () comes after handle.add_mo(vlan_mo, True), which adds the managed object to the commit buffer. The add_mo documentation in Exhibit 1 explicitly states: 'This method does not trigger a commit by itself. This needs to be followed by a handle.commit() either immediately or after more operations to ensure successful addition of object on server.' This indicates that a commit() method needs to be called on the handle to persist the changes to the UCS server. Therefore, 'commit' should be dragged to the fourth blank.
Common mistakes.
- common_mistake. 1. 'Flask': Flask is a micro web framework for Python, completely unrelated to the Cisco UCS Python SDK. It is a distractor.
- 'UcsServer': While a UCS server is the target,
UcsServeris not the class used to establish the connection handle in the UCS SDK;UcsHandleis. Confusing the physical server with the SDK class for interaction is a common mistake. - Misplacing
UcsHandleorFabricVlan: Forgetting which class is for the connection handle versus the specific managed object (VLAN in this case) would lead to incorrect placement. The import statements clearly differentiate them. - Omitting
commit: A common mistake when working with SDKs that use a 'commit buffer' pattern is to forget to call the finalcommitoperation, leading to changes not being applied to the actual device. Theadd_modocumentation explicitly warns against this.
Concept tested. This question tests the understanding and application of the Cisco UCS Python SDK for automating UCS configurations, specifically creating managed objects (VLANs), establishing a connection, and committing changes. It also assesses general Python syntax for loops and object instantiation, and the ability to interpret API documentation.
Topics
Community Discussion
No community discussion yet for this question.
