use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl method createVolumesAndDescriptors.
@Override
public List<VolumeDescriptor> createVolumesAndDescriptors(List<VolumeDescriptor> descriptors, String name, Long size, Project project, VirtualArray varray, VirtualPool vpool, List<Recommendation> recommendations, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) {
BlockServiceApi api = null;
List<VolumeDescriptor> volumeDescriptors = new ArrayList<VolumeDescriptor>();
for (Recommendation recommendation : recommendations) {
if (recommendation instanceof SRDFRecommendation || recommendation instanceof SRDFCopyRecommendation) {
api = BlockService.getBlockServiceImpl(DiscoveredDataObject.Type.srdf.name());
} else if (recommendation instanceof VolumeRecommendation) {
api = BlockService.getBlockServiceImpl(BlockServiceApi.DEFAULT);
} else {
String message = String.format("No BlockServiceApiImpl to handle recommendation of class: ", recommendation.getClass().getName());
s_logger.error(message);
throw WorkflowException.exceptions.workflowConstructionError(message);
}
volumeDescriptors.addAll(api.createVolumesAndDescriptors(descriptors, name, size, project, varray, vpool, recommendations, taskList, task, vpoolCapabilities));
}
return volumeDescriptors;
}
use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.
the class VPlexBlockServiceApiImpl method prepareVolume.
/**
* Prepare a new Bourne Volume.
*
* @param volume pre-created volume (optional)
* @param size The volume capacity.
* @param thinVolumePreAllocationSize preallocation size for thin provisioning or 0.
* @param project A reference to the project.
* @param vArray A reference to the virtual array
* @param vPool The requested virtual pool.
* @param storageSystemURI The URI of the storage system.
* @param storagePoolURI The URI of the storage pool.
* @param label The label for the new volume.
* @param consistencyGroup The consistency group.
* @param capabilities The virtual pool capabilities
*
* @return A reference to the newly persisted Volume.
*/
private Volume prepareVolume(VolumeType volType, Volume volume, long size, long thinVolumePreAllocationSize, Project project, VirtualArray vArray, VirtualPool vPool, URI storageSystemURI, URI storagePoolURI, String label, BlockConsistencyGroup consistencyGroup, VirtualPoolCapabilityValuesWrapper capabilities) {
// Encapsulate the storage system and storage pool in a
// volume recommendation and use the default implementation.
VolumeRecommendation volRecomendation = new VolumeRecommendation(volType, size, vPool, vArray.getId());
volRecomendation.addStorageSystem(storageSystemURI);
volRecomendation.addStoragePool(storagePoolURI);
volume = StorageScheduler.prepareVolume(_dbClient, volume, size, thinVolumePreAllocationSize, project, vArray, vPool, volRecomendation, label, consistencyGroup, capabilities);
// For VPLEX volumes, the protocol will not be set when the
// storage scheduler is invoked to prepare the volume because
// there is no storage pool associated with the volume. So, set
// it to FC here.
StringSet protocols = new StringSet();
protocols.add(StorageProtocol.Block.FC.name());
volume.setProtocol(protocols);
_dbClient.updateObject(volume);
return volume;
}
use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.
the class DefaultBlockFullCopyApiImpl method create.
/**
* {@inheritDoc}
*/
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
// Get the placement recommendations for the full copies and
// prepare the ViPR volumes to represent the full copies.
// TBD We are getting recommendations one at a time instead
// of for all full copies at the same time as was done
// previously. However, now we are allowing for creating
// full copies for multiple volume form a CG. These volumes
// could have different vpools and sizes. Therefore, I don't
// see how we can get them at the same time for all volumes
// as the capabilities could be different. I guess the
// possible result is that if the volumes are the same, they
// could be placed in the same storage pool and if the pool
// is approaching capacity, there may not actually be enough
// space in the recommended pool.
int sourceCounter = 0;
List<Volume> volumesList = new ArrayList<Volume>();
BlockObject aFCSource = null;
Map<URI, VirtualArray> vArrayCache = new HashMap<URI, VirtualArray>();
List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
try {
for (BlockObject fcSourceObj : sortedSourceObjectList) {
// Make sure when there are multiple source objects,
// each full copy has a unique name.
aFCSource = fcSourceObj;
// volumes in VolumeGroup can be from different vArrays
varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
String copyName = null;
boolean inApplication = false;
if (aFCSource instanceof Volume && ((Volume) aFCSource).getApplication(_dbClient) != null) {
inApplication = true;
}
if (NullColumnValueGetter.isNotNullValue(fcSourceObj.getReplicationGroupInstance()) && inApplication) {
copyName = name + "-" + fcSourceObj.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
} else {
copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
}
VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
List<VolumeRecommendation> placementRecommendations = getPlacementRecommendations(fcSourceObj, capabilities, varray, vpool.getId());
volumesList.addAll(prepareClonesForEachRecommendation(copyName, name, fcSourceObj, capabilities, createInactive, placementRecommendations));
}
} catch (Exception ex) {
handlePlacementFailure(volumesList);
throw ex;
}
// get volume descriptors
List<VolumeDescriptor> volumeDescriptors = prepareVolumeDescriptorsForFullCopy(volumesList, createInactive);
// get all tasks
TaskList tasks = getTasksForCreateFullCopy(aFCSource, volumesList, taskId);
try {
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
controller.createFullCopy(volumeDescriptors, taskId);
} catch (InternalException ie) {
handleFailedRequest(taskId, tasks, volumesList, ie, true);
}
return tasks;
}
use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.
the class DefaultBlockFullCopyApiImpl method prepareClonesForEachRecommendation.
/**
* Prepares a ViPR volume instance for each full copy.
*
* @param name The full copy name.
* @param cloneSetName
* @param blockObject The full copy source.
* @param capabilities The full copy capabilities.
* @param createInactive true to create the full copies inactive, false otherwise.
* @param placementRecommendations The placement recommendation for each full copy.
*
* @return A list of volumes representing the full copies.
*/
private List<Volume> prepareClonesForEachRecommendation(String name, String cloneSetName, BlockObject blockObject, VirtualPoolCapabilityValuesWrapper capabilities, Boolean createInactive, List<VolumeRecommendation> placementRecommendations) {
// Prepare clones for each recommendation
List<Volume> volumesList = new ArrayList<Volume>();
List<Volume> toUpdate = new ArrayList<Volume>();
boolean inApplication = false;
if (blockObject instanceof Volume && ((Volume) blockObject).getApplication(_dbClient) != null) {
inApplication = true;
}
int volumeCounter = (capabilities.getResourceCount() > 1) ? 1 : 0;
for (VolumeRecommendation recommendation : placementRecommendations) {
Volume volume = StorageScheduler.prepareFullCopyVolume(_dbClient, name, blockObject, recommendation, volumeCounter, capabilities, createInactive);
// For Application, set the user provided clone name on all the clones to identify clone set
if (inApplication) {
volume.setFullCopySetName(cloneSetName);
toUpdate.add(volume);
}
volumesList.add(volume);
// set volume Id in the recommendation
recommendation.setId(volume.getId());
volumeCounter++;
}
// persist changes
if (!toUpdate.isEmpty()) {
_dbClient.updateObject(toUpdate);
}
return volumesList;
}
use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.
the class DefaultBlockFullCopyApiImpl method getPlacementRecommendations.
/**
* Get the placement recommendations for the passed full copy source.
*
* @param blockObject A reference to the full copy source.
* @param capabilities Encapsulates the copy capabilities
* @param varray A reference to the virtual array.
* @param vpoolURI The URI of the virtual pool for the source.
*
* @return A list of volume placement recommendations.
*/
private List<VolumeRecommendation> getPlacementRecommendations(BlockObject blockObject, VirtualPoolCapabilityValuesWrapper capabilities, VirtualArray varray, URI vpoolURI) {
// Find placement for block volume copies
VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
List<VolumeRecommendation> placementRecommendations = ((StorageScheduler) _scheduler).getRecommendationsForVolumeClones(varray, vPool, blockObject, capabilities);
if (placementRecommendations.isEmpty()) {
throw APIException.badRequests.invalidParameterNoStorageFoundForVolume(varray.getId(), vPool.getId(), blockObject.getId());
}
return placementRecommendations;
}
Aggregations