VMware {code} Community
tqbeibei
Contributor
Contributor

how to use method SearchDatastore_Task from HostDatastoreBrowser (update)

ManagedObjectReference HostDatastoreBrowser = (ManagedObjectReference)_mm.getConVmware().getServiceUtil().getDynamicProperty(mor_Entity, "datastoreBrowser");

I get HostDatastoreBrowser view from about statement, but it's Managed Object Type is ManagedObjectReference. (Here mor_Entity is is HostSystem view)

Since the HostDatastoreBrowser's Managed Object Type is ManagedObjectReference, I cannot see SearchDatastore_Task method from eclipse. (generally, eclipse will list all of the methods for a object by follwing a ".")

Now how can i use the methods. or how can i change HostDatastoreBrowser's Managed Object Type from ManagedObjectReference to HostDatastoreBrowser ?

Actually, the question is:

How can i get a Managed Object Type, which is returned by a method?

Thank you

0 Kudos
3 Replies
Steve_Jin
Expert
Expert

1. VI SDK does not have managed object TYPE exposed. All the managed objects are represented by ManagedObjectReference type.

2. VI Java API recreates the managed objects so you can use them and type . to see all the methods attached to the type.

3. To convert from ManagedObjectReference to a managed object type like VirtualMachine, you can call one line:

ManagedEntity me = MorUtil.createExactManagedEntity(si.getServerConnection(), mor);

or ManagedObject mo = MorUtil.createExactManagedObject(si.getServerConnection(), mor);

The mor is a ManagedObjectReference object.

To download, check my signature below.

Steve JIN, VMware Engineering

Creator of VMware Infrastructure Java API. VI Java API 2.0 --- 15 times faster than AXIS in loading, 4+ faster in deserialization; only 1/4 of the size required by AXIS. More importantly, the freedom to redistribute your applications. (Download, Samples, DocWiki, RSS Feed)

Get Connected with Other Developers in the Community?

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
admin
Immortal
Immortal

Also see VI SDK for Java.

VI SDK for Java completely resolves this issue by hiding ManagedObjectReference type in the API.

It provides a true object-oriented model with all ManagedObject types.

http://communities.vmware.com/community/developer/java_toolkit

core API and toolkits team

0 Kudos
tqbeibei
Contributor
Contributor

thank you. I download the jar, vijava2b120090307src.jar, it works now.

0 Kudos