pages

Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Friday, September 21, 2012

WaveMaker - handling SSL certificates

In the past some people ask for the SSL certificate handling of WaveMaker. This is mostly caused by WebService integration. With my new vCO 5.1 appliance I had the problem again. After generating a new certificate for the vCenter Orchestrator here I connected the WaveMaker and had to learn a hard lesson: no more HTTP API connection with SOAP! Checking the cause in the browser I could see that there is always a HTTPS redirection :)















So I had to import the certificate of the vCenter Orchestrator like this:

sudo keytool -import -alias vco51.vcloud.lab -file /Users/cjohannsen/Desktop/vco51.vcloud.lab -storepass changeit -keystore /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/security/cacerts 

As you can see the WaveMaker uses the JDK certificate store. So I had to export the vCO certificate (i used Firefox) and import it in the certificate store. The store password is originally "changeit". After a WaveMaker restart I tried to connect the https path:

https://vco51.vcloud.lab:8281/vmware-vmo-webcontrol/webservice?wsdl

and everything was fine.










With this its really easy to access the SOAP API. Next post will show how to connect the REST API with WaveMaker :)

Wednesday, July 13, 2011

vCO - OUT-parameter serialization with JSON

Today I stumbled again delivering OUT-parameters with vCO. There is a main thing you have to know: vCO can´t serialize objects. So it isn´t easy to deliver key-paired values to external interfaces, cause if you use "Object" and "Any" as output you`ll get some errors.

Discussing this with some smart guys at the customer site they came up with a JSON description in the "Developers Guide" which is used for WebView. Typically I put all information in a nested Array/string to generate a machine readable output, but JSON could be an alternative.

I started searching with the API Explorer for "JSON" and I found one action:

  •  objectToJson (includes the "serialize" action)
what describes exactly what I want to do.

So here is a little example vm(VC:VirtualMachine) ist IN-Parameter, param(string) is OUT-parameter:

var Specs = new Object();

Specs["vmName"] = vm.name;
Specs["vmId"] = vm.id;
Specs["vmNumCpus"] = vm.summary.config.numCpu;
Specs["vmMemorySize"] = vm.summary.config.memorySizeMB; 
Specs["vmPowerState"] = vm.runtime.PowerState.value;
Specs["vmIpAddress"] = vm.guest.ipAddress;
Specs["vmMacAddress"] = NicObject.macAddress;
Specs["vmGuestHeartbeatStatus"] = vm.summary.quickStats.guestHeartbeatStatus.value;
Specs["vmGuestMemoryUsage"] = vm.summary.quickStats.guestMemoryUsage;
Specs["vmOverallCpuUsage"] = vm.summary.quickStats.overallCpuUsage;
Specs["vmUptime"] = vm.summary.quickStats.uptimeSeconds/3600;
for(i in vm.guest.disk){
if(vm.guest.disk.capacity != undefined){
System.log(vm.guest.disk.capacity);
Specs["vmDiskCapacity"] = vm.guest.disk.capacity;
}
else{
Specs["vmDiskCapacity"] = "undefined";
}
if(vm.guest.disk.freeSpace != undefined){
System.log(vm.guest.disk.freeSpace);
Specs["vmDiskFreeSpace"] = vm.guest.disk.freeSpace;
}
else{
Specs["vmDiskFreeSpace"] = "undefined";
}
}

param = System.getModule("com.vmware.web.webview").objectToJson(Specs) ;














The easiest way to validate the code is JSONlint (http://jsonlint.com). Please keep in mind that the JSON definition does not know "undefined" as type (http://en.wikipedia.org/wiki/JSON). So you need to catch it up and change it into a string or sort it out.

Hope this helps.

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