use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionRestoreJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method restoreSnapshotSession.
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public void restoreSnapshotSession(StorageSystem system, URI snapSessionURI, TaskCompleter completer) throws DeviceControllerException {
if (system.checkIfVmax3()) {
// Only supported for VMAX3 storage systems.
try {
_log.info("Restore snapshot session {} START", snapSessionURI);
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
String syncAspectPath = snapSession.getSessionInstance();
CIMObjectPath settingsStatePath = null;
BlockObject sourceObj = null;
if (snapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapSession.getReplicationGroupInstance())) {
_log.info("Restoring group snapshot session");
// We need a single source volume for the session.
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapSession.getConsistencyGroup());
List<Volume> nativeVolumes = BlockConsistencyGroupUtils.getActiveNativeVolumesInCG(cg, _dbClient);
// get source group name from the session.
String sourceGroupName = snapSession.getReplicationGroupInstance();
settingsStatePath = _cimPath.getGroupSynchronizedSettingsPath(system, sourceGroupName, syncAspectPath);
for (Volume volume : nativeVolumes) {
if (sourceGroupName.equals(volume.getReplicationGroupInstance())) {
sourceObj = volume;
// get source volume which matches session's RG name
break;
}
}
} else {
_log.info("Restoring single volume snapshot session");
sourceObj = BlockObject.fetch(_dbClient, snapSession.getParent().getURI());
CIMObjectPath sourcePath = _cimPath.getVolumePath(system, sourceObj.getNativeId());
settingsStatePath = _cimPath.getSyncSettingsPath(system, sourcePath, syncAspectPath);
}
// Terminate restore sessions.
terminateAnyRestoreSessions(system, null, sourceObj.getId(), completer);
// Invoke SMI-S method to restore snapshot session.
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
inArgs = _helper.getRestoreFromSettingsStateInputArguments(settingsStatePath, true);
_helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionRestoreJob(jobPath, system.getId(), completer)));
} catch (Exception e) {
_log.error("Exception restoring snapshot session", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
completer.error(_dbClient, error);
}
} else {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
}
Aggregations