
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