Thursday, January 27, 2011

vCO - get all Distributed Virtual Switches

Yesterday i try to get all dvSwitches of a vCenter environment into an array. After several hours of searching and trying there is no easy way in my opinion. So i think this little workaround could help:

var dvPG = VcPlugin.getAllDistributedVirtualPortgroups();
var DVS = new Array(); 

for(i in dvPG){
   DVS.push(dvPG[i].config.distributedVirtualSwitch);
   DVS.sort();
   System.log("DVS vor Schleife: " + DVS);

   for ( i = 0; i < DVS.length; i++)
      {
      if(i != 0){
      while (DVS[i] == DVS[i-1])
      DVS.splice(i,1);
      }
   }
}

If you have other ways please feel free to publish them as a comment. Please note that you need at least one dvPortGroup!

Friday, January 21, 2011

vCO - Unzip Files with VMware Orchestrator workflow

To unzip files with vCO, e.g. patch bundles for ESX, there are some prerequisites.
  • vCO read / write access to source / target location (edit js-io-rights.conf)
  • min. 2 (v)CPU on vCO
  • vCO needs access to java.io.* and java.lang.Object (see post for how to)
This is a first full functional draft. There are some workarounds, because syntax / code is restricted in vCO.

Input parameters
  • ZipFileName - absolute path to ZIP file - e.g. C:/VCO/MyZip.zip
  • OutputPath - path for deflating content - e.g. C:/VCO/deflate/


Finding a solution for the used workarounds, I will update this post.

Feel free to leave comments or drop your questions.

Regards, Andreas

Thursday, January 20, 2011

vCO - Access to Java Classes

By default JavaScript in vCO is limited to class subtree java.util.* . Please read vCenter Orchestrator Administration Guide 4.1 on page 69 before changing default settings.
Why changing default settings? In my case I want to unzip bundles in an offline repository only with vCO, not using 3rd party tools. The ZipFile object is direct accessible, but some methods are derived from classes in java.io.* and java.lang.Object. So I have to loosen the default restrictions, described on Page 69.

Step1:

create a text file e.g MyShutter.txt with following content:

java.io.*
java.util.*
java.lang.Object


Save this file at <VCO-install-folder>\Orchestrator\app-server\bin\MyShutter.txt. This folder already exists.

Step 2:

Stop VCO-Server
Edit vmo.properties (look in ...\app-server\server\vmo\conf) and add following line:

com.vmware.scripting.rhino-class-shutter-file=MyShutter.txt

I've tried to use here an absolute path e.g. C:/VCO/MyShutter.txt (nothing was mentioned in documentation). You will get an error (server.log) like this if doing so:

2011-01-20 16:52:31.540+0100 ERROR [MainScriptingObject] Cannot find rhino js shutter class file at location : C:\Program Files\VMware\Orchestrator\app-server\bin\VCOMyShutter.txt

Step 3:

Start VCO-Server
Run an example using an object from new accessible classes.
Check server.log
If your example fails, check
  • server.log for above error - maybe the shutter file was not found
  • object naming - so you not using import the object must be fully qualified - e.g. ZipFile object qualifies as java.util.zip.ZipFile
Feel free to leave comments or drop your questions.

Regards, Andreas

Thursday, January 13, 2011

vCO - SOAP connect via VB .NET

Last week i try to build a Win32 application, based on the vCenter Orchestrator WSDL interface. In my case i try to develop an administrator interface which allows external administrators (external locations and so on) to start defined workflows with defined input parameters, like a vSphere Client for automation tasks.

After the successful evaluation i wrote the following instruction:

At first I install the newest version of Visual Studio 2010 Express Editions on my notebook and create a new Windows-Forms project. After the creation of an empty project you have to add a webservice reference, cause the vCenter Orchestrator WSDL interface is web-based. This is done by a right mouse click on the root folder of your project (in my case SOAPvCO).












In the sub-menu you will find an option called "Add Service Reference". After clicking the "Advanced" option and the WebService Reference button you can add the local WSDL path of your vCenter Orchestrator and rename it how you want it (in my case vCOref).








After the service reference is created all necessary methods and attributes are available in Visual Studio object browser. Now you can create a simple form in like this:














The basic elements are a textbox (multiline), a connect button (name=ButtonConnect) and an exit button (name=ButtonExit) to close the application. By doing a double click the connect button you will get the code window of the form. As you can see, the sub (ButtonConnect_Click) is created automatically. In this code window you have to create the following code (sorry for the screenshot, but only self-writing teaches!).


















In this simple example the connection parameters are asked with simple input boxes and written into string variables. The most important part is the declaration of "SOAP" as vCOref(our reference).VSOWebControlService(default class for new service) above the sub routines. With this definition above you can now use the "SOAP" constructor for the full form.

When debugging the project, the result should look like:













As you can see, the connection was successful and the number of workflow are shown. With this basic you can start to build up some stuff especially for your needs.

Feel free to ask any questions if you want to know more about the possibilities.