Cisco UCS Python SDK is a Python module that helps
automate all aspects of Cisco UCS management,
including server, network, storage, and hypervisor
management. The Cisco UCS Python SDK works on the
Cisco UCS Manager MIT, performing create, read,
modify, or delete actions on the managed objects in the
tree. Python versions 2.7 and higher and version 3.5 and
higher are supported. The Cisco UCS Python module for
UCS Manager is called ucsmsdk and can be installed
using pip by issuing the following command at the
command prompt: pip install ucsmsdk. As of this
writing, the current version of the ucsmsdk module is
0.9.8.
The Cisco UCS Python SDK provides a utility called
convert_to_ucs_python that gives administrators and
developers the option of recording all the interactions
with the Cisco UCS Manager GUI and saving them into
an XML file. Running this XML file through the
convert_to_ucs_python tool automatically generates
Python code corresponding to the actions that were
performed in the GUI. Using this process, data center
automation efforts can be sped up orders of magnitude,
and simple tasks such as creating a new VLAN or
complex tasks such as configuring a service policy
template can be automated within seconds.
Next, let’s explore the Cisco UCS Python SDK and see
how to connect to a Cisco UCS Manager instance,
retrieve a list of all the compute blades in the system, and
extract specific information from the returned data. The
sample Python code is built in Python 3.7.4 using version
0.9.8 of the ucsmsdk module.
First, the UcsHandle class is imported. An instance of
this class is used to connect to Cisco UCS Manager. The