Afaik I'm only allowed to call QueryChangedDiskAreas with a "*" on files residing on vmfs datastores. How do I determine the filesystem of the datastore programatically?
In the vsphere Client if you slect the ESxi Host -> configuration -> storage > their is a field called "Type" , it will tell you if datastore is vmfs or nfs.
You can get file system details@datastore from vSphere API data object " DatastoreSummary". This data object has one property called "type". Once you retrieve this property you can know what is the type of file system that datastore is created of.
Refer: vSphere 5.5 Documentation Center
I read about the DataStoreSummary before. In this thread https://communities.vmware.com/thread/486158 , togtog says I can access it programmatically by
VirtualDisk.backing(VirtualDeviceFileBackingInfo).datastore.summary.type = vmfs | nfs | cifs | vfat
But looking at my backinginfo values, I don't have a datastore.summary. I have a datastore value and a type. Bu ttype is only "Datastore" all the time. Where do I get this summary from programmatically ?
You will have to play with Managed object "Datastore". Once you create instance of Datastore managed object, "datastoreSummary is one of properties of "Datastore".
Here is one code snippet which can solve your problem: (Refereed from VIJAVA project)
package com.vmware.vim25.mo.samples.storage;
import java.net.URL;
import com.vmware.vim25.ArrayOfHostDatastoreBrowserSearchResults;
import com.vmware.vim25.DatastoreInfo;
import com.vmware.vim25.FileInfo;
import com.vmware.vim25.FileQuery;
import com.vmware.vim25.FileQueryFlags;
import com.vmware.vim25.HostDatastoreBrowserSearchResults;
import com.vmware.vim25.HostDatastoreBrowserSearchSpec;
import com.vmware.vim25.VmDiskFileInfo;
import com.vmware.vim25.VmDiskFileQuery;
import com.vmware.vim25.mo.Datastore;
import com.vmware.vim25.mo.Folder;
import com.vmware.vim25.mo.HostDatastoreBrowser;
import com.vmware.vim25.mo.HostSystem;
import com.vmware.vim25.mo.InventoryNavigator;
import com.vmware.vim25.mo.ServiceInstance;
import com.vmware.vim25.mo.Task;
public class SearchDatastore
{
public static void main(String[] args) throws Exception
{
if(args.length != 3)
{
System.out.println("Usage: java SearchDatastore <url> "
+ "<username> <password>");
return;
}
ServiceInstance si = new ServiceInstance(
new URL(args[0]), args[1], args[2], true);
// you need to send 3 parameters, vcip/username/password
String hostname = "<HOST IP>";
Folder rootFolder = si.getRootFolder();
HostSystem host = null;
host = (HostSystem) new InventoryNavigator(
rootFolder).searchManagedEntity("HostSystem", hostname);
if(host==null)
{
System.out.println("Host not found");
si.getServerConnection().logout();
return;
}
HostDatastoreBrowser hdb = host.getDatastoreBrowser();
System.out.println("print out the names of the datastores");
Datastore[] ds = hdb.getDatastores();
//From above line, you got all the datastore those can be browsed from a particular host
//Below loop, you can get all the properties from all datastores.
for(int i=0; ds!=null && i<ds.length; i++)
{
System.out.println("datastore["+i+"]:");
String datastoreType = ds.getDatastoreSummary().getDatastoreType();
}
}
Notes:
1. String datastoreType = ds.getDatastoreSummary().getDatastoreType(); can give you whatever you want.
2. This code snippet I have not tested, plz make changes as per your requirement.
3. Refer complete code snippet here: http://sourceforge.net/p/vijava/code/HEAD/tree/v5.1/src/com/vmware/vim25/mo/samples/storage/SearchDa...
4. VIJAVA getting started : Get Started Tutorial
On Monday, I will test this code in my environment. Let me know if you need any help on this.
Is this available in .net as well somehow? My datastores don't seem to have a getDatastoreType() . They only have a Value and a type.
As per https://www.vmware.com/support/developer/windowstoolkit/wintk40/doc/viwin_devg.pdf this Dev guide on .Net. vSphere APIs can be leveraged by using .Net.
If you could convert above code snippet in .Net as it is, it should work fine. Above code is totally based on java. If you are OK, I will help you on setting up java VIJAVA environment in eclipse. As I completely work on Java/PowerCLI, I do not have experience on .Net.
Here are some other links for self-service support:
Product information—http://www.vmware.com/products/
Developer Center—http://www.vmware.com/communities/content/developer
Documentation—http://www.vmware.com/support/pubs
Knowledge Base—http://kb.vmware.com
User groups—http://www.vmware.com/communities/content/vmug/index.html
Developer Community—http://communities.vmware.com/community/developer