use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class DefaultBlockServiceApiImpl method createVolumes.
@Override
public TaskList createVolumes(VolumeCreate param, Project project, VirtualArray neighborhood, VirtualPool cos, Map<VpoolUse, List<Recommendation>> recommendationMap, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper cosCapabilities) throws InternalException {
Long size = SizeUtil.translateSize(param.getSize());
List<VolumeDescriptor> existingDescriptors = new ArrayList<VolumeDescriptor>();
List<VolumeDescriptor> volumeDescriptors = createVolumesAndDescriptors(existingDescriptors, param.getName(), size, project, neighborhood, cos, recommendationMap.get(VpoolUse.ROOT), taskList, task, cosCapabilities);
List<Volume> preparedVolumes = getPreparedVolumes(volumeDescriptors);
// Check for special characters in volume names
checkVolumeNames(preparedVolumes.get(0));
final BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_011);
try {
// Execute the volume creations requests
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_012);
controller.createVolumes(volumeDescriptors, task);
} catch (InternalException e) {
_log.error("Controller error when creating volumes", e);
failVolumeCreateRequest(task, taskList, preparedVolumes, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating volumes", e);
failVolumeCreateRequest(task, taskList, preparedVolumes, e.getMessage());
throw e;
}
return taskList;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class DefaultBlockServiceApiImpl method prepareVolumeDescriptors.
private List<VolumeDescriptor> prepareVolumeDescriptors(List<Volume> volumes, VirtualPoolCapabilityValuesWrapper cosCapabilities) {
// Build up a list of VolumeDescriptors based on the volumes
final List<VolumeDescriptor> volumeDescriptors = new ArrayList<VolumeDescriptor>();
for (Volume volume : volumes) {
VolumeDescriptor desc = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, volume.getStorageController(), volume.getId(), volume.getPool(), volume.getConsistencyGroup(), cosCapabilities);
volumeDescriptors.add(desc);
}
return volumeDescriptors;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class VPlexBlockFullCopyApiImpl method create.
/**
* {@inheritDoc}
*/
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
// Populate the descriptors list with all volumes required
// to create the VPLEX volume copies.
int sourceCounter = 0;
URI vplexSrcSystemId = null;
List<Volume> allNewVolumes = new ArrayList<>();
List<Volume> vplexCopyVolumes = new ArrayList<>();
List<VolumeDescriptor> volumeDescriptors = new ArrayList<>();
List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
Map<URI, VirtualArray> vArrayCache = new HashMap<>();
BlockObject aFCSource = null;
try {
for (BlockObject fcSourceObj : sortedSourceObjectList) {
if (aFCSource == null) {
aFCSource = fcSourceObj;
}
URI fcSourceURI = fcSourceObj.getId();
// volumes in VolumeGroup can be from different vArrays
varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
String copyName = null;
if (fcSourceObj instanceof Volume && ((Volume) fcSourceObj).getApplication(_dbClient) != null) {
Volume backendVolume = VPlexUtil.getVPLEXBackendVolume((Volume) fcSourceObj, true, _dbClient);
if (NullColumnValueGetter.isNotNullValue(backendVolume.getReplicationGroupInstance())) {
copyName = name + "-" + backendVolume.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
}
}
if (copyName == null) {
copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
}
vplexSrcSystemId = fcSourceObj.getStorageController();
if (fcSourceObj instanceof Volume) {
// DO IT ONLY FOR VOLUME CLONE - In case of snapshot new VPLEX volume needs to be created
// Create a volume descriptor for the source VPLEX volume being copied.
// and add it to the descriptors list. Be sure to identify this VPLEX
// volume as the source volume being copied.
VolumeDescriptor vplexSrcVolumeDescr = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, vplexSrcSystemId, fcSourceURI, null, null);
Map<String, Object> descrParams = new HashMap<>();
descrParams.put(VolumeDescriptor.PARAM_IS_COPY_SOURCE_ID, Boolean.TRUE);
vplexSrcVolumeDescr.setParameters(descrParams);
volumeDescriptors.add(vplexSrcVolumeDescr);
} else {
BlockSnapshot sourceSnapshot = (BlockSnapshot) fcSourceObj;
URIQueryResultList queryResults = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeByAssociatedVolumesConstraint(sourceSnapshot.getParent().getURI().toString()), queryResults);
URI vplexVolumeURI = queryResults.iterator().next();
if (null != vplexVolumeURI) {
Volume vplexVolume = _dbClient.queryObject(Volume.class, vplexVolumeURI);
vplexSrcSystemId = vplexVolume.getStorageController();
}
}
// Get some info about the VPLEX volume being copied and its storage system.
Project vplexSrcProject = BlockFullCopyUtils.queryFullCopySourceProject(fcSourceObj, _dbClient);
StorageSystem vplexSrcSystem = _dbClient.queryObject(StorageSystem.class, vplexSrcSystemId);
Project vplexSystemProject = VPlexBlockServiceApiImpl.getVplexProject(vplexSrcSystem, _dbClient, _tenantsService);
Volume vplexSrcPrimaryVolume = null;
Volume vplexSrcHAVolume = null;
Volume vplexSrcVolume = null;
if (fcSourceObj instanceof Volume) {
// For the VPLEX volume being copied, determine which of the associated
// backend volumes is the primary and, for distributed volumes, which
// is the HA volume. The primary volume will be natively copied and we
// we need to place and prepare a volume to hold the copy. This copy
// will be the primary backend volume for the VPLEX volume copy. For
// a distributed virtual volume, we will need to place and prepare
// a volume to hold the HA volume of the VPLEX volume copy.
vplexSrcVolume = (Volume) fcSourceObj;
StringSet assocVolumeURIs = vplexSrcVolume.getAssociatedVolumes();
if (null == assocVolumeURIs || assocVolumeURIs.isEmpty()) {
s_logger.error("VPLEX volume {} has no backend volumes.", vplexSrcVolume.forDisplay());
throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vplexSrcVolume.forDisplay());
}
Iterator<String> assocVolumeURIsIter = assocVolumeURIs.iterator();
while (assocVolumeURIsIter.hasNext()) {
URI assocVolumeURI = URI.create(assocVolumeURIsIter.next());
Volume assocVolume = _dbClient.queryObject(Volume.class, assocVolumeURI);
if (assocVolume.getVirtualArray().toString().equals(varray.getId().toString())) {
vplexSrcPrimaryVolume = assocVolume;
} else {
vplexSrcHAVolume = assocVolume;
}
}
}
// Get the capabilities
VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
// Get the number of copies to create and the size of the volumes.
// Note that for the size, we must use the actual provisioned size
// of the source side backend volume. The size passed in the
// capabilities will be the size of the VPLEX volume. When the
// source side backend volume for the copy is provisioned, you
// might not get that actual size. On VMAX, the size will be slightly
// larger while for VNX the size will be exactly what is requested.
// So, if the source side is a VMAX, the source side for the copy
// will be slightly larger than the size in the capabilities. If the HA
// side is VNX and we use the size in the capabilities, then you will
// get exactly that size for the HA backend volume. As a result, source
// side backend volume for the copy will be slightly larger than the
// HA side. Now the way a VPLEX copy is made is it uses native full
// copy to create a native full copy of the source side backend
// volume. It then provisions the HA side volume. The new source side
// backend copy is then imported into VPLEX in the same way as is done
// for a vpool change that imports a volume to VPLEX. This code in the
// VPLEX controller creates a local VPLEX volume using the source side
// copy and for a distributed volume it then attaches as a remote
// mirror the HA backend volume that is provisioned. If the HA volume
// is slightly smaller, then this will fail on the VPLEX. So, we must
// ensure that HA side volume is big enough by using the provisioned
// capacity of the source side backend volume of the VPLEX volume being
// copied.
long size = 0L;
List<Volume> vplexCopyPrimaryVolumes = null;
if (null != vplexSrcPrimaryVolume) {
size = vplexSrcPrimaryVolume.getProvisionedCapacity();
// Place and prepare a volume for each copy to serve as a native
// copy of a VPLEX backend volume. The VPLEX backend volume that
// is copied is the backend volume in the same virtual array as the
// VPLEX volume i.e, the primary backend volume. Create
// descriptors for these prepared volumes and add them to the list.
vplexCopyPrimaryVolumes = prepareFullCopyPrimaryVolumes(copyName, count, vplexSrcPrimaryVolume, capabilities, volumeDescriptors, vpool);
} else {
// Get the provisioned capacity of the snapshot
size = ((BlockSnapshot) fcSourceObj).getProvisionedCapacity();
// Place and prepare a back-end volume for each block snapshot
vplexCopyPrimaryVolumes = prepareFullCopyPrimaryVolumes(copyName, count, fcSourceObj, capabilities, volumeDescriptors, vpool);
}
allNewVolumes.addAll(vplexCopyPrimaryVolumes);
// If the VPLEX volume being copied is distributed, then the VPLEX
// HA volume should be non-null. We use the VPLEX scheduler to place
// and then prepare volumes for the HA volumes of the VPLEX volume
// copies. This should be done in the same manner as is done for the
// import volume routine. This is because to form the VPLEX volume
// copy we import the copy of the primary backend volume.
List<Volume> vplexCopyHAVolumes = new ArrayList<>();
if (vplexSrcHAVolume != null) {
vplexCopyHAVolumes.addAll(prepareFullCopyHAVolumes(copyName, count, size, vplexSrcSystem, vplexSystemProject, varray, vplexSrcHAVolume, taskId, volumeDescriptors));
}
allNewVolumes.addAll(vplexCopyHAVolumes);
// and add them to the volume descriptors list.
for (int i = 0; i < count; i++) {
// Prepare a new VPLEX volume for each copy.
Volume vplexCopyPrimaryVolume = vplexCopyPrimaryVolumes.get(i);
Volume vplexCopyHAVolume = null;
if (!vplexCopyHAVolumes.isEmpty()) {
vplexCopyHAVolume = vplexCopyHAVolumes.get(i);
}
Volume vplexCopyVolume = prepareFullCopyVPlexVolume(copyName, name, count, i, size, fcSourceObj, vplexSrcProject, varray, vpool, vplexSrcSystemId, vplexCopyPrimaryVolume, vplexCopyHAVolume, taskId, volumeDescriptors);
vplexCopyVolumes.add(vplexCopyVolume);
allNewVolumes.addAll(vplexCopyHAVolumes);
}
}
} catch (Exception e) {
handlePlacementFailure(allNewVolumes);
throw e;
}
// get all tasks
TaskList taskList = getTasksForCreateFullCopy(aFCSource, vplexCopyVolumes, taskId);
// Invoke the VPLEX controller to create the copies.
try {
s_logger.info("Getting Orchestration controller {}.", taskId);
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
controller.createFullCopy(volumeDescriptors, taskId);
s_logger.info("Successfully invoked controller.");
} catch (InternalException e) {
s_logger.error("Controller error", e);
// Update the status for the VPLEX copy volume and CG tasks.
handleFailedRequest(taskId, taskList, new ArrayList<Volume>(), e, false);
// we were trying to copy.
for (VolumeDescriptor descriptor : volumeDescriptors) {
if (descriptor.getParameters().get(VolumeDescriptor.PARAM_IS_COPY_SOURCE_ID) == null) {
Volume volume = _dbClient.queryObject(Volume.class, descriptor.getVolumeURI());
volume.setInactive(true);
_dbClient.updateObject(volume);
}
}
}
return taskList;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class VPlexBlockFullCopyApiImpl method prepareFullCopyVPlexVolume.
/**
* Prepares the VPLEX volume copies.
*
* @param name The base name for the volume.
* @param fullCopySetName
* @param copyCount The total number of copies.
* @param copyIndex The index for this copy.
* @param size The size for the HA volume.
* @param fcSourceObject The VPLEX volume or the snapshot being copied.
* @param srcProject The project for the VPLEX volume being copied.
* @param srcVarray The virtual array for the VPLEX volume being copied.
* @param srcVpool The virtual pool for the VPLEX volume being copied.
* @param srcSystemURI The VPLEX system URI.
* @param primaryVolume The primary volume for the copy.
* @param haVolume The HA volume for the copy, or null.
* @param taskId The task identifier.
* @param volumeDescriptors The list of descriptors.
*
* @return A reference to the prepared VPLEX volume copy.
*/
private Volume prepareFullCopyVPlexVolume(String name, String fullCopySetName, int copyCount, int copyIndex, long size, BlockObject fcSourceObject, Project srcProject, VirtualArray srcVarray, VirtualPool srcVpool, URI srcSystemURI, Volume primaryVolume, Volume haVolume, String taskId, List<VolumeDescriptor> volumeDescriptors) {
// Determine the VPLEX volume copy name.
StringBuilder nameBuilder = new StringBuilder(name);
if (copyCount > 1) {
nameBuilder.append("-");
nameBuilder.append(copyIndex + 1);
}
// Prepare the VPLEX volume copy.
Volume vplexCopyVolume = VPlexBlockServiceApiImpl.prepareVolumeForRequest(size, srcProject, srcVarray, srcVpool, srcSystemURI, NullColumnValueGetter.getNullURI(), nameBuilder.toString(), ResourceOperationTypeEnum.CREATE_VOLUME_FULL_COPY, taskId, _dbClient);
// Create a volume descriptor and add it to the passed list.
VolumeDescriptor vplexCopyVolumeDescr = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, srcSystemURI, vplexCopyVolume.getId(), null, null);
volumeDescriptors.add(vplexCopyVolumeDescr);
// Set the associated volumes for this new VPLEX volume copy to
// the copy of the backend primary and the newly prepared HA
// volume if the VPLEX volume being copied is distributed.
vplexCopyVolume.setAssociatedVolumes(new StringSet());
StringSet assocVolumes = vplexCopyVolume.getAssociatedVolumes();
assocVolumes.add(primaryVolume.getId().toString());
if (haVolume != null) {
assocVolumes.add(haVolume.getId().toString());
}
// Set the VPLEX source volume or the snapshot for the copy.
vplexCopyVolume.setAssociatedSourceVolume(fcSourceObject.getId());
// Except for the Openstack, all Copies always created active.
if (VPlexUtil.isOpenStackBackend(fcSourceObject, _dbClient)) {
vplexCopyVolume.setSyncActive(Boolean.FALSE);
} else {
vplexCopyVolume.setSyncActive(Boolean.TRUE);
}
// For Application, set the user provided clone name on all the clones to identify clone set
if (fcSourceObject instanceof Volume && ((Volume) fcSourceObject).getApplication(_dbClient) != null) {
vplexCopyVolume.setFullCopySetName(fullCopySetName);
}
// Persist the copy.
_dbClient.persistObject(vplexCopyVolume);
return vplexCopyVolume;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class VPlexBlockFullCopyApiImpl method prepareFullCopyHAVolumes.
/**
* Places and prepares the HA volumes when copying a distributed VPLEX
* volume.
*
* @param name The base name for the volume.
* @param copyCount The number of copies to be made.
* @param size The size for the HA volume.
* @param vplexSystem A reference to the VPLEX storage system.
* @param vplexSystemProject A reference to the VPLEX system project.
* @param srcVarray The virtual array for the VPLEX volume being copied.
* @param srcHAVolume The HA volume of the VPLEX volume being copied.
* @param taskId The task identifier.
* @param volumeDescriptors The list of descriptors.
*
* @return A list of the prepared HA volumes for the VPLEX volume copy.
*/
private List<Volume> prepareFullCopyHAVolumes(String name, int copyCount, Long size, StorageSystem vplexSystem, Project vplexSystemProject, VirtualArray srcVarray, Volume srcHAVolume, String taskId, List<VolumeDescriptor> volumeDescriptors) {
List<Volume> copyHAVolumes = new ArrayList<>();
// Get the storage placement recommendations for the volumes.
// Placement must occur on the same VPLEX system
Set<URI> vplexSystemURIS = new HashSet<>();
vplexSystemURIS.add(vplexSystem.getId());
VirtualArray haVarray = _dbClient.queryObject(VirtualArray.class, srcHAVolume.getVirtualArray());
VirtualPool haVpool = _dbClient.queryObject(VirtualPool.class, srcHAVolume.getVirtualPool());
VirtualPoolCapabilityValuesWrapper haCapabilities = new VirtualPoolCapabilityValuesWrapper();
haCapabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, size);
haCapabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, copyCount);
VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(srcHAVolume, _dbClient);
if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
haCapabilities.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
haCapabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_VOLUME_PRE_ALLOCATE_SIZE, BlockFullCopyUtils.getAllocatedCapacityForFullCopySource(srcHAVolume, _dbClient));
}
List<Recommendation> recommendations = ((VPlexScheduler) _scheduler).scheduleStorageForImport(srcVarray, vplexSystemURIS, haVarray, haVpool, haCapabilities);
if (recommendations.isEmpty()) {
throw APIException.badRequests.noStorageForHaVolumesForVplexVolumeCopies();
}
// Prepare the HA volumes for the VPLEX volume copy.
int copyIndex = 1;
for (Recommendation recommendation : recommendations) {
VPlexRecommendation haRecommendation = (VPlexRecommendation) recommendation;
for (int i = 0; i < haRecommendation.getResourceCount(); i++) {
// Determine the name for the HA volume copy.
StringBuilder nameBuilder = new StringBuilder(name);
nameBuilder.append("-1");
if (copyCount > 1) {
nameBuilder.append("-");
nameBuilder.append(copyIndex++);
}
// Prepare the volume.
Volume volume = VPlexBlockServiceApiImpl.prepareVolumeForRequest(size, vplexSystemProject, haVarray, haVpool, haRecommendation.getSourceStorageSystem(), haRecommendation.getSourceStoragePool(), nameBuilder.toString(), null, taskId, _dbClient);
volume.addInternalFlags(Flag.INTERNAL_OBJECT);
_dbClient.persistObject(volume);
copyHAVolumes.add(volume);
// Create the volume descriptor and add it to the passed list.
VolumeDescriptor volumeDescriptor = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, volume.getStorageController(), volume.getId(), volume.getPool(), haCapabilities);
volumeDescriptors.add(volumeDescriptor);
}
}
return copyHAVolumes;
}
Aggregations