use of com.cloud.agent.api.GetStoragePoolCapabilitiesAnswer in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(GetStoragePoolCapabilitiesCommand cmd) {
try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
HostMO host = (HostMO) hyperHost;
StorageFilerTO pool = cmd.getPool();
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
if (morDatastore == null) {
morDatastore = hyperHost.mountDatastore((pool.getType() == StoragePoolType.VMFS || pool.getType() == StoragePoolType.PreSetup || pool.getType() == StoragePoolType.DatastoreCluster), pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""), true);
}
assert (morDatastore != null);
DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDatastore);
GetStoragePoolCapabilitiesAnswer answer = new GetStoragePoolCapabilitiesAnswer(cmd);
boolean hardwareAccelerationSupportForDataStore = getHardwareAccelerationSupportForDataStore(host.getMor(), dsMo.getName());
Map<String, String> poolDetails = answer.getPoolDetails();
poolDetails.put(Storage.Capability.HARDWARE_ACCELERATION.toString(), String.valueOf(hardwareAccelerationSupportForDataStore));
answer.setPoolDetails(poolDetails);
answer.setResult(true);
return answer;
} catch (Throwable e) {
GetStoragePoolCapabilitiesAnswer answer = new GetStoragePoolCapabilitiesAnswer(cmd);
answer.setResult(false);
answer.setDetails(createLogMessageException(e, cmd));
return answer;
}
}
use of com.cloud.agent.api.GetStoragePoolCapabilitiesAnswer in project cloudstack by apache.
the class StorageManagerImpl method updateStorageCapabilities.
/**
* @param poolId - Storage pool id for pool to update.
* @param failOnChecks - If true, throw an error if pool type and state checks fail.
*/
@Override
public void updateStorageCapabilities(Long poolId, boolean failOnChecks) {
StoragePoolVO pool = _storagePoolDao.findById(poolId);
if (pool == null) {
throw new CloudRuntimeException("Primary storage not found for id: " + poolId);
}
// Only checking NFS for now - required for disk provisioning type support for vmware.
if (pool.getPoolType() != StoragePoolType.NetworkFilesystem) {
if (failOnChecks) {
throw new CloudRuntimeException("Storage capabilities update only supported on NFS storage mounted.");
}
return;
}
if (pool.getStatus() != StoragePoolStatus.Initialized && pool.getStatus() != StoragePoolStatus.Up) {
if (failOnChecks) {
throw new CloudRuntimeException("Primary storage is not in the right state to update capabilities");
}
return;
}
HypervisorType hypervisor = pool.getHypervisor();
if (hypervisor == null) {
if (pool.getClusterId() != null) {
ClusterVO cluster = _clusterDao.findById(pool.getClusterId());
hypervisor = cluster.getHypervisorType();
}
}
if (!HypervisorType.VMware.equals(hypervisor)) {
if (failOnChecks) {
throw new CloudRuntimeException("Storage capabilities update only supported on VMWare.");
}
return;
}
// find the host
List<Long> poolIds = new ArrayList<Long>();
poolIds.add(pool.getId());
List<Long> hosts = _storagePoolHostDao.findHostsConnectedToPools(poolIds);
if (hosts.size() > 0) {
GetStoragePoolCapabilitiesCommand cmd = new GetStoragePoolCapabilitiesCommand();
cmd.setPool(new StorageFilerTO(pool));
GetStoragePoolCapabilitiesAnswer answer = (GetStoragePoolCapabilitiesAnswer) _agentMgr.easySend(hosts.get(0), cmd);
if (answer.getPoolDetails() != null && answer.getPoolDetails().containsKey(Storage.Capability.HARDWARE_ACCELERATION.toString())) {
StoragePoolDetailVO hardwareAccelerationSupported = _storagePoolDetailsDao.findDetail(pool.getId(), Storage.Capability.HARDWARE_ACCELERATION.toString());
if (hardwareAccelerationSupported == null) {
StoragePoolDetailVO storagePoolDetailVO = new StoragePoolDetailVO(pool.getId(), Storage.Capability.HARDWARE_ACCELERATION.toString(), answer.getPoolDetails().get(Storage.Capability.HARDWARE_ACCELERATION.toString()), false);
_storagePoolDetailsDao.persist(storagePoolDetailVO);
} else {
hardwareAccelerationSupported.setValue(answer.getPoolDetails().get(Storage.Capability.HARDWARE_ACCELERATION.toString()));
_storagePoolDetailsDao.update(hardwareAccelerationSupported.getId(), hardwareAccelerationSupported);
}
} else {
if (answer != null && !answer.getResult()) {
s_logger.error("Failed to update storage pool capabilities: " + answer.getDetails());
if (failOnChecks) {
throw new CloudRuntimeException(answer.getDetails());
}
}
}
}
}
Aggregations