use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method createVplexCG.
/**
* Create a Vplex CG within a step. This routine does not complete the step unless there is an error (and it returns false).
* @param vplexSystem -- StorageSystem of the VPLEX
* @param cg -- BlockConsistencyGroup object
* @param protoVolume -- A prototypical Vplex volume
* @param stepId -- String stepId, completed only if error
* @return true if no error, false if error
*/
private boolean createVplexCG(StorageSystem vplexSystem, BlockConsistencyGroup cg, Volume protoVolume, String stepId) {
try {
VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
log.info("Got VPLEX API client.");
// Check to see if it was created since we defined the workflow.
if (cg.created(vplexSystem.getId())) {
StringSet cgNames = cg.getSystemConsistencyGroups().get(vplexSystem.getId().toString());
log.info("Consistency group(s) already created: " + cgNames.toString());
return true;
}
// We need to know on what cluster to create the consistency group.
// The cluster would be determined by the virtual array specified in
// a volume creation request, which is the virtual array of the
// passed virtual volumes. Get the virtual array for one of the
// vplex volumes.
// Lets determine the VPlex consistency group that need to be created for this volume.
ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(protoVolume, cg);
String cgName = clusterConsistencyGroup.getCgName();
String clusterName = clusterConsistencyGroup.getClusterName();
boolean isDistributed = clusterConsistencyGroup.isDistributed();
URI vaURI = protoVolume.getVirtualArray();
log.info("Got virtual array for VPLEX volume.");
// Now we can create the consistency group.
client.createConsistencyGroup(cgName, clusterName, isDistributed);
log.info("Created VPLEX consistency group.");
// Now update the CG in the DB.
cg.setVirtualArray(vaURI);
cg.addSystemConsistencyGroup(vplexSystem.getId().toString(), BlockConsistencyGroupUtils.buildClusterCgName(clusterName, cgName));
cg.addConsistencyGroupTypes(Types.VPLEX.name());
dbClient.updateObject(cg);
log.info("Updated consistency group in DB.");
} catch (VPlexApiException vex) {
log.error("Exception creating consistency group: " + vex.getMessage(), vex);
WorkflowStepCompleter.stepFailed(stepId, vex);
return false;
} catch (Exception ex) {
log.error("Exception creating consistency group: " + ex.getMessage(), ex);
String opName = ResourceOperationTypeEnum.CREATE_CONSISTENCY_GROUP.getName();
ServiceError serviceError = VPlexApiException.errors.createConsistencyGroupFailed(opName, ex);
WorkflowStepCompleter.stepFailed(stepId, serviceError);
return false;
}
return true;
}
use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method setCGProperties.
/**
* Called by the workflow to set the properties for an existing VPLEX
* consistency group with no volumes.
*
* @param vplexURI The URI of the VPLEX storage system.
* @param cgURI The URI of the Bourne consistency group.
* @param vplexVolumeURIs The URIs of the VPLEX volumes to be added to the
* consistency group.
* @param stepId The workflow step id.
*
* @throws WorkflowException When an error occurs updating the workflow step
* state.
*/
public void setCGProperties(URI vplexURI, URI cgURI, List<URI> vplexVolumeURIs, String stepId) throws WorkflowException {
try {
// Update workflow step.
WorkflowStepCompleter.stepExecuting(stepId);
log.info("Updated step state for consistency group properties to execute.");
// Lock the CG for the step duration.
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(dbClient, cgURI, vplexURI));
workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_VPLEX_CG));
// Get the API client.
StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, dbClient);
VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
log.info("Got VPLEX API client.");
// Get the consistency group
BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
// We need to know on what cluster to find the consistency group.
// The cluster would be determined by the virtual array specified in
// a volume creation request, which is the virtual array of the
// passed virtual volumes. Get the virtual array for one of the
// vplex volumes.
Volume firstVPlexVolume = getDataObject(Volume.class, vplexVolumeURIs.get(0), dbClient);
ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(firstVPlexVolume, cg);
String cgName = clusterConsistencyGroup.getCgName();
String clusterName = clusterConsistencyGroup.getClusterName();
boolean isDistributed = clusterConsistencyGroup.isDistributed();
// Now we can update the consistency group properties.
client.updateConsistencyGroupProperties(cgName, clusterName, isDistributed);
log.info("Updated VPLEX consistency group properties.");
// Update workflow step state to success.
WorkflowStepCompleter.stepSucceded(stepId);
log.info("Updated workflow step for consistency group properties to success.");
} catch (VPlexApiException vae) {
log.error("Exception updating consistency group properties: " + vae.getMessage(), vae);
WorkflowStepCompleter.stepFailed(stepId, vae);
} catch (Exception ex) {
log.error("Exception updating consistency group properties: " + ex.getMessage(), ex);
ServiceError serviceError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method getClusterConsistencyGroup.
/**
* Maps a VPlex cluster/consistency group to its volumes.
*
* @param vplexVolume The virtual volume from which to obtain the VPlex cluster.
* @param clusterConsistencyGroupVolumes The map to store cluster/cg/volume relationships.
* @param cgName The VPlex consistency group name.
* @throws Exception
*/
@Override
public ClusterConsistencyGroupWrapper getClusterConsistencyGroup(Volume vplexVolume, BlockConsistencyGroup cg) throws Exception {
ClusterConsistencyGroupWrapper clusterConsistencyGroup = new ClusterConsistencyGroupWrapper();
// these cases, we just set the cgName value only.
if (vplexVolume.getAssociatedVolumes() != null && !vplexVolume.getAssociatedVolumes().isEmpty()) {
String clusterName = VPlexControllerUtils.getVPlexClusterName(dbClient, vplexVolume);
StringSet assocVolumes = vplexVolume.getAssociatedVolumes();
boolean distributed = false;
if (assocVolumes.size() > 1) {
distributed = true;
}
clusterConsistencyGroup.setClusterName(clusterName);
clusterConsistencyGroup.setDistributed(distributed);
}
clusterConsistencyGroup.setCgName(cg.getLabel());
return clusterConsistencyGroup;
}
use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method removeVplexVolumesFromSRDFTargetCG.
/**
* Removes volumes from SRDF Target.
* @param vplexURI
* @param vplexVolumeURIs
* @param stepId
* @throws WorkflowException
*/
public void removeVplexVolumesFromSRDFTargetCG(URI vplexURI, List<URI> vplexVolumeURIs, String stepId) throws WorkflowException {
try {
WorkflowStepCompleter.stepExecuting(stepId);
Volume protoVolume = dbClient.queryObject(Volume.class, vplexVolumeURIs.get(0));
if (NullColumnValueGetter.isNullURI(protoVolume.getConsistencyGroup())) {
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, protoVolume.getConsistencyGroup());
if (consistencyGroup == null) {
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
// Remove the volumes from the ConsistencyGroup. Returns a codedError if failure.
ServiceCoded codedError = removeVolumesFromCGInternal(vplexURI, protoVolume.getConsistencyGroup(), vplexVolumeURIs);
if (codedError != null) {
WorkflowStepCompleter.stepFailed(stepId, codedError);
return;
}
// Determine if there are any remaining Vplex volumes in the consistency group.
List<Volume> vplexVolumesInCG = BlockConsistencyGroupUtils.getActiveVplexVolumesInCG(consistencyGroup, dbClient, null);
if (vplexVolumesInCG.isEmpty()) {
ClusterConsistencyGroupWrapper clusterCGWrapper = getClusterConsistencyGroup(protoVolume, consistencyGroup);
// No vplex volumes left, clean up the Vplex part of the consistency group.
// deleteCG will call the step completer.
deleteCG(vplexURI, consistencyGroup.getId(), clusterCGWrapper.getCgName(), clusterCGWrapper.getClusterName(), false, stepId);
} else {
// Vplex volumes left... we're finished.
WorkflowStepCompleter.stepSucceded(stepId);
}
} catch (Exception ex) {
log.info("Exception removing Vplex volumes from SRDF Target CG: " + ex.getMessage(), ex);
ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, svcError);
}
}
Aggregations