use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.
the class BucketService method initiateBucketCreation.
private TaskResourceRep initiateBucketCreation(BucketParam param, Project project, TenantOrg tenant, DataObject.Flag[] flags) throws InternalException {
ArgValidator.checkFieldUriType(param.getVpool(), VirtualPool.class, "vpool");
ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
Integer retention = Integer.valueOf(param.getRetention());
// Hard Quota should be more than SoftQuota
verifyQuotaValues(softQuota, hardQuota, param.getLabel());
// check varray
VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, param.getVarray());
ArgValidator.checkEntity(neighborhood, param.getVarray(), false);
_permissionsHelper.checkTenantHasAccessToVirtualArray(tenant.getId(), neighborhood);
// check vpool reference
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, param.getVpool());
_permissionsHelper.checkTenantHasAccessToVirtualPool(tenant.getId(), vpool);
ArgValidator.checkEntity(vpool, param.getVpool(), false);
if (!VirtualPool.Type.object.name().equals(vpool.getType())) {
throw APIException.badRequests.virtualPoolNotForObjectStorage(VirtualPool.Type.object.name());
}
// verify retention. Its validated only if Retention is configured.
if (retention != 0 && vpool.getMaxRetention() != 0 && retention > vpool.getMaxRetention()) {
throw APIException.badRequests.insufficientRetentionForVirtualPool(vpool.getLabel(), "bucket");
}
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, Integer.valueOf(1));
capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.FALSE);
capabilities.put(VirtualPoolCapabilityValuesWrapper.QUOTA, hardQuota.toString());
Map<String, Object> attributeMap = new HashMap<String, Object>();
List<BucketRecommendation> placement = _bucketScheduler.placeBucket(neighborhood, vpool, capabilities, attributeMap);
if (placement.isEmpty()) {
StringBuffer errorMessage = new StringBuffer();
if (attributeMap.get(AttributeMatcher.ERROR_MESSAGE) != null) {
errorMessage = (StringBuffer) attributeMap.get(AttributeMatcher.ERROR_MESSAGE);
}
throw APIException.badRequests.noStoragePools(neighborhood.getLabel(), vpool.getLabel(), errorMessage.toString());
}
// Randomly select a recommended pool
Collections.shuffle(placement);
BucketRecommendation recommendation = placement.get(0);
String task = UUID.randomUUID().toString();
Bucket bucket = prepareBucket(param, project, tenant, neighborhood, vpool, flags, recommendation);
_log.info(String.format("createBucket --- Bucket: %1$s, StoragePool: %2$s, StorageSystem: %3$s", bucket.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.CREATE_BUCKET);
op.setDescription("Bucket Create");
// Controller invocation
StorageSystem system = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
ObjectController controller = getController(ObjectController.class, system.getSystemType());
controller.createBucket(recommendation.getSourceStorageSystem(), recommendation.getSourceStoragePool(), bucket.getId(), bucket.getName(), bucket.getNamespace(), bucket.getRetention(), bucket.getHardQuota(), bucket.getSoftQuota(), bucket.getOwner(), task);
auditOp(OperationTypeEnum.CREATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, param.getLabel(), param.getHardQuota(), neighborhood.getId().toString(), project == null ? null : project.getId().toString());
return toTask(bucket, task, op);
}
use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.
the class VPlexScheduler method getRecommendationsForPools.
/**
* Uses the block scheduler to get the placement recommendations.
*
* @param varrayId The virtual array id.
* @param vpool A reference to the virtual pool
* @param candidatePools The list of candidate pools.
* @param capabilities The virtual pool capabilities.
*
* @return The list of placement recommendations.
*/
private List<Recommendation> getRecommendationsForPools(String varrayId, VirtualPool vpool, List<StoragePool> candidatePools, VirtualPoolCapabilityValuesWrapper capabilities) {
VirtualPoolCapabilityValuesWrapper updatedCapabilities = capabilities;
if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
updatedCapabilities = new VirtualPoolCapabilityValuesWrapper(capabilities);
updatedCapabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.TRUE);
}
return _blockScheduler.getRecommendationsForPools(varrayId, candidatePools, updatedCapabilities);
}
use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method upgradeToMetroPointVolume.
/**
* Upgrade a local block volume to a protected RP volume
*
* @param volume the existing volume being protected.
* @param newVpool the requested virtual pool
* @param taskId the task identifier
* @throws InternalException
*/
private void upgradeToMetroPointVolume(Volume volume, VirtualPool newVpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
_log.info(String.format("Upgrade [%s] to MetroPoint", volume.getLabel()));
Project project = _dbClient.queryObject(Project.class, volume.getProject());
// Now that we have a handle on the current vpool, let's set the new vpool on the volume.
// The volume will not be persisted just yet but we need to have the new vpool to
// properly make placement decisions and to add reference to the new vpool to the
// recommendation objects that will be created.
URI currentVpool = volume.getVirtualPool();
volume.setVirtualPool(newVpool.getId());
List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, newVpool, vpoolChangeParam, null);
volume.setVirtualPool(currentVpool);
if (recommendations.isEmpty()) {
throw APIException.badRequests.noStorageFoundForVolume();
}
// Get the volume's varray
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
// Generate a VolumeCreate object that contains the information that createVolumes likes to consume.
VolumeCreate param = new VolumeCreate(volume.getLabel(), String.valueOf(volume.getCapacity()), 1, newVpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
TaskList taskList = new TaskList();
createTaskForVolume(volume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL, taskList, taskId);
Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
recommendationMap.put(VpoolUse.ROOT, recommendations);
createVolumes(param, project, varray, newVpool, recommendationMap, taskList, taskId, capabilities);
}
use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.
the class VPlexDeviceController method addStepsForImportClonesOfApplicationVolumes.
/**
* This method will add steps to import the clone of the source backend volumes,
* create clone VPlex virtual volumes
* create HA backend volume for clone virtual volume if distributed.
*
* @param workflow
* @param waitFor
* @param sourceVolumes
* @param opId
* @return
*/
public void addStepsForImportClonesOfApplicationVolumes(Workflow workflow, String waitFor, List<URI> sourceVolumes, String opId) {
_log.info("Creating steps for importing clones");
for (URI vplexSrcUri : sourceVolumes) {
Volume vplexSrcVolume = getDataObject(Volume.class, vplexSrcUri, _dbClient);
Volume backendSrc = VPlexUtil.getVPLEXBackendVolume(vplexSrcVolume, true, _dbClient);
long size = backendSrc.getProvisionedCapacity();
Volume backendHASrc = VPlexUtil.getVPLEXBackendVolume(vplexSrcVolume, false, _dbClient);
StringSet backSrcCopies = backendSrc.getFullCopies();
if (backSrcCopies != null && !backSrcCopies.isEmpty()) {
for (String copy : backSrcCopies) {
List<VolumeDescriptor> vplexVolumeDescriptors = new ArrayList<VolumeDescriptor>();
List<VolumeDescriptor> blockDescriptors = new ArrayList<VolumeDescriptor>();
Volume backCopy = getDataObject(Volume.class, URI.create(copy), _dbClient);
String name = backCopy.getLabel();
_log.info(String.format("Creating steps for import clone %s.", name));
VolumeDescriptor vplexCopyVolume = prepareVolumeDescriptor(vplexSrcVolume, name, VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, size, false);
Volume vplexCopy = getDataObject(Volume.class, vplexCopyVolume.getVolumeURI(), _dbClient);
vplexCopy.setAssociatedVolumes(new StringSet());
StringSet assVol = vplexCopy.getAssociatedVolumes();
if (null == assVol) {
assVol = new StringSet();
vplexCopy.setAssociatedVolumes(assVol);
}
assVol.add(backCopy.getId().toString());
VirtualPoolCapabilityValuesWrapper capabilities = getCapabilities(backCopy, size);
VolumeDescriptor backCopyDesc = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_IMPORT_VOLUME, backCopy.getStorageController(), backCopy.getId(), backCopy.getPool(), capabilities);
blockDescriptors.add(backCopyDesc);
if (backendHASrc != null) {
// distributed volume
name = name + "-ha";
VolumeDescriptor haDesc = prepareVolumeDescriptor(backendHASrc, name, VolumeDescriptor.Type.BLOCK_DATA, size, true);
blockDescriptors.add(haDesc);
assVol.add(haDesc.getVolumeURI().toString());
}
vplexCopy.setFullCopySetName(backCopy.getFullCopySetName());
vplexCopy.setAssociatedSourceVolume(vplexSrcUri);
StringSet srcClones = vplexSrcVolume.getFullCopies();
if (srcClones == null) {
srcClones = new StringSet();
}
srcClones.add(vplexCopy.getId().toString());
backCopy.setFullCopySetName(NullColumnValueGetter.getNullStr());
backCopy.addInternalFlags(Flag.INTERNAL_OBJECT);
_dbClient.updateObject(backCopy);
_dbClient.updateObject(vplexCopy);
_dbClient.updateObject(vplexSrcVolume);
vplexVolumeDescriptors.add(vplexCopyVolume);
createStepsForFullCopyImport(workflow, vplexSrcVolume.getStorageController(), vplexVolumeDescriptors, blockDescriptors, waitFor);
}
}
}
_log.info("Created workflow steps to import the backend full copies");
}
use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.
the class VPlexDeviceController method getCapabilities.
/**
* Create a VirtualPoolCapabilityValuesWrapper based on the passed in volume
*
* @param volume
* - The volume used to create the VirtualPoolCapabilityValuesWrapper.
* @param size
* @return
*/
private VirtualPoolCapabilityValuesWrapper getCapabilities(Volume volume, long size) {
URI vpoolUri = volume.getVirtualPool();
VirtualPool vpool = getDataObject(VirtualPool.class, vpoolUri, _dbClient);
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, size);
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.TRUE);
// To guarantee that storage pool for a copy has enough physical
// space to contain current allocated capacity of thin source volume
capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_VOLUME_PRE_ALLOCATE_SIZE, volume.getAllocatedCapacity());
}
return capabilities;
}
Aggregations