Duplicate VMware instance and add it to a pool
Problem this snippet solves:
The purpose of this windows binary is to duplicate an existing VMware instance and power it up. Once it is powered up, the application will add this new member in the proper pool. A config sync will be done after in case of a redundant system
If a copy of this instance already exists but is shut down(had been shut down manually by an admin for example), it will power it up instead (quicker)
Note: a clone of a VMware takes some time to be created and then we wait for the host system to have an IP Address to use for the pool member creation. So it's normal if it takes some time ^^
In order to compile this application you need the icontrol and vmware dll. It's included into my zip file in the bin/debug/ directory. If you don't compile your code with those dll you'll need to put them into the same directory than your binary in order to make it works.
The binary which is in bin/debug/Clone_template_Secure is compiled with those dlls.
Note2: It has been tested in one environnment and may need to be adapt depending on your Vmwares architecture (cluster/no cluster, etc...)
The best way to use this application is to create a new alarm for a VMWare instance that will execute this application with the proper parameter when CPU usage is above a specific value. Copies of this instance won't have this alarm so ensure to have a proper load balancing configuration!
Since we duplicate a VMWare instance, you should use DHCP for the IP address assignment or you'll create conflict. If the original instance has a fixed IP, then you should copy this one manually and then change its configuration to use DHCP. You'll configure the application with this instance.
Code :
Usage : Clone_template.exewhere: : this is the uri to connect to the sdk of the virtual center: ex: https://192.168.155.92/sdk/ : name of the virtual machine that will be replicated : name of the datacenter where is located this virtual machine : this is the uri to connect to the iControl API. Ex: 192.168.155.91 : name of the pool where we want to add the new pool member : port number of the service we want to load balance for this new member.