Search in sources :

Example 1 with SmisBlockSnapshotSessionRestoreJob

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();
    }
}
Also used : SmisBlockSnapshotSessionRestoreJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionRestoreJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMObjectPath(javax.cim.CIMObjectPath) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Aggregations

BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1 Volume (com.emc.storageos.db.client.model.Volume)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)1 SmisBlockSnapshotSessionRestoreJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionRestoreJob)1 CIMArgument (javax.cim.CIMArgument)1 CIMObjectPath (javax.cim.CIMObjectPath)1 WBEMException (javax.wbem.WBEMException)1