use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method resyncGroupSnapshots.
@Override
public void resyncGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
if (storage.checkIfVmax3()) {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
// Check if the consistency group exists
String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
storage = findProviderFactory.withGroup(storage, consistencyGroupName).find();
if (storage == null) {
ServiceError error = DeviceControllerErrors.smis.noConsistencyGroupWithGivenName();
taskCompleter.error(_dbClient, error);
return;
}
String snapshotGroupName = snapshotObj.getReplicationGroupInstance();
CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, snapshotGroupName);
if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
CIMObjectPath cimJob = null;
CIMArgument[] restoreCGSnapInput = _helper.getResyncSnapshotWithWaitInputArguments(groupSynchronized);
cimJob = _helper.callModifyReplica(storage, restoreCGSnapInput);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockResyncSnapshotJob(cimJob, storage.getId(), taskCompleter)));
} else {
ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(consistencyGroupName);
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
String message = String.format("Generic exception when trying to resynchronizing consistency group snapshots on array %s", storage.getSerialNumber());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("resyncGroupSnapshots", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method restoreSingleVolumeSnapshot.
/**
* Implementation for restoring of a single volume snapshot restore. That is, this
* volume is independent of other volumes and a snapshot was taken previously, and
* now we want to restore that snap to the original volume.
*
* @param storage [required] - StorageSystem object representing the array
* @param volume [required] - Volume URI for the volume to be restored
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param taskCompleter - TaskCompleter object used for the updating operation status.
*/
@Override
public void restoreSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
Volume vol = _dbClient.queryObject(Volume.class, volume);
try {
_helper.doApplyRecoverPointTag(storage, vol, false);
callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
BlockSnapshot from = _dbClient.queryObject(BlockSnapshot.class, snapshot);
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, from);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
terminateAnyRestoreSessions(storage, from, volume, taskCompleter);
}
CIMObjectPath cimJob;
if (storage.checkIfVmax3()) {
Volume to = _dbClient.queryObject(Volume.class, volume);
cimJob = _helper.callModifySettingsDefineState(storage, _helper.getRestoreFromSnapshotInputArguments(storage, to, from));
} else {
cimJob = _helper.callModifyReplica(storage, _helper.getRestoreFromReplicaInputArguments(syncObjectPath));
}
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(cimJob, storage.getId(), taskCompleter)));
} catch (WBEMException e) {
String message = String.format("Error encountered when trying to restore from snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
_log.error(message, e);
try {
// Re-enable the RP tag.
_log.info(String.format("Enabling the RecoverPoint tag on volume %s", volume.toString()));
_helper.doApplyRecoverPointTag(storage, vol, true);
} catch (Exception ex) {
_log.error(String.format("An error has occured trying to enable the RecoverPoint tag on volume %s."), ex);
}
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
} catch (Exception e) {
String message = String.format("Generic exception when trying to restore from snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
_log.error(message, e);
try {
// Re-enable the RP tag.
_log.info(String.format("Enabling the RecoverPoint tag on volume %s", volume.toString()));
_helper.doApplyRecoverPointTag(storage, vol, true);
} catch (Exception ex) {
_log.error(String.format("An error has occured trying to enable the RecoverPoint tag on volume %s."), ex);
}
ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method linkSnapshotSessionTargetGroup.
@Override
public void linkSnapshotSessionTargetGroup(StorageSystem system, URI snapshotSessionURI, List<URI> snapSessionSnapshotURIs, String copyMode, Boolean targetsExist, TaskCompleter completer) throws DeviceControllerException {
_log.info("Link new target group to snapshot session group START");
CIMObjectPath targetGroupPath = null;
List<String> targetDeviceIds = new ArrayList<>();
// Gather all snapshots to be created
List<URI> snapshotUris = snapSessionSnapshotURIs;
List<BlockSnapshot> snapshots = newArrayList(_dbClient.queryIterativeObjects(BlockSnapshot.class, snapshotUris));
final Map<URI, BlockSnapshot> uriToSnapshot = new HashMap<>();
BlockSnapshot sampleSnapshot = snapshots.get(0);
BlockObject sampleParent = BlockObject.fetch(_dbClient, sampleSnapshot.getParent().getURI());
try {
String sourceGroupName;
String targetGroupName;
if (!targetsExist) {
// This is the normal scenario for linking group targets to a group snapshot session.
sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sampleParent, _dbClient);
// Group snapshots parent volumes by their pool and size
Map<String, List<Volume>> volumesBySizeMap = new HashMap<>();
for (BlockSnapshot target : snapshots) {
uriToSnapshot.put(target.getId(), target);
Volume parent = _dbClient.queryObject(Volume.class, target.getParent().getURI());
String key = parent.getPool() + "-" + parent.getCapacity();
if (volumesBySizeMap.containsKey(key)) {
volumesBySizeMap.get(key).add(parent);
} else {
volumesBySizeMap.put(key, newArrayList(parent));
}
}
// Create snapshot target volumes
for (Entry<String, List<Volume>> entry : volumesBySizeMap.entrySet()) {
final List<Volume> volumes = entry.getValue();
final Volume volume = volumes.get(0);
final URI poolId = volume.getPool();
// get respective group path for volume storage pool
CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(system, system, volume, null);
// Create target devices based on the array model
final List<String> newDeviceIds = kickOffTargetDevicesCreation(system, volumeGroupPath, sourceGroupName, null, false, true, volumes.size(), poolId, volume.getCapacity(), completer);
targetDeviceIds.addAll(newDeviceIds);
}
// Create target device group
targetGroupPath = ReplicationUtils.createTargetDeviceGroup(system, sourceGroupName, targetDeviceIds, completer, _dbClient, _helper, _cimPath, SYNC_TYPE.SNAPSHOT);
_log.info("Created target device group: {}", targetGroupPath);
targetGroupName = (String) targetGroupPath.getKeyValue(CP_INSTANCE_ID);
// Update the snapshots with the ReplicationGroup InstanceID
for (BlockSnapshot snapshot : snapshots) {
snapshot.setReplicationGroupInstance(targetGroupName);
}
_dbClient.updateObject(snapshots);
} else {
// already exist. First we setup of the snapshot map.
for (BlockSnapshot target : snapshots) {
uriToSnapshot.put(target.getId(), target);
}
// The parent in this case is a BlockSnapshot and the source group is the
// replication group for the snapshot. We eliminate the system prefix and
// serial number from the replication group, to get simply the group name
// as in the case above.
sourceGroupName = ((BlockSnapshot) sampleParent).getReplicationGroupInstance();
int groupNameStartIndex = sourceGroupName.indexOf("+") + 1;
sourceGroupName = sourceGroupName.substring(groupNameStartIndex);
// The target in this case is actually a source volume and the target group
// is the source volume group, which we can get from the parent's replication group instance.
// Note that we can use the sample parent because it references the same
// repliaction group as the source volume.
targetGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sampleParent, _dbClient);
// Get the CIM object path for the target group.
targetGroupPath = _cimPath.getReplicationGroupPath(system, targetGroupName);
}
// Now link the target group to the array snapshots represented by the session.
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapshotSessionURI);
String syncAspectPath = snapSession.getSessionInstance();
CIMObjectPath settingsStatePath = _cimPath.getGroupSynchronizedSettingsPath(system, sourceGroupName, syncAspectPath);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
inArgs = _helper.getModifySettingsDefinedStateForLinkTargetGroup(system, settingsStatePath, targetGroupPath, copyMode);
_helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
SmisBlockSnapshotSessionLinkTargetGroupJob job = new SmisBlockSnapshotSessionLinkTargetGroupJob(jobPath, system.getId(), completer);
job.setSourceGroupName(sourceGroupName);
job.setTargetGroupName(targetGroupName);
job.setSnapSessionInstance(snapSession.getSessionInstance());
Map<String, URI> srcNativeIdToSnapshot = Maps.uniqueIndex(snapshotUris, new Function<URI, String>() {
@Override
public String apply(URI input) {
return uriToSnapshot.get(input).getSourceNativeId();
}
});
job.setSrcNativeIdToSnapshotMap(srcNativeIdToSnapshot);
ControllerServiceImpl.enqueueJob(new QueueJob(job));
_log.info("Link new target group to snapshot session group FINISH");
} catch (Exception e) {
_log.error("Exception creating and linking snapshot session targets", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
completer.error(_dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method createSnapshotSession.
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public void createSnapshotSession(StorageSystem system, URI snapSessionURI, TaskCompleter completer) throws DeviceControllerException {
if (system.checkIfVmax3()) {
// Only supported for VMAX3 storage systems.
try {
_log.info("Create snapshot session operation START");
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
URI sourceObjURI = snapSession.getParent().getURI();
BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceObjURI);
// Need to terminate an restore sessions, so that we can
// restore from the same snapshot multiple times
terminateAnyRestoreSessionsForVolume(system, sourceObj, completer);
URI tenantURI = null;
if (URIUtil.isType(sourceObjURI, Volume.class)) {
tenantURI = ((Volume) sourceObj).getTenant().getURI();
} else {
Volume sourceObjParent = _dbClient.queryObject(Volume.class, ((BlockSnapshot) sourceObj).getParent().getURI());
tenantURI = sourceObjParent.getTenant().getURI();
}
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, tenantURI);
String tenantName = tenant.getLabel();
String snapSessionLabelToUse = _nameGenerator.generate(tenantName, snapSession.getSessionLabel(), snapSessionURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
CIMObjectPath sourceObjPath = _cimPath.getBlockObjectPath(system, sourceObj);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
inArgs = _helper.getCreateSynchronizationAspectInput(sourceObjPath, false, snapSessionLabelToUse, new Integer(SmisConstants.MODE_SYNCHRONOUS));
_helper.invokeMethod(system, replicationSvcPath, SmisConstants.CREATE_SYNCHRONIZATION_ASPECT, inArgs, outArgs);
CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionCreateJob(jobPath, system.getId(), completer)));
} catch (Exception e) {
_log.error("Exception creating snapshot session ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
completer.error(_dbClient, error);
}
} else {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method linkSnapshotSessionTarget.
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public void linkSnapshotSessionTarget(StorageSystem system, URI snapSessionURI, URI snapshotURI, String copyMode, Boolean targetExists, TaskCompleter completer) throws DeviceControllerException {
if (system.checkIfVmax3()) {
// Only supported for VMAX3 storage systems.
try {
_log.info("Link new target {} to snapshot session {} START", snapshotURI, snapSessionURI);
CIMObjectPath sourcePath = null;
CIMObjectPath targetPath = null;
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
URI sourceObjURI = snapshot.getParent().getURI();
BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceObjURI);
if (!targetExists) {
// of snapshot.
if (URIUtil.isType(sourceObjURI, Volume.class)) {
// Provision the new target volume.
Volume sourceVolume = (Volume) sourceObj;
CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(system, system, sourceVolume, null);
// COP-17240: For VMAX3, we will derive the target volumes from the source volumes SRP Pool
CIMObjectPath poolPath = _helper.getVolumeStoragePoolPath(system, sourceVolume);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, sourceVolume.getTenant().getURI());
String tenantName = tenant.getLabel();
String label = _nameGenerator.generate(tenantName, snapshot.getLabel(), snapshotURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
List<String> targetDeviceIds = createTargetDevices(system, poolPath, volumeGroupPath, null, "SingleSnapshot", label, Boolean.FALSE, 1, sourceVolume.getCapacity(), completer);
if (targetDeviceIds.isEmpty()) {
throw DeviceControllerException.exceptions.createTargetForSnapshotSessionFailed(snapSessionURI.toString());
}
sourcePath = _cimPath.getVolumePath(system, sourceVolume.getNativeId());
targetPath = _cimPath.getVolumePath(system, targetDeviceIds.get(0));
// Set the native id into the snapshot. This will allow a rollback
// to delete the target if we subsequently fail to link the target
// to the array snapshot.
String targetDeviceId = targetDeviceIds.get(0);
snapshot.setNativeId(targetDeviceId);
_dbClient.updateObject(snapshot);
} else {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
} else {
// When the passed flag indicates the target exists and just needs to be
// linked, this is the special case where we link a source volume to a snapshot
// session of a linked target volume for the purpose of restoring the source
// volume from the linked target volume for VMAX3. In this case, the source
// of the passed snapshot is itself a BlockSnapshot.
sourcePath = _cimPath.getBlockObjectPath(system, sourceObj);
targetPath = _cimPath.getBlockObjectPath(system, snapshot);
}
// Now link the target to the array snapshot represented by the session.
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
String syncAspectPath = snapSession.getSessionInstance();
CIMObjectPath settingsStatePath = _cimPath.getSyncSettingsPath(system, sourcePath, syncAspectPath);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
inArgs = _helper.getModifySettingsDefinedStateForLinkTargets(system, settingsStatePath, targetPath, copyMode);
_helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionLinkTargetJob(jobPath, system.getId(), snapshotURI, copyMode, completer)));
} catch (Exception e) {
_log.error("Exception creating and linking snapshot session target", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
completer.error(_dbClient, error);
}
} else {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
}
Aggregations