use of com.emc.storageos.db.client.model.StringSet 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.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class SRDFDeviceController method rollbackAddSyncVolumePairStep.
public boolean rollbackAddSyncVolumePairStep(final URI systemURI, final List<URI> sourceURIs, final List<URI> targetURIs, final boolean isGroupRollback, final String opId) {
log.info("START rollback srdf volume pair");
TaskCompleter completer = new SRDFMirrorRollbackCompleter(sourceURIs, opId);
try {
StorageSystem system = getStorageSystem(systemURI);
List<Volume> sources = dbClient.queryObject(Volume.class, sourceURIs);
for (Volume source : sources) {
StringSet targets = source.getSrdfTargets();
for (String targetStr : targets) {
URI targetURI = URI.create(targetStr);
if (!targetURIs.contains(targetURI)) {
continue;
}
Volume target = dbClient.queryObject(Volume.class, targetURI);
rollbackAddSyncVolumePair(system, source, target);
}
}
} catch (Exception e) {
log.warn("Error during rollback for adding sync pairs", e);
} finally {
return completeAsReady(completer, opId);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VPlexSrdfUtil method getSrdfOrVplexTargets.
/**
* Returns the vplex front volume ids for the srdf targets if they have a vplex volume,
* otherwise returns the original srdf target id
* @param dbClient - DbClient handle
* @param srdfVolume - An Srdf volume having targets
* @return String set of volume ids for either vplex/srdf volume or srdf volume in target list
*/
public static StringSet getSrdfOrVplexTargets(DbClient dbClient, Volume srdfVolume) {
StringSet targets = new StringSet();
for (String targetVolumeId : srdfVolume.getSrdfTargets()) {
URI srdfTargetUri = URI.create(targetVolumeId);
URI vplexTargetUri = Volume.fetchVplexVolume(dbClient, srdfTargetUri);
if (vplexTargetUri != null) {
targets.add(vplexTargetUri.toString());
} else {
targets.add(srdfTargetUri.toString());
}
}
return targets;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class BlockDeviceController method restoreSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void restoreSnapshotSession(URI systemURI, URI snapSessionURI, Boolean updateStatus, String opId) {
BlockSnapshotSession snapshotSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
TaskCompleter completer = new BlockSnapshotSessionRestoreWorkflowCompleter(snapshotSession.getId(), updateStatus, opId);
try {
// Get a new workflow to restore the snapshot session.
Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_SNAPSHOT_SESSION_WF_NAME, false, opId);
_log.info("Created new workflow to restore snapshot session {} with operation id {}", snapSessionURI, opId);
String waitFor = null;
// Check if we are dealing with a single volume or a group...
BlockObject sourceObj = null;
if (snapshotSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshotSession.getReplicationGroupInstance())) {
// We need a single source volume for the session.
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapshotSession.getConsistencyGroup());
List<Volume> nativeVolumes = BlockConsistencyGroupUtils.getActiveNativeVolumesInCG(cg, _dbClient);
// get source group name from the session.
String sourceGroupName = snapshotSession.getReplicationGroupInstance();
for (Volume volume : nativeVolumes) {
if (sourceGroupName.equals(volume.getReplicationGroupInstance())) {
sourceObj = volume;
// get source volume which matches session's RG name
break;
}
}
} else {
sourceObj = BlockObject.fetch(_dbClient, snapshotSession.getParent().getURI());
}
if (sourceObj instanceof Volume && isNonSplitSRDFTargetVolume((Volume) sourceObj)) {
// PRIOR to Restoring R2 Device from its session, we need to
// a) SUSPEND the R1-R2 pair if the Copy Mode is ACTIVE Or
// b) SPLIT the R1-R2 pair if the Copy Mode is SYNC/ ASYNC
Volume sourceVolume = (Volume) sourceObj;
URI srdfSourceVolumeURI = sourceVolume.getSrdfParent().getURI();
Volume srdfSourceVolume = _dbClient.queryObject(Volume.class, srdfSourceVolumeURI);
URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
if (Mode.ACTIVE.equals(Mode.valueOf(sourceVolume.getSrdfCopyMode()))) {
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId(), workflow);
} else {
// split all members the group
Workflow.Method splitMethod = srdfDeviceController.splitSRDFGroupLinkMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId(), false);
Workflow.Method splitRollbackMethod = srdfDeviceController.resumeGroupPairsMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId());
waitFor = workflow.createStep(SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_GROUP, SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, srdfSourceStorageSystemURI, getDeviceType(srdfSourceStorageSystemURI), SRDFDeviceController.class, splitMethod, splitRollbackMethod, null);
}
} else if (sourceObj instanceof Volume && isNonSplitSRDFSourceVolume((Volume) sourceObj)) {
// PRIOR to Restoring R1 Device from its session, we need to SUSPEND the R1-R2 pair if the Copy Mode is
// ACTIVE
Volume srdfSourceVolume = (Volume) sourceObj;
URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
StringSet targets = srdfSourceVolume.getSrdfTargets();
if (null != targets) {
for (String target : targets) {
if (NullColumnValueGetter.isNotNullValue(target)) {
Volume srdfTargetVolume = _dbClient.queryObject(Volume.class, URI.create(target));
if (null != srdfTargetVolume && Mode.ACTIVE.equals(Mode.valueOf(srdfTargetVolume.getSrdfCopyMode()))) {
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
}
break;
}
}
}
}
// Create the workflow step to restore the snapshot session.
waitFor = workflow.createStep(RESTORE_SNAPSHOT_SESSION_STEP_GROUP, String.format("Restore snapshot session %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), restoreBlockSnapshotSessionMethod(systemURI, snapSessionURI), rollbackMethodNullMethod(), null);
// Execute the workflow.
workflow.executePlan(completer, "Restore block snapshot session successful");
} catch (Exception e) {
_log.error("Restore block snapshot session failed", e);
ServiceCoded serviceException = DeviceControllerException.exceptions.restoreBlockSnapshotSessionFailed(e);
completer.error(_dbClient, serviceException);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileDeviceController method copyPropertiesToSave.
private void copyPropertiesToSave(FileExportRule dest, ExportRule orig, FileShare fs, FileDeviceInputOutput args) {
_log.info("Origin {}", orig.toString());
String exportPath = args.getExportPath();
// This export path is the one that is figured out at the device.
// Make sure you set the path on args object while doing the operation. Check for
// <Device>FileStorageDeviceXXX.java
dest.setExportPath(exportPath);
dest.setSecFlavor(orig.getSecFlavor());
dest.setAnon(orig.getAnon());
if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
_log.info("Read Only Hosts {}", dest.getReadOnlyHosts());
}
if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
_log.info("Read Write Hosts {}", dest.getReadWriteHosts());
}
if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
dest.setRootHosts(new StringSet(orig.getRootHosts()));
_log.info("Root hosts {}", dest.getRootHosts());
}
// Set this always at the end -- Thats how the model is defined.
if (!args.getFileOperation()) {
dest.setSnapshotId(args.getSnapshotId());
} else {
dest.setFileSystemId(fs.getId());
}
// Figure out Storage Port Network id to build the mount point.
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, fs.getStoragePort());
String mountPoint = ExportUtils.getFileMountPoint(storagePort.getPortNetworkId(), exportPath);
dest.setMountPoint(mountPoint);
// dest.calculateExportRuleIndex();
if ((orig.getDeviceExportId() != null) && (!orig.getDeviceExportId().isEmpty())) {
dest.setDeviceExportId(orig.getDeviceExportId());
} else if ((args.getObjIdOnDevice() != null) && (!args.getObjIdOnDevice().isEmpty())) {
dest.setDeviceExportId(args.getObjIdOnDevice());
}
// _log.info("New File Export Rule Object {}", dest);
_log.info("Dest After {}", dest.toString());
}
Aggregations