use of com.cloud.dc.VsphereStoragePolicyVO in project cloudstack by apache.
the class ServiceOfferingJoinDaoImpl method newServiceOfferingResponse.
@Override
public ServiceOfferingResponse newServiceOfferingResponse(ServiceOfferingJoinVO offering) {
ServiceOfferingResponse offeringResponse = new ServiceOfferingResponse();
offeringResponse.setId(offering.getUuid());
offeringResponse.setName(offering.getName());
offeringResponse.setIsSystemOffering(offering.isSystemUse());
offeringResponse.setDefaultUse(offering.isDefaultUse());
offeringResponse.setSystemVmType(offering.getSystemVmType());
offeringResponse.setDisplayText(offering.getDisplayText());
offeringResponse.setProvisioningType(offering.getProvisioningType().toString());
offeringResponse.setCpuNumber(offering.getCpu());
offeringResponse.setCpuSpeed(offering.getSpeed());
offeringResponse.setMemory(offering.getRamSize());
offeringResponse.setCreated(offering.getCreated());
offeringResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
offeringResponse.setOfferHa(offering.isOfferHA());
offeringResponse.setLimitCpuUse(offering.isLimitCpuUse());
offeringResponse.setVolatileVm(offering.getVolatileVm());
offeringResponse.setTags(offering.getTags());
offeringResponse.setDomain(offering.getDomainName());
offeringResponse.setDomainId(offering.getDomainUuid());
offeringResponse.setZone(offering.getZoneName());
offeringResponse.setZoneId(offering.getZoneUuid());
offeringResponse.setNetworkRate(offering.getRateMbps());
offeringResponse.setHostTag(offering.getHostTag());
offeringResponse.setDeploymentPlanner(offering.getDeploymentPlanner());
offeringResponse.setCustomizedIops(offering.isCustomizedIops());
offeringResponse.setMinIops(offering.getMinIops());
offeringResponse.setMaxIops(offering.getMaxIops());
offeringResponse.setHypervisorSnapshotReserve(offering.getHypervisorSnapshotReserve());
offeringResponse.setBytesReadRate(offering.getBytesReadRate());
offeringResponse.setBytesReadRateMax(offering.getBytesReadRateMax());
offeringResponse.setBytesReadRateMaxLength(offering.getBytesReadRateMaxLength());
offeringResponse.setBytesWriteRate(offering.getBytesWriteRate());
offeringResponse.setBytesWriteRateMax(offering.getBytesWriteRateMax());
offeringResponse.setBytesWriteRateMaxLength(offering.getBytesWriteRateMaxLength());
offeringResponse.setIopsReadRate(offering.getIopsReadRate());
offeringResponse.setIopsReadRateMax(offering.getIopsReadRateMax());
offeringResponse.setIopsReadRateMaxLength(offering.getIopsReadRateMaxLength());
offeringResponse.setIopsWriteRate(offering.getIopsWriteRate());
offeringResponse.setIopsWriteRateMax(offering.getIopsWriteRateMax());
offeringResponse.setIopsWriteRateMaxLength(offering.getIopsWriteRateMaxLength());
Map<String, String> offeringDetails = ApiDBUtils.getResourceDetails(offering.getId(), ResourceObjectType.ServiceOffering);
offeringResponse.setDetails(offeringDetails);
offeringResponse.setObjectName("serviceoffering");
offeringResponse.setIscutomized(offering.isDynamic());
offeringResponse.setCacheMode(offering.getCacheMode());
offeringResponse.setDynamicScalingEnabled(offering.isDynamicScalingEnabled());
if (offeringDetails != null && !offeringDetails.isEmpty()) {
String vsphereStoragePolicyId = offeringDetails.get(ApiConstants.STORAGE_POLICY);
if (vsphereStoragePolicyId != null) {
VsphereStoragePolicyVO vsphereStoragePolicyVO = _vsphereStoragePolicyDao.findById(Long.parseLong(vsphereStoragePolicyId));
if (vsphereStoragePolicyVO != null)
offeringResponse.setVsphereStoragePolicy(vsphereStoragePolicyVO.getName());
}
}
long rootDiskSizeInGb = (long) offering.getRootDiskSize() / GB_TO_BYTES;
offeringResponse.setRootDiskSize(rootDiskSizeInGb);
offeringResponse.setDiskOfferingStrictness(offering.getDiskOfferingStrictness());
DiskOfferingVO diskOfferingVO = ApiDBUtils.findDiskOfferingById(offering.getDiskOfferingId());
if (diskOfferingVO != null) {
offeringResponse.setDiskOfferingId(offering.getDiskOfferingUuid());
offeringResponse.setDiskOfferingName(offering.getDiskOfferingName());
offeringResponse.setDiskOfferingDisplayText(offering.getDiskOfferingDisplayText());
}
offeringResponse.setHasAnnotation(annotationDao.hasAnnotations(offering.getUuid(), AnnotationService.EntityType.SERVICE_OFFERING.name(), accountManager.isRootAdmin(CallContext.current().getCallingAccount().getId())));
return offeringResponse;
}
use of com.cloud.dc.VsphereStoragePolicyVO in project cloudstack by apache.
the class VolumeObject method getvSphereStoragePolicyId.
public String getvSphereStoragePolicyId() {
if (StringUtils.isEmpty(vSphereStoragePolicyId)) {
String storagePolicyVOid = null;
if (Volume.Type.ROOT == getVolumeType()) {
Long vmId = volumeVO.getInstanceId();
if (vmId != null) {
VMInstanceVO vm = vmInstanceDao.findByIdIncludingRemoved(vmId);
storagePolicyVOid = serviceOfferingDetailsDao.getDetail(vm.getServiceOfferingId(), ApiConstants.STORAGE_POLICY);
}
} else {
storagePolicyVOid = diskOfferingDetailsDao.getDetail(volumeVO.getDiskOfferingId(), ApiConstants.STORAGE_POLICY);
}
if (storagePolicyVOid != null) {
VsphereStoragePolicyVO vsphereStoragePolicyVO = vsphereStoragePolicyDao.findById(Long.parseLong(storagePolicyVOid));
vSphereStoragePolicyId = vsphereStoragePolicyVO.getPolicyId();
}
}
return vSphereStoragePolicyId;
}
use of com.cloud.dc.VsphereStoragePolicyVO in project cloudstack by apache.
the class VmwareManagerImpl method listVsphereStoragePolicyCompatibleStoragePools.
@Override
public List<StoragePool> listVsphereStoragePolicyCompatibleStoragePools(ListVsphereStoragePolicyCompatiblePoolsCmd cmd) {
Long policyId = cmd.getPolicyId();
VsphereStoragePolicyVO storagePolicy = vsphereStoragePolicyDao.findById(policyId);
if (storagePolicy == null) {
throw new CloudRuntimeException("Storage policy with ID = " + policyId + " was not found");
}
long zoneId = storagePolicy.getZoneId();
List<StoragePoolVO> poolsInZone = primaryStorageDao.listByStatusInZone(zoneId, StoragePoolStatus.Up);
List<StoragePool> compatiblePools = new ArrayList<>();
for (StoragePoolVO pool : poolsInZone) {
StorageFilerTO storageFilerTO = new StorageFilerTO(pool);
List<Long> hostIds = storageManager.getUpHostsInPool(pool.getId());
if (CollectionUtils.isNullOrEmpty(hostIds)) {
s_logger.debug("Did not find a suitable host to verify compatibility of the pool " + pool.getName());
continue;
}
Collections.shuffle(hostIds);
CheckDataStoreStoragePolicyComplainceCommand command = new CheckDataStoreStoragePolicyComplainceCommand(storagePolicy.getPolicyId(), storageFilerTO);
long targetHostId = hypervisorGuruManager.getGuruProcessedCommandTargetHost(hostIds.get(0), command);
try {
Answer answer = _agentMgr.send(targetHostId, command);
boolean result = answer != null && answer.getResult();
if (result) {
compatiblePools.add(pool);
}
} catch (AgentUnavailableException | OperationTimedoutException e) {
s_logger.error("Could not verify if storage policy " + storagePolicy.getName() + " is compatible with storage pool " + pool.getName());
}
}
return compatiblePools;
}
use of com.cloud.dc.VsphereStoragePolicyVO in project cloudstack by apache.
the class DiskOfferingJoinDaoImpl method newDiskOfferingResponse.
@Override
public DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
DiskOfferingResponse diskOfferingResponse = new DiskOfferingResponse();
diskOfferingResponse.setId(offering.getUuid());
diskOfferingResponse.setName(offering.getName());
diskOfferingResponse.setDisplayText(offering.getDisplayText());
diskOfferingResponse.setProvisioningType(offering.getProvisioningType().toString());
diskOfferingResponse.setCreated(offering.getCreated());
diskOfferingResponse.setDiskSize(offering.getDiskSize() / (1024 * 1024 * 1024));
diskOfferingResponse.setMinIops(offering.getMinIops());
diskOfferingResponse.setMaxIops(offering.getMaxIops());
diskOfferingResponse.setDisplayOffering(offering.isDisplayOffering());
diskOfferingResponse.setDomainId(offering.getDomainUuid());
diskOfferingResponse.setDomain(offering.getDomainPath());
diskOfferingResponse.setZoneId(offering.getZoneUuid());
diskOfferingResponse.setZone(offering.getZoneName());
diskOfferingResponse.setHasAnnotation(annotationDao.hasAnnotations(offering.getUuid(), AnnotationService.EntityType.DISK_OFFERING.name(), accountManager.isRootAdmin(CallContext.current().getCallingAccount().getId())));
diskOfferingResponse.setTags(offering.getTags());
diskOfferingResponse.setCustomized(offering.isCustomized());
diskOfferingResponse.setCustomizedIops(offering.isCustomizedIops());
diskOfferingResponse.setHypervisorSnapshotReserve(offering.getHypervisorSnapshotReserve());
diskOfferingResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
diskOfferingResponse.setBytesReadRate(offering.getBytesReadRate());
diskOfferingResponse.setBytesReadRateMax(offering.getBytesReadRateMax());
diskOfferingResponse.setBytesReadRateMaxLength(offering.getBytesReadRateMaxLength());
diskOfferingResponse.setBytesWriteRate(offering.getBytesWriteRate());
diskOfferingResponse.setBytesWriteRateMax(offering.getBytesWriteRateMax());
diskOfferingResponse.setBytesWriteRateMaxLength(offering.getBytesWriteRateMaxLength());
diskOfferingResponse.setIopsReadRate(offering.getIopsReadRate());
diskOfferingResponse.setIopsReadRateMax(offering.getIopsReadRateMax());
diskOfferingResponse.setIopsReadRateMaxLength(offering.getIopsReadRateMaxLength());
diskOfferingResponse.setIopsWriteRate(offering.getIopsWriteRate());
diskOfferingResponse.setIopsWriteRateMax(offering.getIopsWriteRateMax());
diskOfferingResponse.setIopsWriteRateMaxLength(offering.getIopsWriteRateMaxLength());
diskOfferingResponse.setCacheMode(offering.getCacheMode());
diskOfferingResponse.setObjectName("diskoffering");
Map<String, String> offeringDetails = ApiDBUtils.getResourceDetails(offering.getId(), ResourceTag.ResourceObjectType.DiskOffering);
if (offeringDetails != null && !offeringDetails.isEmpty()) {
String vsphereStoragePolicyId = offeringDetails.get(ApiConstants.STORAGE_POLICY);
if (vsphereStoragePolicyId != null) {
VsphereStoragePolicyVO vsphereStoragePolicyVO = _vsphereStoragePolicyDao.findById(Long.parseLong(vsphereStoragePolicyId));
if (vsphereStoragePolicyVO != null)
diskOfferingResponse.setVsphereStoragePolicy(vsphereStoragePolicyVO.getName());
}
}
diskOfferingResponse.setDiskSizeStrictness(offering.getDiskSizeStrictness());
return diskOfferingResponse;
}
use of com.cloud.dc.VsphereStoragePolicyVO in project cloudstack by apache.
the class StorageManagerImpl method isStoragePoolCompliantWithStoragePolicy.
@Override
public boolean isStoragePoolCompliantWithStoragePolicy(List<Pair<Volume, DiskProfile>> volumes, StoragePool pool) throws StorageUnavailableException {
if (CollectionUtils.isEmpty(volumes)) {
return false;
}
List<Pair<Volume, Answer>> answers = new ArrayList<Pair<Volume, Answer>>();
for (Pair<Volume, DiskProfile> volumeDiskProfilePair : volumes) {
String storagePolicyId = null;
Volume volume = volumeDiskProfilePair.first();
DiskProfile diskProfile = volumeDiskProfilePair.second();
if (volume.getVolumeType() == Type.ROOT) {
Long vmId = volume.getInstanceId();
if (vmId != null) {
VMInstanceVO vm = _vmInstanceDao.findByIdIncludingRemoved(vmId);
storagePolicyId = _serviceOfferingDetailsDao.getDetail(vm.getServiceOfferingId(), ApiConstants.STORAGE_POLICY);
}
} else {
storagePolicyId = _diskOfferingDetailsDao.getDetail(diskProfile.getDiskOfferingId(), ApiConstants.STORAGE_POLICY);
}
if (StringUtils.isNotEmpty(storagePolicyId)) {
VsphereStoragePolicyVO storagePolicyVO = _vsphereStoragePolicyDao.findById(Long.parseLong(storagePolicyId));
List<Long> hostIds = getUpHostsInPool(pool.getId());
Collections.shuffle(hostIds);
if (hostIds == null || hostIds.isEmpty()) {
throw new StorageUnavailableException("Unable to send command to the pool " + pool.getName() + " due to there is no enabled hosts up in this cluster", pool.getId());
}
try {
StorageFilerTO storageFilerTO = new StorageFilerTO(pool);
CheckDataStoreStoragePolicyComplainceCommand cmd = new CheckDataStoreStoragePolicyComplainceCommand(storagePolicyVO.getPolicyId(), storageFilerTO);
long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(hostIds.get(0), cmd);
Answer answer = _agentMgr.send(targetHostId, cmd);
answers.add(new Pair<>(volume, answer));
} catch (AgentUnavailableException e) {
s_logger.debug("Unable to send storage pool command to " + pool + " via " + hostIds.get(0), e);
throw new StorageUnavailableException("Unable to send command to the pool ", pool.getId());
} catch (OperationTimedoutException e) {
s_logger.debug("Failed to process storage pool command to " + pool + " via " + hostIds.get(0), e);
throw new StorageUnavailableException("Failed to process storage command to the pool ", pool.getId());
}
}
}
// check cummilative result for all volumes
for (Pair<Volume, Answer> answer : answers) {
if (!answer.second().getResult()) {
s_logger.debug(String.format("Storage pool %s is not compliance with storage policy for volume %s", pool.getUuid(), answer.first().getName()));
return false;
}
}
return true;
}
Aggregations