Cisco UCS Layout API


  This API was created for automated generation of UCS Rack Layout pictures. It can be used to incorporate UCS Layout images into other tools. And it overcomes the issue of the regular UCS Layout tool not having the capability to save configurations for later reuse.

To start you have to create an XML file describing your configuration. The configuration must be valid and "making sense". The API doesn't allow for "impossible" configurations or corner cases. As the interactive UCS Layout, this API tool runs in either automatic or manual mode. Here an example of the XML file for automatic mode configurations.
 


            <?xml version="1.0" encoding="UTF-8"?>

            <layout mode="AUTO" src="API">

                <fabint model="FI6248" qty="2">
                    <expmod model="E16UP" qty="0" />
                    <power qty="2" />
                </fabint>

                <chassis model="UCS5108" cfg="1" qty="3">
                    <blade model="B200" qty="2" />
                    <blade model="B250" qty="3" />
                    <iomod model="IOM2208" qty="2" />
                    <power qty="4" />
                </chassis>

                <fabext model="NX2232" qty="2" />

                <rackmount>
                    <server model="C240" qty="6" />
                    <server model="C460" qty="2" />
                </rackmount>

                <params extra="0" face="FRONT" fill="LINEAR" size="MEDIUM" trans="NO"/>

            </layout>

You can download api-auto.xml, which is the full version that tells you the do's and don'ts.


The XML file for manual mode configurations shouldn't give any surprises. If you want to add UCS chassis's to your racks, you've first to provide configurations for them.

Total number of racks can't be higher than nine, although the tool doesn't check for that. As said above, this API expect the user to provide "sensible" configurations.
 


            <?xml version="1.0" encoding="UTF-8"?>

            <layout mode="MANUAL" src="API">

                <chassis model="UCS5108" cfg="1" qty="1">
                    <blade model="B260" qty="2" />
                    <blade model="B460" qty="1" />
                    <iomod model="IOM2204" qty="2" />
                    <power qty="4" />
                </chassis>

                <rack cfg="1" qty="1">
                    <device model="NX5548" qty="2" />
                    <device model="FI6296" qty="2" />
                    <device model="UCS-CH1" qty="6" />
                </rack>

                <rack cfg="2" qty="3">
                    <device model="SPACE1" qty="4" />
                    <device model="NX2232" qty="2" />
                    <device model="C221" qty="6" />
                    <device model="C240" qty="6" />
                    <device model="C464" qty="4" />
                </rack>

                <params extra="0" face="FRONT" load="HIGH" panels="YES" size="SMALL" />

            </layout>

You can download api-manual.xml for the more complete version. In file api-devices.txt you can see the list of allowed device names.

To get started quickly you can also go into the rack layout tool, create a configuration using the GUI and then click the "Export" button. Use copy/paste to save the XML code into a file and use a text editor to modify the config to your liking. This is also the easiest way to create configs with odd quantities like 5, 11 or 20. When doing things this way it is best to clear the 4-digit number from the "seq" parameter in the second line of the XML.


Now you have to submit this file with a http POST to "http://ucs4.us/ucs/engine/ucs-engine.cgi". You can't simply let your browser do that. I had hoped that a simple wget command would do it, but for some reason that gives errors in combination with the XML parser.

There are a number of options for the client-side of things. This could be the beginning of adding UCS-Layout functionality – using the Rest API – to your own application.

  • This tiny shell script is using "curl" to post the XML file and then "wget" to grab the image. What I decided to do is not to have the server send the JPEG file, but just reply with an http "302 Moved" return code, which includes the location of the file. I think it is a more flexible option.
  • As a starting point for programmers, there is this Python script. After running the program you can use "eog" or "wget" with the returned URL to view or download the image. You can also extend the script itself.
  • Or, if that's your language of choice, you can pick the Perl variant. This one embeds the XML code in the source.
  • The last one is a Java program, incl. the class file. The default behaviour is to give you the "Moved=302" location, but with a single change in the source code it will return the image itself.

In case you want to create a wiring diagram instead of a rack layout, the only thing you need to do is to modify the script you use from accessing "http://ucs4.us/ucs/engine/ucs-wiring.cgi" instead of "ucs-engine.cgi".

Have fun with it. Happy hacking . . . .


API Auto  API Manual

auto & manual mode XML files