I connet to a virtual center and need get datastore ealier than hostSystem, and then list all of the host associated this datasore.
Take a look at this script for an example on how to accomplish this task: , you can connect to either a ESX(i) host or vCenter.
Regarding which hosts have access to the datastores, there is a property called DatastoreHostMount which is a available for each datastore that gives you an array of HostSystem that can access the datastore.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Take a look at this script for an example on how to accomplish this task: , you can connect to either a ESX(i) host or vCenter.
Regarding which hosts have access to the datastores, there is a property called DatastoreHostMount which is a available for each datastore that gives you an array of HostSystem that can access the datastore.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Actually, my question is how to get all the datastores in VC inventory.
I use vi java API as following
String[] s1 = {"VirtualMachine"};
String[] s2 = {"HostSystem"};
String[] s3 = {"Datastore"};
String[][] sArray = new String[][] { s1, s2, s3 };
//Array of Managed Entities
ManagedEntity[] me = new InventoryNavigator(mm.getConVmware().getRootFolder()).searchManagedEntities(sArray, true);
But it only returns ManagedEntity about HostSystem and vm. There isn't any datastore ManagedEntity in the inventory.
Thank you