use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method getDescriptorsForVolumesToBeDeleted.
@Override
public List<VolumeDescriptor> getDescriptorsForVolumesToBeDeleted(URI systemURI, List<URI> volumeURIs, String deletionType) {
// Get descriptors for all volumes impacted by the deletion of the requested volumes.
List<VolumeDescriptor> volumeDescriptors = RPHelper.getDescriptorsForVolumesToBeDeleted(systemURI, volumeURIs, deletionType, null, _dbClient);
// Filter these descriptors for a block volumes and VPLEX volumes.
List<VolumeDescriptor> filteredDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.VPLEX_VIRT_VOLUME }, new VolumeDescriptor.Type[] {});
// Now get descriptors for the mirrors of these block and VPLEX volumes.
for (VolumeDescriptor descriptor : filteredDescriptors) {
URI volumeURI = descriptor.getDeviceURI();
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (volume != null && !volume.getInactive()) {
if (VolumeDescriptor.Type.BLOCK_DATA == descriptor.getType()) {
addDescriptorsForMirrors(volumeDescriptors, volume);
} else if (VolumeDescriptor.Type.VPLEX_VIRT_VOLUME == descriptor.getType()) {
vplexBlockServiceApiImpl.addDescriptorsForVplexMirrors(volumeDescriptors, volume);
}
}
}
return volumeDescriptors;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method cleanupForViPROnlyDelete.
/**
* {@inheritDoc}
*/
@Override
protected void cleanupForViPROnlyDelete(List<VolumeDescriptor> volumeDescriptors) {
// Call super first.
super.cleanupForViPROnlyDelete(volumeDescriptors);
// Get the RP source volumes.
List<VolumeDescriptor> sourceVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
List<URI> sourceVolumeURIs = new ArrayList<URI>();
for (URI sourceVolumeURI : VolumeDescriptor.getVolumeURIs(sourceVolumeDescriptors)) {
Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceVolumeURI);
if (sourceVolume != null && !sourceVolume.getInactive() && !sourceVolume.isIngestedVolumeWithoutBackend(_dbClient)) {
// Keeping this in here for when we do RP ingest.
sourceVolumeURIs.add(sourceVolumeURI);
}
}
// If we're deleting the last volume, we can delete the ProtectionSet object.
// This list of volumes may contain volumes from many protection sets
Set<URI> volumesToDelete = RPHelper.getVolumesToDelete(sourceVolumeURIs, _dbClient);
Map<URI, Set<URI>> psetToVolumesToDelete = new HashMap<URI, Set<URI>>();
// Group volumes to delete by their protectionsets
for (URI volumeURI : volumesToDelete) {
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (volume.getProtectionSet() != null) {
if (psetToVolumesToDelete.get(volume.getProtectionSet().getURI()) == null) {
psetToVolumesToDelete.put(volume.getProtectionSet().getURI(), new HashSet<URI>());
}
psetToVolumesToDelete.get(volume.getProtectionSet().getURI()).add(volumeURI);
}
}
// Go through all protection sets and verify we have all of the volumes accounted for
// and delete the protection set if necessary. Log otherwise.
Set<URI> psetsDeleted = new HashSet<URI>();
for (Entry<URI, Set<URI>> psetVolumeEntry : psetToVolumesToDelete.entrySet()) {
ProtectionSet pset = _dbClient.queryObject(ProtectionSet.class, psetVolumeEntry.getKey());
if (pset != null && !psetsDeleted.contains(pset.getId()) && psetVolumeEntry.getValue().size() == pset.getVolumes().size()) {
_dbClient.markForDeletion(pset);
psetsDeleted.add(pset.getId());
} else if (pset.getVolumes() == null) {
_dbClient.markForDeletion(pset);
psetsDeleted.add(pset.getId());
_log.info(String.format("Deleting protection %s because there are no volumes in it any longer", pset.getLabel()));
} else if (volumesToDelete.size() != pset.getVolumes().size()) {
// For debugging: log conditions that caused us to not delete the protection set
_log.info(String.format("Not deleting protection %s because there are %d volumes to delete in the request, however there are %d volumes in the pset", pset.getLabel(), RPHelper.getVolumesToDelete(sourceVolumeURIs, _dbClient).size(), pset.getVolumes().size()));
}
}
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method expandVolume.
/**
* {@inheritDoc}
*/
@Override
public void expandVolume(Volume volume, long newSize, String taskId) throws InternalException {
Long originalVolumeSize = volume.getCapacity();
List<URI> replicationSetVolumes = RPHelper.getReplicationSetVolumes(volume, _dbClient);
Map<URI, StorageSystem> volumeStorageSystems = new HashMap<URI, StorageSystem>();
// provisioned capacity into the computeProtectionAllocation Capacity.
for (URI rpVolumeURI : replicationSetVolumes) {
Volume rpVolume = _dbClient.queryObject(Volume.class, rpVolumeURI);
Volume vmaxVolume = null;
StorageSystem vmaxStorageSystem = null;
if (rpVolume.getAssociatedVolumes() != null && !rpVolume.getAssociatedVolumes().isEmpty()) {
// Check backend volumes for VPLEX
for (String backingVolumeStr : rpVolume.getAssociatedVolumes()) {
Volume backingVolume = _dbClient.queryObject(Volume.class, URI.create(backingVolumeStr));
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, backingVolume.getStorageController());
if (storageSystem.getSystemType().equalsIgnoreCase(DiscoveredDataObject.Type.vmax.toString())) {
vmaxVolume = backingVolume;
vmaxStorageSystem = storageSystem;
break;
}
}
} else {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, rpVolume.getStorageController());
if (storageSystem.getSystemType().equalsIgnoreCase(DiscoveredDataObject.Type.vmax.toString())) {
vmaxVolume = rpVolume;
vmaxStorageSystem = storageSystem;
}
}
if (vmaxVolume != null && vmaxStorageSystem != null) {
// Set the requested size to what the VMAX Meta utils determines will possibly be the provisioned
// capacity.
// All the other volumes, will need to be the same size as well or else RP will have a fit.
newSize = RPHelper.computeVmaxVolumeProvisionedCapacity(newSize, vmaxVolume, vmaxStorageSystem, _dbClient);
_log.info(String.format("VMAX volume detected, expand size re-calculated to [%d]", newSize));
// No need to continue, newSize has been calculated.
break;
}
}
try {
List<Volume> allVolumesToUpdateCapacity = new ArrayList<Volume>();
Map<URI, String> associatedVolumePersonalityMap = new HashMap<URI, String>();
for (URI rpVolumeURI : replicationSetVolumes) {
Volume rpVolume = _dbClient.queryObject(Volume.class, rpVolumeURI);
if (rpVolume.getAssociatedVolumes() != null && !rpVolume.getAssociatedVolumes().isEmpty()) {
// Check backend volumes for VPLEX
for (String backingVolumeStr : rpVolume.getAssociatedVolumes()) {
Volume backingVolume = _dbClient.queryObject(Volume.class, URI.create(backingVolumeStr));
allVolumesToUpdateCapacity.add(backingVolume);
associatedVolumePersonalityMap.put(backingVolume.getId(), rpVolume.getPersonality());
addVolumeStorageSystem(volumeStorageSystems, backingVolume);
}
} else {
allVolumesToUpdateCapacity.add(rpVolume);
addVolumeStorageSystem(volumeStorageSystems, rpVolume);
}
}
if (!capacitiesCanMatch(volumeStorageSystems)) {
Map<Volume.PersonalityTypes, Long> capacities = setUnMatchedCapacities(allVolumesToUpdateCapacity, associatedVolumePersonalityMap, true, newSize);
_log.info("Capacities for source and target of the Volume Expand request cannot match due to the differences in array types");
_log.info("Expand Volume requested size : {}", newSize);
_log.info("Expand source calculated size : {}", capacities.get(Volume.PersonalityTypes.SOURCE));
_log.info("Expand target calcaluted size : {}", capacities.get(Volume.PersonalityTypes.TARGET));
List<VolumeDescriptor> volumeDescriptors = createVolumeDescriptors(null, replicationSetVolumes, null, null, null);
for (VolumeDescriptor volDesc : volumeDescriptors) {
if (volDesc.getType() == VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE) {
volDesc.setVolumeSize(capacities.get(Volume.PersonalityTypes.SOURCE));
} else if ((volDesc.getType() == VolumeDescriptor.Type.RP_TARGET) || (volDesc.getType() == VolumeDescriptor.Type.RP_VPLEX_VIRT_TARGET)) {
volDesc.setVolumeSize(capacities.get(Volume.PersonalityTypes.TARGET));
}
}
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
controller.expandVolume(volumeDescriptors, taskId);
} else {
// Step 2: Just because we have a RP source/target on VMAX and have a size calculated doesn't mean VNX can honor it.
// The trick is that the size of the volume must be a multiple of 512 for VNX and 520 for VMAX because of the different
// block sizes.
// We will find a number (in bytes) that is greater than the requested size and meets the above criteria and use that our
// final expanded volume size.
long normalizedRequestSize = computeProtectionCapacity(replicationSetVolumes, newSize, true, false, null);
// Step 3: Call the controller to do the expand.
_log.info("Expand volume request size : {}", normalizedRequestSize);
List<VolumeDescriptor> volumeDescriptors = createVolumeDescriptors(null, replicationSetVolumes, null, null, null);
for (VolumeDescriptor volDesc : volumeDescriptors) {
volDesc.setVolumeSize(normalizedRequestSize);
}
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
controller.expandVolume(volumeDescriptors, taskId);
}
} catch (ControllerException e) {
// Set the volume size back to original size before the expand request
for (URI volumeURI : replicationSetVolumes) {
Volume rpVolume = _dbClient.queryObject(Volume.class, volumeURI);
rpVolume.setCapacity(originalVolumeSize);
_dbClient.updateObject(rpVolume);
// Reset the backing volumes as well, if they exist
if (rpVolume.getAssociatedVolumes() != null && !rpVolume.getAssociatedVolumes().isEmpty()) {
// Check backend volumes for VPLEX
for (String backingVolumeStr : rpVolume.getAssociatedVolumes()) {
Volume backingVolume = _dbClient.queryObject(Volume.class, URI.create(backingVolumeStr));
backingVolume.setCapacity(originalVolumeSize);
_dbClient.updateObject(backingVolume);
}
}
}
throw APIException.badRequests.volumeNotExpandable(volume.getLabel());
}
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method prepareVPlexVolume.
/**
* Leverage the vplex block service api to properly prepare volumes in cassandra for later consumption by the controllers
*
* @param vplexRecommendations All the VPLEX recs
* @param project Project for the volume
* @param varray Varray for the volume
* @param vpool Vpool for the volume
* @param storagePoolUri URI of the Storage Pool for the volume
* @param storageSystemId URI of the Storage System for the volume
* @param capabilities Capabilities for the volume create
* @param consistencyGroup CG for the volume
* @param param Volume create param for the volume
* @param volumeName Volume name
* @param size Volume size
* @param descriptors All volume descriptors, needed to be populated by the VPLEX Block
* @param taskList Tasklist to add all VPLEX tasks
* @param task Task Id
* @param personality Personality of the volume
* @param isChangeVpool Boolean set to true if it's a change vpool op
* @param changeVpoolVolume The change vpool volume if needed
* @return Prepared VPLEX volume
*/
private Volume prepareVPlexVolume(List<Recommendation> vplexRecommendations, Project project, VirtualArray varray, VirtualPool vpool, URI storagePoolUri, URI storageSystemId, VirtualPoolCapabilityValuesWrapper capabilities, BlockConsistencyGroup consistencyGroup, VolumeCreate param, String volumeName, String size, List<VolumeDescriptor> descriptors, TaskList taskList, String task, Volume.PersonalityTypes personality, boolean isChangeVpool, Volume changeVpoolVolume) {
Volume vplexVirtualVolume = null;
if (!isChangeVpool) {
List<URI> volumes = new ArrayList<URI>();
// VPLEX needs to be aware of the CG
capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, consistencyGroup.getId());
capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, personality.name());
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
// Tweak the VolumeCreate slightly for VPLEX
VolumeCreate volumeCreateParam = new VolumeCreate();
volumeCreateParam.setConsistencyGroup(consistencyGroup.getId());
volumeCreateParam.setCount(1);
volumeCreateParam.setName(volumeName);
volumeCreateParam.setProject(project.getId());
volumeCreateParam.setSize(size);
volumeCreateParam.setVarray(varray.getId());
volumeCreateParam.setVpool(vpool.getId());
boolean createTask = Volume.PersonalityTypes.SOURCE.equals(personality);
List<VolumeDescriptor> vplexVolumeDescriptors = vplexBlockServiceApiImpl.createVPlexVolumeDescriptors(volumeCreateParam, project, varray, vpool, vplexRecommendations, task, capabilities, capabilities.getBlockConsistencyGroup(), taskList, volumes, createTask);
// name if the custom volume naming is configured as such.
if ((createTask) && (param.getComputeResource() != null)) {
for (VolumeDescriptor vplexVolumeDescriptor : vplexVolumeDescriptors) {
vplexVolumeDescriptor.setComputeResource(param.getComputeResource());
}
}
descriptors.addAll(vplexVolumeDescriptors);
vplexVirtualVolume = this.getVPlexVirtualVolume(volumes);
} else {
if (Volume.PersonalityTypes.SOURCE.equals(personality)) {
VolumeDescriptor changeVpoolDescriptor = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, changeVpoolVolume.getStorageController(), changeVpoolVolume.getId(), null, consistencyGroup.getId(), capabilities, changeVpoolVolume.getCapacity());
Map<String, Object> descParams = new HashMap<String, Object>();
descParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_EXISTING_VOLUME_ID, changeVpoolVolume.getId());
descParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_NEW_VPOOL_ID, vpool.getId());
descParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_OLD_VPOOL_ID, changeVpoolVolume.getVirtualPool());
changeVpoolDescriptor.setParameters(descParams);
descriptors.add(changeVpoolDescriptor);
vplexVirtualVolume = changeVpoolVolume;
}
}
return vplexVirtualVolume;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method createVolumes.
@Override
public TaskList createVolumes(VolumeCreate param, Project project, VirtualArray varray, VirtualPool vpool, Map<VpoolUse, List<Recommendation>> recommendationMap, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper capabilities) throws InternalException {
List<Recommendation> recommendations = recommendationMap.get(VpoolUse.ROOT);
// List of volumes to be prepared
List<URI> volumeURIs = new ArrayList<URI>();
// Volume label from the param
String volumeLabel = param.getName();
// List to store the volume descriptors for the Block Orchestration
List<VolumeDescriptor> volumeDescriptors = new ArrayList<VolumeDescriptor>();
// Store capabilities of the CG, so they make it down to the controller
if (vpool.getRpCopyMode() != null) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.RP_COPY_MODE, vpool.getRpCopyMode());
}
if (vpool.getRpRpoType() != null && NullColumnValueGetter.isNotNullValue(vpool.getRpRpoType())) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.RP_RPO_TYPE, vpool.getRpRpoType());
}
if (vpool.checkRpRpoValueSet()) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.RP_RPO_VALUE, vpool.getRpRpoValue());
}
// Get the first recommendation, we need to figure out if this is a change vpool
RPProtectionRecommendation rpProtectionRec = (RPProtectionRecommendation) recommendations.get(0);
boolean isChangeVpool = (rpProtectionRec.getVpoolChangeVolume() != null);
boolean isChangeVpoolForProtectedVolume = rpProtectionRec.isVpoolChangeProtectionAlreadyExists();
// for change vpool, save off the original source volume in case we need to roll back
URI oldVpoolId = null;
if (isChangeVpool || isChangeVpoolForProtectedVolume) {
Volume changeVpoolVolume = _dbClient.queryObject(Volume.class, rpProtectionRec.getVpoolChangeVolume());
oldVpoolId = changeVpoolVolume.getVirtualPool();
}
try {
// Prepare the volumes
prepareRecommendedVolumes(param, task, taskList, project, varray, vpool, capabilities.getResourceCount(), recommendations, volumeLabel, capabilities, volumeDescriptors, volumeURIs);
// Execute the volume creations requests for each recommendation.
Iterator<Recommendation> recommendationsIter = recommendations.iterator();
while (recommendationsIter.hasNext()) {
RPProtectionRecommendation recommendation = (RPProtectionRecommendation) recommendationsIter.next();
volumeDescriptors.addAll(createVolumeDescriptors(recommendation, volumeURIs, capabilities, oldVpoolId, param.getComputeResource()));
logDescriptors(volumeDescriptors);
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
// TODO might be able to use param.getSize() instead of the below code to find requestedVolumeCapactity
Long requestedVolumeCapactity = 0L;
for (URI volumeURI : volumeURIs) {
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (Volume.PersonalityTypes.SOURCE.name().equalsIgnoreCase(volume.getPersonality())) {
requestedVolumeCapactity = volume.getCapacity();
break;
}
}
computeProtectionCapacity(volumeURIs, requestedVolumeCapactity, false, isChangeVpool, null);
if (isChangeVpool) {
_log.info("Add Recoverpoint Protection to existing volume");
controller.changeVirtualPool(volumeDescriptors, task);
} else {
_log.info("Create RP volumes");
controller.createVolumes(volumeDescriptors, task);
}
}
} catch (Exception e) {
_log.error(e.getMessage(), e);
try {
// We want to return the volume back to its original state.
if (isChangeVpool || isChangeVpoolForProtectedVolume) {
Volume changeVpoolVolume = _dbClient.queryObject(Volume.class, rpProtectionRec.getVpoolChangeVolume());
VirtualPool oldVpool = _dbClient.queryObject(VirtualPool.class, oldVpoolId);
RPHelper.rollbackProtectionOnVolume(changeVpoolVolume, oldVpool, _dbClient);
}
for (URI volumeURI : volumeURIs) {
// completely rollback an existing volume (which the change vpool volume would be).
if (!volumeURI.equals(rpProtectionRec.getVpoolChangeVolume())) {
RPHelper.rollbackVolume(volumeURI, _dbClient);
}
}
} catch (Exception e2) {
// best effort for rollback; still need to set the tasks to error
_log.error("rollback create volume or change vpool failed");
_log.error(e2.getMessage(), e);
}
// Let's check to see if there are existing tasks, if so, put them in error.
if (taskList.getTaskList() != null && !taskList.getTaskList().isEmpty()) {
for (TaskResourceRep volumeTask : taskList.getTaskList()) {
volumeTask.setState(Operation.Status.error.name());
volumeTask.setMessage(e.getMessage());
Operation statusUpdate = new Operation(Operation.Status.error.name(), e.getMessage());
_dbClient.updateTaskOpStatus(Volume.class, volumeTask.getResource().getId(), task, statusUpdate);
}
}
throw APIException.badRequests.rpBlockApiImplPrepareVolumeException(volumeLabel);
}
return taskList;
}
Aggregations