So, here's what the VCO 4.1 developer's guide says about accessing java classes from Orchestrator's javascript...
h5. Accessing Java Classes from JavaScript
By default, Orchestrator restricts JavaScript access to a limited set of Java classes. If you require JavaScript
access to a wider range of Java classes, you must set an Orchestrator system property to allow this access.
By default, the Orchestrator JavaScript engine can access only the classes in the java.util.* package.
The Orchestrator administrator can allow access to other Java classes from JavaScript functions by setting a
system property. See the VMware vCenter Orchestrator Administration Guide for information about setting system
properties.
(http://vmware.ie/pdf/vco_410_developers_guide.pdf, pp. 115).
This is less-than helpful as it doesn't actually say how to use java classes from javascript.
After following the instructions for access java classes from javascript in the VCO administrator's guide (http://vmware.ie/pdf/vco_410_admin_guide.pdf, pp. 67) I am still unable to use standard java classes. Does anyone have any examples of how to do this? I've tried "inetAddress = java.net.InetAddress.getByName(serverAddress);" and I get the error "TypeError: getByName is not a function, it is org.mozilla.javascript.NativeJavaPackage." I've also tried using Rhino's importPackage function and it doesn't seem to be recognized.
For the java example try:
var baseAddress = java.net.InetAddress.getByName(serverAddress);
var name = baseAddress.getHostName();
If you want to do just this it is not necessary to use java. You can do like this:
var name = System.resolveIpAddress(serverAddress);
Christophe.
hi Christophe,
I got exactly same problem here. when I call
var url = java.net.url("http://www.google.com");
var con = url.openConnection();
I got the TypeError: Cannot find function openConnection.
also any idea about how can I convert java class type in orchestrator? like url.openConnection will return URLConnection, but I want to convert it to HTTPURLConnection.
Thanks,
Hi!
Have you tried to use a shutter-file to allow vCO to access the Java-Classes?
See some examples here:
http://mighty-virtualization.blogspot.com/2011/01/vco-access-to-java-classes.html
Regards,
Joerg
I did. but just java.net.URL class is not working, because Orchestartor also offer another URL class, blocking me to use the orignal Java class.
I'm facing exactly the same issue. java.net.URL object is somehow automatically "switched" to Orchestrator's URL.
Have you found some workaround?
