Blog Posts

Integrate VMware Infrastructure

March 25, 2009

The simplest definition of the term “virtualization” I could find:
“In computing, virtualization is a broad term that refers to the abstraction of computer resources”


The following introductory video sheds a bit more light on this subject:

To summarize, without virtualization an OS (Windows, Linux, Mac OS X, etc.) is tightly coupled to a computer’s hardware (PC, mainframe, etc.) and no other OS can run simultaneously on that same machine because it is already reserved by the OS. With virtualization a single computer can run multiple operating systems at the same time.

The idea of virtualization has been around for decades, pioneered by IBM [], but has become so popular and widely adopted only after VMware joined the game with its virtualization software products, one of which is VMware Virtual Infrastructure.

VMware Virtual Infrastructure is not just one product, but rather a group of products which when used collectively allow for managing the resources of whole infrastructures like a data center, for example, with hundreds of servers. The main components of VMware Virtual Infrastructure are:

  • VMware ESX
  • VMware vCenter Server
  • VI Client

Here is how these components fit together:

VMware ESX is at the bottom layer installed on each server in the managed infrastructure. Interestingly enough it is a whole operating system based on Red Hat Enterprise linux, but with modified kernel so that it can run multiple operating systems, called guests on top of the ESX server, called a host.

Next comes the VMware vCenter Server. This component is totally separate from the ESX server and runs on a separate computer. It is a Windows based server application. The purpose of the vCenter server is to manage multitude of ESX servers from one central point. For example, hardware resources like cpu and memory from different ESX servers could be combined into one virtual computing entity, i.e. a cluster, whose computational power could be adjusted on demand. This brings high availability and load balancing to your application, to name a few.

Last but not least comes VI Client. It is nothing more than a frontend for the vCenter server. It is the actual GUI application which enables the access to a vCenter server. It is also a Windows application, and it is currently not supported on other OS platforms. This is not so bad, because both vCenter and ESX servers support web services through which one can do almost everything which can be done through the VI Client. It is interesting that the VI Client does not use the web services, but a proprietary protocol to communicate
with the vCenter and ESX servers.

In case you want to integrate VMware Virtual Infrastructure or provide support for it in your application, here is how:

Prerequisites: Installed Java, vCenter and/or ESX servers.
Environment: Linux

First you need to download the VMware Infrastructure SDK from here. Click on the “VMware Infrastructure SDK” link and then on “Downloads”. You will need to register in order to download the SDK. Once you download the archive, extract it in a directory on your hard drive, here I use /bianor/vmware_sdk/. The archive contains documentation files, samples and most importantly, the WSDL definitions of the web services exposed by the vCenter and ESX servers. You can find more info about WSDL here.

Next step is to generate source code from the WSDL definitions. This is programming language specific and depending on your project the software you might need to use for this step could differ from the one used here – Apache Axis. If you do not have it installed you can get it from the Axis’s web site. Version 1.4 is used here, installed in /bianor/axis/.

To generate java source code from the WSDL definitions execute this in a shell terminal line by line or as a group from a shell script file (you will need to create one if you prefer this option):

# Define a few constants for clarity
export HOME="/bianor"
export AXIS_LIB_HOME="$HOME/axis/lib"
export AXIS_CLASSPATH="$AXIS_LIB_HOME/axis.jar:$AXIS_LIB_HOME/axis-ant.jar:$AXIS_LIB_HOME/commons-discovery-0.2.jar:$AXIS_LIB_HOME/commons-logging-1.0.4.jar:$AXIS_LIB_HOME/jaxrpc.jar:$AXIS_LIB_HOME/log4j-1.2.8.jar:$AXIS_LIB_HOME/saaj.jar:$AXIS_LIB_HOME/wsdl4j-1.5.1.jar"
export VMWARE_SDK_HOME="$HOME/vmware_sdk"

# The command which will generate the java source code from the wsdl definitions
# "--timeout -1" prevents " WSDL2Java emitter timed out (this often means the WSDL at the specified URL is inaccessible)!"
export WSDL2JAVA="java -cp &AXIS_CLASSPATH org.apache.axis.wsdl.WSDL2Java --timeout -1"

# The folder in $HOME must be previously created and containing the "vmware_sdk" and "axis" sub-folders
cd $HOME

# Version 2.5 of the API, you could also use version 2 in $VMWARE_SDK_HOME/wsdl/vim
$WSDL2JAVA -o $HOME/src $VMWARE_SDK_HOME/wsdl/vim25/vimService.wsdl

You should have the following folder hierarchy now:

  • /bianor
    • /src
    • /vim25
    • /vim25Service

We need to jar these two folders in order to use them as a library in a java project. This is done in the following way:

cd $HOME/src
jar -cvf vim25.jar .

Now we have the vim25.jar file. Actually a precompiled jar file comes by default with VMware’s SDK, but the steps above are just in case the stubs have to be created with another version of Axis or with another soap framework. What’s left is to include this jar and all libraries defined in AXIS_CLASSPATH variable shown above to the classpath of a java project and use it to connect and manage vCenter or ESX servers. Here’s an example from the SDK samples which creates a virtual machine on a remote ESX server:


Author: hristo.alexiev

Comments are closed.

Back to top
Have a question? Contact us
Bianor tweets See all tweets
Sitemap | Privacy policy | Copyright notice
©1998-2018, Bianor. All rights reserved.