This blog is part of my series on Devops for Networking. In this blog, I will cover a brief overview of UCS management model, management tools and how to automate configuration and monitoring of Cisco UCS using Python SDK. UCS is Cisco’s Unified computing system that provides a tightly integrated compute, networking and storage solution.
Cisco UCS management information model is a hierarchical tree with each node in the tree representing either physical or logical entity. The node is referred to as MO(Managed object). Physical entities could be chassis, servers, switches and logical entities could be policies, service profiles etc. XML based interface is provided to set and get managed objects. Following picture shows a sample Management tree with Chassis, blades and adapters.
Following picture shows overview of Cisco UCS management blocks.
Following are some notes:
- UCS information model is the central repository.
- Different management tools can be used to modify and retrieve the information model. These tools can be CLI, GUI as well as third-party tools.
- When the model is modified, device level agents take that modified information and update the physical and logical devices with the new state.
UCS Python SDK
To make UCS management easier, Cisco has provided a Python SDK library. The Python SDK library abstracts some of the low level details and provide simple APIs to manage UCS. It is easier to automate configuration and monitoring using the abstractions provided by the SDK. Following are some functionalities Python SDK provides:
- Handles setting up of connections with login details.
- Provides apis to get managed object based on classid or Distinguished name.
- Provides apis to add, set, remove, compare managed objects.
- Provides capability to watch MO events.
Getting started with UCS Python SDK
If you have access to UCS hardware which I have access to, you can try with it. Else you can use the UCS platform emulator which can be installed as a VM.
The easiest way to browse MO tree is using Visore browser based tool that UCS provides. To access the tool, type <ip/visore.html> in the browser. You will see the following main page where we can filter based on classid, Distinguished name, property.
Following is a sample output for classid “fabricLanCloud” or Distinguished name “fabric/lan”. The different rows we see are the properties associated with this managed object. 1 of the key properties we see here is Ethernet mode of the switch which it says as End-host.
Download SDK from here. I installed version 0.8.2 in my Ubuntu 12.04 using the following instructions mentioned in user guide.
python setup.py build sudo python setup.py install
There are some sample scripts present in the “samples” directory.
Using the sample scripts, I wrote a small application that can read and display basic properties of UCS device. The usecase for this script is that we have a bunch of UCS devices in our lab and to test out a particular scenario, we need a particular UCS system with specific configuration like cluster/stand-alone, software version, specific type of server etc. Instead of logging into each device and executing a bunch of commands to get this info, the script can automatically fetch this information. The script can be found in github.
To execute the script:
python getUcsProp.py -i <ip>-u <username>-p <password>
Output from the above script on a specific device:
hamode cluster ethmode end-host version 2.2(3a) fia-model UCS-FI-6248UP fib-model UCS-FI-6248UP chassis 1 model N20-C6508 server 1 model UCSB-B200-M3 server 2 model UCSB-B200-M3
The capability to manage a device through a script provides endless possibilities for the automation team.
For UCS sdk version 0.8.3, there is a change in default behavior where all MOs are not in single file and we either need to load individual module MOs are make an additional change to load all Modules. Above script modified for sdk version 0.8.3 is available here. (Thanks Amir for pointing out the issue)
Pictures used in the blog are from the references.