use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class AbstractConsistencyGroupManager method removeVolumeFromCg.
@Override
public void removeVolumeFromCg(URI cgURI, Volume vplexVolume, VPlexApiClient client, boolean removeFromViPRCg) throws Exception {
BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
ClusterConsistencyGroupWrapper clusterCgWrapper = this.getClusterConsistencyGroup(vplexVolume, cg);
log.info("Removing volumes from consistency group: " + clusterCgWrapper.getCgName());
// Remove the volumes from the CG.
client.removeVolumesFromConsistencyGroup(Arrays.asList(vplexVolume.getDeviceLabel()), clusterCgWrapper.getCgName(), false);
if (removeFromViPRCg) {
vplexVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
dbClient.updateAndReindexObject(vplexVolume);
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class AbstractConsistencyGroupManager method getVplexCgName.
/**
* Gets the VPlex consistency group name that corresponds to the volume
* and BlockConsistencyGroup.
*
* @param volume The virtual volume used to determine cluster configuration.
* @param cgURI The BlockConsistencyGroup id.
* @return The VPlex consistency group name
* @throws Exception
*/
protected String getVplexCgName(Volume volume, URI cgURI) throws Exception {
BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(volume, cg);
return clusterConsistencyGroup.getCgName();
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class RPVplexConsistencyGroupManager method addStepsForCreateConsistencyGroup.
@Override
public String addStepsForCreateConsistencyGroup(Workflow workflow, String waitFor, StorageSystem vplexSystem, List<URI> vplexVolumeURIs, boolean willBeRemovedByEarlierStep) throws ControllerException {
// No volumes, all done.
if (vplexVolumeURIs.isEmpty()) {
log.info("No volumes specified consistency group.");
return waitFor;
}
// Grab the first volume
Volume firstVolume = getDataObject(Volume.class, vplexVolumeURIs.get(0), dbClient);
URI cgURI = firstVolume.getConsistencyGroup();
URI vplexURI = vplexSystem.getId();
String nextStep = waitFor;
// Load the ViPR consistency group. This single ViPR consistency group will map to
// potentially several different VPlex consistency groups.
BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
// Create a step to create the CG.
String stepMsg = String.format("Create and add volumes to VPLEX consistency group. VPLEX: %s (%s) Consistency group: %s (%s) Volumes: %s (%s) ", vplexSystem.getLabel(), vplexURI, cg.getLabel(), cg.getId(), getVolumeLabels(vplexVolumeURIs), StringUtils.collectionToCommaDelimitedString(vplexVolumeURIs));
nextStep = workflow.createStep(CREATE_CG_STEP, stepMsg, nextStep, vplexURI, vplexSystem.getSystemType(), this.getClass(), createCGMethod(vplexURI, cgURI, vplexVolumeURIs), createRemoveVolumesFromCGMethod(vplexURI, cgURI, vplexVolumeURIs), null);
log.info("Created step for consistency group creation and add volumes.");
return nextStep;
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method updateConsistencyGroupReadOnlyState.
/**
* Step to call the VPLEX to update the read-only flag on a consistency group.
* If the Vplex Api library detects the firmware does not properly handle the flag,
* a warning message is put in the SUCCESS status.
* @param vplexVolumeURIs -- List of at least some volumes in the consistency group.
* @param isReadOnly - if true marks read-only, false read-write
* @param stepId - Workflow step id
*/
public void updateConsistencyGroupReadOnlyState(List<URI> vplexVolumeURIs, Boolean isReadOnly, String stepId) {
try {
WorkflowStepCompleter.stepExecuting(stepId);
// Get the first virtual volume, as all volumes should be in the same CG
Volume vplexVolume = dbClient.queryObject(Volume.class, vplexVolumeURIs.get(0));
// Get the storage system for the Vplex.
StorageSystem vplexSystem = dbClient.queryObject(StorageSystem.class, vplexVolume.getStorageController());
// And from that a handle to the VplexApiClient
VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
// From that get the Consistency Group, if there is not one, just return success
if (NullColumnValueGetter.isNullURI(vplexVolume.getConsistencyGroup())) {
log.info("Volume has no ConsistencyGroup: " + vplexVolume.getLabel());
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, vplexVolume.getConsistencyGroup());
// Get the consistency group parameters.
ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(vplexVolume, cg);
String cgName = clusterConsistencyGroup.getCgName();
String clusterName = clusterConsistencyGroup.getClusterName();
boolean isDistributed = clusterConsistencyGroup.isDistributed();
// Make the call to update the consistency group read-only status
client.updateConsistencyGroupReadOnly(cgName, clusterName, isDistributed, isReadOnly);
// Complete the step
WorkflowStepCompleter.stepSucceded(stepId);
} catch (VPlexApiException ex) {
if (ServiceCode.VPLEX_API_FIRMWARE_UPDATE_NEEDED.equals(ex.getServiceCode())) {
// The firmware doesn't support read-only flag, inform the user, but do not fail.
WorkflowStepCompleter.stepSucceeded(stepId, ex.getLocalizedMessage());
} else {
log.info("Exception setting Consistency Group read-only state: " + ex.getMessage());
ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, svcError);
}
} catch (Exception ex) {
log.info("Exception setting Consistency Group read-only state: " + ex.getMessage());
ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, svcError);
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockObjectMultipleConsistencyGroupsMigration method migrateBlockConsistencyGroups.
/**
* Migrates all BlockConsistencyGroups. Migrates the type and deviceName fields
* too types and deviceNames fields. For VPlex only BlockConsistencyGroup objects,
* a mapping of VPlex storage system to VPlex cluster/cg name is added.
*/
private void migrateBlockConsistencyGroups() {
log.info("Migrating BlockConsistencyGroup objects.");
List<URI> cgURIs = dbClient.queryByType(BlockConsistencyGroup.class, true);
for (URI cgURI : cgURIs) {
BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, cgURI);
// RP+VPlex BlockConsistencyGroups at this point.
if (cg.getTypes() == null || cg.getTypes().isEmpty()) {
log.info("Migrating BlockConsistencyGroup {}.", cg.getLabel());
if (cg.getType() != null) {
cg.addConsistencyGroupTypes(cg.getType());
}
// We need to keep a map of the volume's storage controller to VPlex cluster/cg.
if (isVPlexCG(cg)) {
log.info("Migrating fields for VPlex BlockConsistencyGroup {}.", cg.getLabel());
// Set the type, as VPLEX CGS prior to 2.2 do not have a type set.
cg.addConsistencyGroupTypes(Types.VPLEX.name());
// Get the VPlex volumes associated with this CG.
final List<Volume> activeCGVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Volume.class, getVolumesByConsistencyGroup(cg.getId().toString()));
log.info("Found " + activeCGVolumes.size() + " volumes that belong to BlockConsistencyGroup " + cg.getLabel());
for (Volume cgVolume : activeCGVolumes) {
if (!NullColumnValueGetter.isNullURI(cgVolume.getStorageController())) {
// Look at each of the associated volumes and add a mapping of VPlex storage
// system to cluster/cg.
String clusterId = getVPlexClusterFromVolume(cgVolume);
log.info("Adding storage system to cluster/cg mapping for VPlex BlockConsistencyGroup " + cg.getLabel());
cg.addSystemConsistencyGroup(cgVolume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(clusterId, cg.getLabel()));
}
}
} else if (!NullColumnValueGetter.isNullURI(cg.getStorageController())) {
// Non-RP/Non-VPLEX/Non-RP+VPLEX
// Add an entry for the storage system -> consistency group name
cg.addSystemConsistencyGroup(cg.getStorageController().toString(), cg.getDeviceName());
}
// Remove type and deviceName fields
cg.setType(NullColumnValueGetter.getNullStr());
cg.setDeviceName(NullColumnValueGetter.getNullStr());
dbClient.updateObject(cg);
log.info("Migration of BlockConsistencyGroup {} complete.", cg.getLabel());
}
}
}
Aggregations