use of com.vmware.vim25.NasDatastoreInfo in project CloudStack-archive by CloudStack-extras.
the class ClusterMO method findDatastoreByExportPath.
@Override
public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath(). target MOR: " + _mor.get_value() + ", exportPath: " + exportPath);
ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] { "info" });
if (ocs != null && ocs.length > 0) {
for (ObjectContent oc : ocs) {
DatastoreInfo dsInfo = (DatastoreInfo) oc.getPropSet(0).getVal();
if (dsInfo != null && dsInfo instanceof NasDatastoreInfo) {
NasDatastoreInfo info = (NasDatastoreInfo) dsInfo;
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)) {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath() done(successfully)");
return oc.getObj();
}
}
}
}
}
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath() done(failed)");
return null;
}
use of com.vmware.vim25.NasDatastoreInfo in project CloudStack-archive by CloudStack-extras.
the class HostDatastoreSystemMO method findDatastoreByUrl.
// storeUrl in nfs://host/exportpath format
public ManagedObjectReference findDatastoreByUrl(String storeUrl) throws Exception {
assert (storeUrl != null);
ManagedObjectReference[] datastores = getDatastores();
if (datastores != null && datastores.length > 0) {
for (ManagedObjectReference morDatastore : datastores) {
NasDatastoreInfo info = getNasDatastoreInfo(morDatastore);
if (info != null) {
URI uri = new URI(storeUrl);
String vmwareStyleUrl = "netfs://" + uri.getHost() + "/" + uri.getPath() + "/";
if (info.getUrl().equals(vmwareStyleUrl))
return morDatastore;
}
}
}
return null;
}
use of com.vmware.vim25.NasDatastoreInfo in project cloudstack by apache.
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);
List<ManagedObjectReference> datastores = getDatastores();
if (datastores != null && datastores.size() > 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;
}
use of com.vmware.vim25.NasDatastoreInfo in project cloudstack by apache.
the class HostDatastoreSystemMO method findDatastoreByUrl.
// storeUrl in nfs://host/exportpath format
public ManagedObjectReference findDatastoreByUrl(String storeUrl) throws Exception {
assert (storeUrl != null);
List<ManagedObjectReference> datastores = getDatastores();
if (datastores != null && datastores.size() > 0) {
for (ManagedObjectReference morDatastore : datastores) {
NasDatastoreInfo info = getNasDatastoreInfo(morDatastore);
if (info != null) {
URI uri = new URI(storeUrl);
String vmwareStyleUrl = "netfs://" + uri.getHost() + "/" + uri.getPath() + "/";
if (info.getUrl().equals(vmwareStyleUrl))
return morDatastore;
}
}
}
return null;
}
use of com.vmware.vim25.NasDatastoreInfo in project cloudstack by apache.
the class ClusterMO method findDatastoreByExportPath.
@Override
public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath(). target MOR: " + _mor.getValue() + ", exportPath: " + exportPath);
ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] { "info" });
if (ocs != null && ocs.length > 0) {
for (ObjectContent oc : ocs) {
DatastoreInfo dsInfo = (DatastoreInfo) oc.getPropSet().get(0).getVal();
if (dsInfo != null && dsInfo instanceof NasDatastoreInfo) {
NasDatastoreInfo info = (NasDatastoreInfo) dsInfo;
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)) {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath() done(successfully)");
return oc.getObj();
}
}
}
}
}
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath() done(failed)");
return null;
}
Aggregations