use of com.vmware.vim25.mo.Datastore in project CloudStack-archive by CloudStack-extras.
the class ClusterMO method getDatastorePropertiesOnHyperHost.
@Override
public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.get_value() + ", properties: " + new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
pSpec.setPathSet(propertyPaths);
TraversalSpec cluster2DatastoreTraversal = new TraversalSpec();
cluster2DatastoreTraversal.setType("ClusterComputeResource");
cluster2DatastoreTraversal.setPath("datastore");
cluster2DatastoreTraversal.setName("cluster2DatastoreTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { cluster2DatastoreTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
ObjectContent[] properties = _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() done");
return properties;
}
use of com.vmware.vim25.mo.Datastore in project CloudStack-archive by CloudStack-extras.
the class ClusterMO method mountDatastore.
@Override
public ManagedObjectReference mountDatastore(boolean vmfsDatastore, String poolHostAddress, int poolHostPort, String poolPath, String poolUuid) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.get_value() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
ManagedObjectReference morDs = null;
ManagedObjectReference morDsFirst = null;
ManagedObjectReference[] hosts = (ManagedObjectReference[]) _context.getServiceUtil().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.length > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
morDs = hostMo.mountDatastore(vmfsDatastore, poolHostAddress, poolHostPort, poolPath, poolUuid);
if (morDsFirst == null)
morDsFirst = morDs;
// assume datastore is in scope of datacenter
assert (morDsFirst.get_value().equals(morDs.get_value()));
}
}
if (morDs == null) {
String msg = "Failed to mount datastore in all hosts within the cluster";
s_logger.error(msg);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - mountDatastore() done(failed)");
throw new Exception(msg);
}
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - mountDatastore() done(successfully)");
return morDs;
}
use of com.vmware.vim25.mo.Datastore in project CloudStack-archive by CloudStack-extras.
the class ClusterMO method importVmFromOVF.
@Override
public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.get_value() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", datastore: " + dsMo.getMor().get_value() + ", diskOption: " + diskOption);
ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
assert (morRp != null);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF(). resource pool: " + morRp.get_value());
HypervisorHostHelper.importVmFromOVF(this, ovfFilePath, vmName, dsMo, diskOption, morRp, null);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF() done");
}
use of com.vmware.vim25.mo.Datastore in project CloudStack-archive by CloudStack-extras.
the class DatacenterMO method getDatastorePropertiesOnDatacenter.
public ObjectContent[] getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
pSpec.setPathSet(propertyPaths);
TraversalSpec dc2DatastoreTraversal = new TraversalSpec();
dc2DatastoreTraversal.setType("Datacenter");
dc2DatastoreTraversal.setPath("datastore");
dc2DatastoreTraversal.setName("dc2DatastoreTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { dc2DatastoreTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
return _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
}
use of com.vmware.vim25.mo.Datastore in project CloudStack-archive by CloudStack-extras.
the class DatastoreMO method fileExists.
public boolean fileExists(String fileFullPath) throws Exception {
DatastoreFile file = new DatastoreFile(fileFullPath);
DatastoreFile dirFile = new DatastoreFile(file.getDatastoreName(), file.getDir());
HostDatastoreBrowserMO browserMo = getHostDatastoreBrowserMO();
s_logger.info("Search file " + file.getFileName() + " on " + dirFile.getPath());
HostDatastoreBrowserSearchResults results = browserMo.searchDatastore(dirFile.getPath(), file.getFileName(), true);
if (results != null) {
FileInfo[] info = results.getFile();
if (info != null && info.length > 0) {
s_logger.info("File " + fileFullPath + " exists on datastore");
return true;
}
}
s_logger.info("File " + fileFullPath + " does not exist on datastore");
return false;
/*
String[] fileNames = listDirContent(dirFile.getPath());
String fileName = file.getFileName();
for(String name : fileNames) {
if(name.equalsIgnoreCase(fileName))
return true;
}
return false;
*/
}
Aggregations