200-901 無料問題集「Cisco DevNet Associate」
Refer to the exhibit.
An engineer needs to retrieve all the organizations in a Cisco UCS Manager deployment. Drag and drop the code snippets from the bottom onto the blanks in.. Python script to print the information to standard output.
Some options may be used more than once. Not all options are used.
An engineer needs to retrieve all the organizations in a Cisco UCS Manager deployment. Drag and drop the code snippets from the bottom onto the blanks in.. Python script to print the information to standard output.
Some options may be used more than once. Not all options are used.
正解:
Explanation:
from ucsmsdk.ucshandle import UcsHandle
connection = UcsHandle("10.10.20.113", "ucspe", "ucspe")
connection.login()
orgs = []
ucsm_orgs = connection.query_classid("orgOrg")
for org in ucsm_orgs:
temp_org = {"name": org.name, "dn": org.dn, "rn": org.rn}
orgs.append(temp_org)
print(orgs)
* Understanding the UCSHandle Class:
* Purpose: The UcsHandle class is used to interface with the UCS Manager.
* Parameters: It requires parameters like IP address, username, password, port, secure, and proxy.
* Python Script Explanation:
* Importing UcsHandle: The first step is to import the UcsHandle class from the ucsmsdk.ucshandle module.
* Creating a Connection: An instance of UcsHandle is created with the UCS Manager's IP address, username, and password.
* Login: The login() method is called on the UcsHandle instance to establish a session with the UCS Manager.
* Querying Organizations: The query_classid() method is used to retrieve objects of a specific class, in this case, "orgOrg" which represents organizations.
* Looping through Results: The script iterates over the retrieved organizations, extracting their name, distinguished name (dn), and relative name (rn), and appending this information to the orgs list.
* Printing Results: Finally, the orgs list is printed, which contains the details of all the organizations.
References:
* Cisco DevNet Associate Certification Guide, Sections on UCS Manager API and Python SDK
* UCS Python SDK Documentation
Drag and drop the Python code from the left onto the correct step on the right to call a REST API.
正解:
Explanation: