I'm creating an administrator extension, which is not associated with any context object. I want to show all the hosts and VMs running on those hosts as a tree. How can I retrieve this information using DAM?
Or you should be able to do something like this to retrieve a model for the list of vms in a host.
[Model(type="HostSystem")]
public class VmData extends DataObject {
[Model(relation="vm as VirtualMachine",
nestedModel="com.vmware.samples.viewspropertiesui.model.VmDataItem")]
[ArrayElementType("com.vmware.samples.viewspropertiesui.model.VmDataItem")]
public var vms:Array /*VmDataItem*/;
...
}
Hi hanish,
Yes it is possible to show all the hosts and VMs running on those hosts as a tree using dam. The only think which you need to do is write you own PropertyCollector.
For samples browse vsphere-client-sdk\samples\vsphereviews here you will get all the required information to build your own propertyCollector.
Thanks Vaibhav for the response. I want to display all the hosts and VMs in a new view. It's not associated with a contectObject. So why do I have to write a property collector?
To use DAM to retrieve a list of objects you need to have a root object reference and a property path according to the vSphere API (vSphere Management SDK) I don't think it's possible to retrieve all hosts and VMs with simple calls. Your best option is to write a simple Java service that does everything you need on the Java side with the same Management SDK.
Hi hanish,
it is not compulsory to pass context object for data collection.
Check this example vSphere Documentation Center
I'm able to retrieve list of host using 'DataByConstraintRequest'. The model I'm using is
[Model] |
public class HostSystemInfo extends DataObject {
[Model(property="name")] | |
public var hsName:String; | |
[Model(property="vm")] | |
public var vms:Array; |
}
But the problem is 'vms' array contains elements of type ServerObjectRef . Is it possible to get actual VM names or use my custom Model?
The documentation specifies about fetching data of multi-hop relationship ([Model(relation=”runtime.host,cluster”, property=”name”)]).
Will something of this sort would be useful?
See this sample for building more complex DAM queries to retrieve various vm properties for all vms of a host:
samples/vsphereviews/views-properties-ui/swf/src/main/flex/com/vmware/samples/viewspropertiesui/views/HostSampleMonitorViewMediator.as
Or you should be able to do something like this to retrieve a model for the list of vms in a host.
[Model(type="HostSystem")]
public class VmData extends DataObject {
[Model(relation="vm as VirtualMachine",
nestedModel="com.vmware.samples.viewspropertiesui.model.VmDataItem")]
[ArrayElementType("com.vmware.samples.viewspropertiesui.model.VmDataItem")]
public var vms:Array /*VmDataItem*/;
...
}
Thanks for the pointer. What I missed was the `nestedModel` property.
Thanks again!