/** * Create search specification that searches for exact disk name. */ private HostDatastoreBrowserSearchSpec createHostDatastoreBrowserSearchSpecForDisk(String diskName) { VmDiskFileQueryFilter vdiskFilter = new VmDiskFileQueryFilter(); VmDiskFileQuery fQuery = new VmDiskFileQuery(); fQuery.setFilter(vdiskFilter); HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec(); searchSpec.getQuery().add(fQuery); FileQueryFlags flag = new FileQueryFlags(); flag.setFileOwner(true); flag.setFileSize(true); flag.setFileType(true); flag.setModification(true); searchSpec.setDetails(flag); searchSpec.getMatchPattern().add(diskName + ".vmdk"); return searchSpec; }