use of com.vmware.vim25.NasDatastoreInfo in project CloudStack-archive by CloudStack-extras.
the class HostDatastoreSystemMO method findDatastoreByExportPath.
// TODO this is a hacking helper method, when we can pass down storage pool info along with volume
// we should be able to find the datastore by name
public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception {
assert (exportPath != null);
ManagedObjectReference[] datastores = getDatastores();
if (datastores != null && datastores.length > 0) {
for (ManagedObjectReference morDatastore : datastores) {
DatastoreMO dsMo = new DatastoreMO(_context, morDatastore);
if (dsMo.getInventoryPath().equals(exportPath))
return morDatastore;
NasDatastoreInfo info = getNasDatastoreInfo(morDatastore);
if (info != null) {
String vmwareUrl = info.getUrl();
if (vmwareUrl.charAt(vmwareUrl.length() - 1) == '/')
vmwareUrl = vmwareUrl.substring(0, vmwareUrl.length() - 1);
URI uri = new URI(vmwareUrl);
if (uri.getPath().equals("/" + exportPath))
return morDatastore;
}
}
}
return null;
}
Aggregations