use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPDeviceController method setVolumeConsistencyGroup.
/**
* Sets the volume consistency group
*
* @param volumeDescriptors
* @param cgURI
*/
private void setVolumeConsistencyGroup(List<VolumeDescriptor> volumeDescriptors, URI cgURI) {
for (VolumeDescriptor volumeDescriptor : volumeDescriptors) {
Volume volume = _dbClient.queryObject(Volume.class, volumeDescriptor.getVolumeURI());
volume.setConsistencyGroup(cgURI);
_dbClient.updateObject(volume);
}
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class RPDeviceController method cgCreateStep.
/**
* Workflow step method for creating/updating a consistency group.
*
* @param rpSystemId
* RP system Id
* @param recommendation
* parameters needed to create the CG
* @param token
* the task
* @return
* @throws InternalException
*/
public boolean cgCreateStep(URI rpSystemId, List<VolumeDescriptor> volumeDescriptors, String token) throws InternalException {
RecoverPointClient rp;
CGRequestParams cgParams = null;
boolean metropoint = false;
boolean lockException = false;
try {
// Get only the RP volumes from the descriptors.
List<VolumeDescriptor> sourceVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_EXISTING_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
WorkflowStepCompleter.stepExecuting(token);
ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
URI cgId = volumeDescriptors.iterator().next().getCapabilitiesValues().getBlockConsistencyGroup();
boolean attachAsClean = true;
for (VolumeDescriptor sourceVolumedescriptor : sourceVolumeDescriptors) {
Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceVolumedescriptor.getVolumeURI());
metropoint = RPHelper.isMetroPointVolume(_dbClient, sourceVolume);
// if this is a change vpool, attachAsClean should be false so that source and target are synchronized
if (VolumeDescriptor.Type.RP_EXISTING_SOURCE.equals(sourceVolumedescriptor.getType())) {
attachAsClean = false;
}
}
// Build the CG Request params
cgParams = getCGRequestParams(volumeDescriptors, rpSystem);
updateCGParams(cgParams);
// Validate the source/target volumes before creating a CG.
validateCGVolumes(volumeDescriptors);
rp = RPHelper.getRecoverPointClient(rpSystem);
// Scan the rp sites for volume visibility
rp.waitForVolumesToBeVisible(cgParams);
// Before acquiring a lock on the CG we need to ensure that the
// CG is created. If it hasn't, then the first CGRequestParams
// to be allowed to pass through needs to have the journals
// defined.
//
// NOTE: The CG may not yet be created on the RP protection system and
// that's OK since this might be the first request going in.
waitForCGToBeCreated(cgId, cgParams);
// lock around create and delete operations on the same CG
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgId, rpSystem.getId()));
boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(token, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
if (!lockAcquired) {
lockException = true;
throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Create or add volumes to RP consistency group id: %s", cgId.toString()));
}
RecoverPointCGResponse response = null;
// The CG already exists if it contains volumes and is of type RP
_log.info("Submitting RP Request: " + cgParams);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
// Check to see if the CG has been created in ViPR and on the RP protection system
boolean cgAlreadyExists = rpCGExists(cg, rp, cgParams.getCgName(), rpSystem.getId());
if (cgAlreadyExists) {
// cg exists in both the ViPR db and on the RP system
_log.info(String.format("RP CG [%s] already exists, adding replication set(s) to it...", cgParams.getCgName()));
response = rp.addReplicationSetsToCG(cgParams, metropoint, attachAsClean);
} else {
_log.info(String.format("RP CG [%s] does not already exist, creating it now and adding replication set(s) to it...", cgParams.getCgName()));
response = rp.createCG(cgParams, metropoint, attachAsClean);
// "Turn-on" the consistency group
cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgParams.getCgUri());
cg.addSystemConsistencyGroup(rpSystemId.toString(), cgParams.getCgName());
cg.addConsistencyGroupTypes(Types.RP.name());
}
// At this point, always clear the journal provisioning lock on the
// CG for any concurrent orders that may come in.
cg.setJournalProvisioningLock(0L);
_dbClient.updateObject(cg);
setVolumeConsistencyGroup(volumeDescriptors, cgParams.getCgUri());
// If this was a vpool Update, now is a good time to update the vpool and Volume information
if (VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors) != null) {
Volume volume = _dbClient.queryObject(Volume.class, VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors));
URI newVpoolURI = getVirtualPoolChangeNewVirtualPool(volumeDescriptors);
volume.setVirtualPool(newVpoolURI);
volume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
volume.setLinkStatus(Volume.LinkStatus.IN_SYNC.name());
volume.setProtectionController(rpSystemId);
_dbClient.updateObject(volume);
// We might need to update the vpools of the backing volumes if this is an RP+VPLEX
// or MetroPoint change vpool.
VPlexUtil.updateVPlexBackingVolumeVpools(volume, newVpoolURI, _dbClient);
// Record Audit operation. (virtualpool change only)
AuditBlockUtil.auditBlock(_dbClient, OperationTypeEnum.CHANGE_VOLUME_VPOOL, true, AuditLogManager.AUDITOP_END, token);
}
// Create the ProtectionSet to contain the CG UID (which is truly unique to the protection system)
if (response.getCgId() != null) {
List<ProtectionSet> protectionSets = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ProtectionSet.class, AlternateIdConstraint.Factory.getConstraint(ProtectionSet.class, "protectionId", response.getCgId().toString()));
ProtectionSet protectionSet = null;
if (protectionSets.isEmpty()) {
// A protection set corresponding to the CG does not exist so we need to create one
protectionSet = createProtectionSet(rpSystem, cgParams, response.getCgId());
} else {
// Update the existing protection set. We will only have 1 protection set
// get the first one.
protectionSet = protectionSets.get(0);
protectionSet = updateProtectionSet(protectionSet, cgParams);
}
_dbClient.updateObject(protectionSet);
}
// Set the CG last created time to now.
rpSystem.setCgLastCreatedTime(Calendar.getInstance());
_dbClient.updateObject(rpSystem);
// Update the workflow state.
WorkflowStepCompleter.stepSucceded(token);
// collect and update the protection system statistics to account for
// the newly created CG.
_log.info("Collecting RP statistics post CG create.");
collectRPStatistics(rpSystem);
} catch (Exception e) {
if (lockException) {
List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
ServiceError serviceError = DeviceControllerException.errors.createVolumesAborted(volUris.toString(), e);
doFailCgCreateStep(volumeDescriptors, cgParams, rpSystemId, token);
stepFailed(token, serviceError, "cgCreateStep");
} else {
doFailCgCreateStep(volumeDescriptors, cgParams, rpSystemId, token);
stepFailed(token, e, "cgCreateStep");
}
return false;
}
return true;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class SRDFDeviceController method addStepsForDeleteVolumes.
@Override
public String addStepsForDeleteVolumes(final Workflow workflow, String waitFor, final List<VolumeDescriptor> volumeDescriptors, final String taskId) throws InternalException {
List<VolumeDescriptor> sourceDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, VolumeDescriptor.Type.SRDF_SOURCE);
if (sourceDescriptors.isEmpty()) {
return waitFor;
}
Map<URI, Volume> volumeMap = queryVolumes(sourceDescriptors);
// TODO make this roll back work for multiple targets
for (Volume source : volumeMap.values()) {
StringSet targets = source.getSrdfTargets();
if (targets == null) {
return waitFor;
}
for (String target : targets) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
if (null == targetVolume || targetVolume.getInactive()) {
return waitFor;
}
if (Mode.ASYNCHRONOUS.toString().equalsIgnoreCase(targetVolume.getSrdfCopyMode()) && targetVolume.hasConsistencyGroup()) {
// if replication Group Name is not set, we end up in delete errors, preventing.
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, targetVolume.getSrdfGroup());
if (!NullColumnValueGetter.isNotNullValue(group.getSourceReplicationGroupName()) || !NullColumnValueGetter.isNotNullValue(group.getTargetReplicationGroupName())) {
log.warn("Consistency Groups of RDF {} still not updated in ViPR DB. If async pair is created minutes back and tried delete immediately,please wait and try again", group.getNativeGuid());
throw DeviceControllerException.exceptions.srdfAsyncStepDeletionfailed(group.getNativeGuid());
}
}
}
}
waitFor = deleteSRDFMirrorSteps(workflow, waitFor, sourceDescriptors);
return waitFor;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class SRDFDeviceController method addStepsForExpandVolume.
// TODO : JIRA CTRL-5335 SRDF expand needs to go via BlockOrchestrationController. Close this JIRA.
@Override
public String addStepsForExpandVolume(Workflow workflow, String waitFor, List<VolumeDescriptor> descriptors, String task) {
TaskCompleter completer = null;
descriptors = VolumeDescriptor.filterByType(descriptors, VolumeDescriptor.Type.SRDF_SOURCE);
if (descriptors.isEmpty()) {
return waitFor;
}
if (descriptors.size() > 1) {
throw WorkflowException.exceptions.workflowConstructionError("SRDFDeviceController.addStepsForExpandVolume only supports one source volume");
}
VolumeDescriptor descriptor = descriptors.get(0);
Long size = descriptor.getVolumeSize();
List<URI> uris = VolumeDescriptor.getVolumeURIs(descriptors);
URI volumeId = uris.get(0);
try {
Volume source = dbClient.queryObject(Volume.class, volumeId);
StringSet targets = source.getSrdfTargets();
List<URI> combined = Lists.newArrayList();
combined.add(source.getId());
combined.addAll(transform(targets, FCTN_STRING_TO_URI));
completer = new SRDFExpandCompleter(combined, task);
if (null != targets) {
for (String targetURI : targets) {
Volume target = dbClient.queryObject(Volume.class, URI.create(targetURI));
log.info("target Volume {} with srdf group {}", target.getNativeGuid(), target.getSrdfGroup());
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
if (group.getVolumes() == null) {
group.setVolumes(new StringSet());
}
group.getVolumes().replace(volumes);
dbClient.persistObject(group);
if (!source.hasConsistencyGroup()) {
// First we suspend the mirror...
Workflow.Method suspendMethod = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
// TODO Belongs as a rollback for the detach step
Workflow.Method rollbackMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), suspendMethod, rollbackMethod, null);
// Second we detach the mirror...
Workflow.Method detachMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, suspendStep, system.getId(), system.getSystemType(), getClass(), detachMethod, null, null);
// Expand the source and target Volumes
String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, source.getPool(), volumeId, size, task);
// resync source and target again
waitFor = createSyncSteps(workflow, expandStep, source, system);
} else {
if (volumes.size() == 1) {
// split all members the group
Workflow.Method splitMethod = splitSRDFGroupLinkMethod(system.getId(), source.getId(), target.getId(), false);
String splitStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), splitMethod, null, null);
// Second we detach the group...
Workflow.Method detachMethod = detachGroupPairsMethod(system.getId(), source.getId(), target.getId());
Workflow.Method resumeMethod = resumeGroupPairsMethod(system.getId(), source.getId(), target.getId());
String detachMirrorStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, splitStep, system.getId(), system.getSystemType(), getClass(), detachMethod, resumeMethod, null);
// Expand the source and target Volumes
String expandStep = addExpandBlockVolumeSteps(workflow, detachMirrorStep, source.getPool(), volumeId, size, task);
// re-establish again
List<URI> sourceURIs = new ArrayList<URI>();
sourceURIs.add(source.getId());
List<URI> targetURIs = new ArrayList<URI>();
targetURIs.add(target.getId());
Workflow.Method createGroupsMethod = createSrdfCgPairsMethod(system.getId(), sourceURIs, targetURIs, null);
waitFor = workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, expandStep, system.getId(), system.getSystemType(), getClass(), createGroupsMethod, null, null);
} else {
// First we remove the sync pair from Async CG...
Workflow.Method removeAsyncPairMethod = removePairFromGroup(system.getId(), source.getId(), target.getId(), true);
List<URI> sourceUris = new ArrayList<URI>();
sourceUris.add(system.getId());
String removePairFromGroupWorkflowDesc = String.format(REMOVE_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
String detachVolumePairWorkflowDesc = String.format(DETACH_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
Workflow.Method addSyncPairMethod = addVolumePairsToCgMethod(system.getId(), sourceUris, group.getId(), null);
String removeAsyncPairStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, removePairFromGroupWorkflowDesc, waitFor, system.getId(), system.getSystemType(), getClass(), removeAsyncPairMethod, addSyncPairMethod, null);
// split the removed async pair
Workflow.Method suspend = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
Workflow.Method resumeSyncPairMethod = resumeSyncPairMethod(system.getId(), source.getId(), target.getId());
String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, removeAsyncPairStep, system.getId(), system.getSystemType(), getClass(), suspend, resumeSyncPairMethod, null);
// Finally we detach the removed async pair...
Workflow.Method detachAsyncPairMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
Workflow.Method createSyncPairMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, detachVolumePairWorkflowDesc, suspendStep, system.getId(), system.getSystemType(), getClass(), detachAsyncPairMethod, createSyncPairMethod, null);
// Expand the source and target Volumes
String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, source.getPool(), volumeId, size, task);
// create Relationship again
waitFor = createSrdfCGPairStepsOnPopulatedGroup(source, expandStep, workflow);
}
}
}
}
} catch (Exception e) {
log.error("Failed SRDF Expand Volume operation ", e);
completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
throw e;
}
return waitFor;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.
the class SRDFDeviceController method createNonCGSRDFVolumes.
protected void createNonCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, Map<URI, Volume> uriVolumeMap) {
for (VolumeDescriptor sourceDescriptor : sourceDescriptors) {
Volume source = uriVolumeMap.get(sourceDescriptor.getVolumeURI());
// this will be null for normal use cases except vpool change
URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
log.info("VPoolChange URI {}", vpoolChangeUri);
StringSet srdfTargets = source.getSrdfTargets();
for (String targetStr : srdfTargets) {
URI targetURI = URI.create(targetStr);
Volume target = uriVolumeMap.get(targetURI);
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
Workflow.Method createMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), targetURI, vpoolChangeUri);
Workflow.Method rollbackMethod = rollbackSRDFLinkMethod(system.getId(), source.getId(), targetURI, false);
// Ensure CreateElementReplica steps are executed sequentially (CQ613404)
waitFor = workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), createMethod, rollbackMethod, null);
}
}
}
Aggregations