VM Ware Automation

Problem this snippet solves:

VMware Automation via iControl


1.1. Presentation

People using VMWARE may need to replicate an instance in order to respond to an increase of traffic. The application we created will help the administrator to automatically handle that situation. The purpose of this document is to explain/present how to install the application. You can get the zip with the entire solution and source code here

1.2. How it works

This application will help the administrator to launch new vmware instance of an application when a CPU threshold is reached. Here is the method:

  1. The administrator create an instance of its application and configure one alarm to be triggered when the CPU is too high
  2. This alarm will trigger our application with the proper parameters
  3. Our application will check the name of the vmware instance and find a name for the new instance. It will have the following aspect: _. At the same time it will check for each name if a previous VM instance has been created and been shutdown. If yes it will power this one up instead of creating a new one (quicker)
  4. It will create a clone of this instance and power it up
  5. It will wait for the host system to be launched and we will retrieve the IP address of the new system
  6. We will connect to the BIGIP and insert the new pool members in the proper pool
  7. It will synchronize the configuration between the bigips in case we are in a redundant configuration

1.3. Syntax

Here is the syntax of the application:

Clone_Templatev2.exe < virtual center uri> < virtual center login> < virtual center passwd> \
< virtual_machine name > < datacenter> < bigip uri> < bigip login> < bigip passwd> < pool name> < service port>


< virtual center uri>: this is the uri to connect to the sdk of the virtual center: ex:
< virtual machine name>: name of the virtual machine that will be replicated
< datacenter name>: name of the datacenter where is located this virtual machine
< bigip uri>: this is the uri to connect to the iControl API. Ex:
< pool name>: name of the pool where we want to add the new pool member
< service port>: port number of the service we want to load balance for this new member.

1.4. Some information

Here is some information you need to be aware for this current version:

  • Creating a new instance takes some time !
  • When cloning a VMWARE instance, the alarm won’t be copied. It means that only the original instance will be able to call for additional instances. This makes more sense but it implies you need to ensure to have almost equal CPU consumption on each VMware instances with your load balancing configuration (average)
  • Right now it only adds VMware instances or powers it up. It is not able to remove automatically instances when CPU is really low in order to save CPU. If CPU is low on each VMWARE, the administrator can disable a pool member from the BIGIP GUI. When there is no more connection on a VMWARE instance it can shut it down. Next version will be able to check how many connections are on the instance to shut it down automatically.
  • To make it work you need to compile the source code with the icontrol and vmware dll. Or you’ll need to have the .exe file and the dlls in the same directory

2. Installation

2.1. Procedure

First thing will be to push our application on the VMware Virtual Center. We will consider that we pushed the application in c:\Vmware-iControl\ and the application name is Clone_template.exe

We need to configure our VMware instance with a new alarm (we will use Hackme instance in this example):

Then we set the custom action for this trigger. In our case it will be to execute the application. We type the following in the action:

Clonetemplatev2.exe administrator MyPassword Hackme LabFR admin admin pool_test  8080

You need to adapt the parameters to your environment!

Once the alarm is configured, the application is ready to be executed by the trigger. On the next screenshot you can see new vmware instances have been created:

Code :

# no snippet
Updated Jun 06, 2023
Version 2.0

Was this article helpful?

No CommentsBe the first to comment