VMware {code} Community
tqll
Contributor
Contributor
Jump to solution

how can i get datastore earlier than hostSystem

I connet to a virtual center and need get datastore ealier than hostSystem, and then list all of the host associated this datasore.

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

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

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
2 Replies
lamw
Community Manager
Community Manager
Jump to solution

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

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
tqll
Contributor
Contributor
Jump to solution

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

0 Kudos