Search in sources :

Example 1 with SmisBlockRestoreSnapshotJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method restoreGroupSnapshots.

/**
 * Implementation should restore the set of snapshots that were taken for a set of
 * volumes in a consistency group. That is, at some time there was a consistency
 * group of volumes created and snapshot was taken of these; these snapshots would
 * belong to a "snap-set". This restore operation, will restore the volumes in the
 * consistency group from this snap-set. Any snapshot from the snap-set can be
 * provided to restore the whole snap-set.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @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 restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
        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;
            if (storage.checkIfVmax3()) {
                if (snapshotObj.getSettingsInstance() == null) {
                    throw DeviceControllerException.exceptions.snapSettingsInstanceNull(snapshotObj.getSnapsetLabel(), snapshotObj.getId().toString());
                }
                // there could only be one restored snapshot per device at a time
                // terminate any pre-existing one in favor of the new one
                terminateAnyRestoreSessions(storage, snapshotObj, snapshot, taskCompleter);
                CIMObjectPath settingsPath = _cimPath.getGroupSynchronizedSettingsPath(storage, consistencyGroupName, snapshotObj.getSettingsInstance());
                cimJob = _helper.callModifySettingsDefineState(storage, _helper.getRestoreFromSettingsStateInputArguments(settingsPath, false));
            } else {
                CIMArgument[] restoreCGSnapInput = _helper.getRestoreFromReplicaInputArguments(groupSynchronized);
                cimJob = _helper.callModifyReplica(storage, restoreCGSnapInput);
            }
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(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 restoring snapshots from consistency group on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreGroupSnapshots", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 2 with SmisBlockRestoreSnapshotJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob in project coprhd-controller by CoprHD.

the class VnxSnapshotOperations 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 {
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
        BlockSnapshot from = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume to = _dbClient.queryObject(Volume.class, volume);
        CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, from);
        if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
            CIMObjectPath cimJob;
            if (_helper.isThinlyProvisioned(storage, to) || isBasedOnVNXThinStoragePool(to)) {
                _log.info("Volume {} is thinly provisioned or based on a Thin StoragePool, need to deactivate the volume before restore", to.getLabel());
                deactivateSnapshot(storage, from, syncObjectPath);
                cimJob = _helper.callModifySettingsDefineState(storage, _helper.getRestoreFromSnapshotInputArguments(storage, to, from));
            } else {
                // Thick volumes do not need to be deactivated prior to restore.
                // The can be restored directly. WaitForCopyState should not be supplied in this scenario
                _log.info("Volume {} is not thinly provisioned, will attempt restore", to.getLabel());
                cimJob = _helper.callModifyReplica(storage, _helper.getRestoreFromReplicaInputArgumentsWithForce(syncObjectPath));
            }
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(cimJob, storage.getId(), taskCompleter)));
        } else {
            ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(storage.getLabel());
            taskCompleter.error(_dbClient, error);
        }
    } 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);
        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);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob) WBEMException(javax.wbem.WBEMException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 3 with SmisBlockRestoreSnapshotJob

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

Example 4 with SmisBlockRestoreSnapshotJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob in project coprhd-controller by CoprHD.

the class VnxSnapshotOperations method restoreGroupSnapshots.

/**
 * Implementation should restore the set of snapshots that were taken for a set of
 * volumes in a consistency group. That is, at some time there was a consistency
 * group of volumes created and snapshot was taken of these; these snapshots would
 * belong to a "snap-set". This restore operation, will restore the volumes in the
 * consistency group from this snap-set. Any snapshot from the snap-set can be
 * provided to restore the whole snap-set.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshotURI [required] - BlockSnapshot URI representing the previously created
 *            snap for the volume
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshotURI, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshotURI));
        final BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
        // Check if the consistency group exists
        final 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;
        }
        final String snapshotGroupName = snapshotObj.getReplicationGroupInstance();
        final CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, snapshotGroupName);
        final CIMInstance groupSynchronizedInstance = _helper.checkExists(storage, groupSynchronized, false, false);
        List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
        if (groupSynchronizedInstance != null) {
            // would mean that there wasn't any export performed.
            if (snapshotObj.getNeedsCopyToTarget()) {
                _log.info("Consistency group {} snapshots require copy-to-target", consistencyGroupName);
                List<URI> snapshotList = new ArrayList<URI>();
                for (BlockSnapshot snapshot : snapshots) {
                    snapshotList.add(snapshot.getId());
                }
                internalGroupSnapCopyToTarget(storage, snapshotObj, snapshotList);
            }
            CIMObjectPath settingsPathFromOutputArg = null;
            // Deactivate Synchronization if not already deactivated
            String copyState = groupSynchronizedInstance.getPropertyValue(SmisConstants.CP_COPY_STATE).toString();
            if (!String.valueOf(SmisConstants.INACTIVE_VALUE).equalsIgnoreCase(copyState)) {
                CIMArgument[] deactivateGroupInput = _helper.getDeactivateSnapshotSynchronousInputArguments(groupSynchronized);
                CIMArgument[] outArgs = new CIMArgument[5];
                _helper.callModifyReplica(storage, deactivateGroupInput, outArgs);
                settingsPathFromOutputArg = (CIMObjectPath) outArgs[0].getValue();
            }
            final boolean isSynchronizationAspectSet = snapshotObj.getSettingsGroupInstance() != null;
            // Get the Clar_SettingsDefineState_RG_SAFS path
            final CIMObjectPath settingsPath = isSynchronizationAspectSet ? _helper.getSettingsDefineStateForSourceGroup(storage, snapshotObj.getSettingsGroupInstance()) : settingsPathFromOutputArg;
            // If the Clar_SynchronizationAspectForSourceGroup hasn't been set in the snapshots, then set it.
            if (!isSynchronizationAspectSet) {
                CIMObjectPath syncPath = (CIMObjectPath) settingsPath.getKey(SmisConstants.CP_SETTING_DATA).getValue();
                String instanceId = (String) syncPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
                for (BlockSnapshot it : snapshots) {
                    it.setSettingsGroupInstance(instanceId);
                }
                _dbClient.persistObject(snapshots);
            }
            // Restore snapshot
            CIMArgument[] restoreInput = _helper.getRestoreFromSettingsStateInputArguments(settingsPath, false);
            CIMObjectPath cimJob = _helper.callModifySettingsDefineState(storage, restoreInput);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(cimJob, storage.getId(), taskCompleter)));
        } else {
            taskCompleter.ready(_dbClient);
        }
    } catch (Exception e) {
        String message = String.format("Generic exception when trying to restoring snapshots from consistency group on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreGroupSnapshots", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)4 SmisBlockRestoreSnapshotJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockRestoreSnapshotJob)4 CIMObjectPath (javax.cim.CIMObjectPath)4 WBEMException (javax.wbem.WBEMException)4 Volume (com.emc.storageos.db.client.model.Volume)2 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 CIMArgument (javax.cim.CIMArgument)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 CIMInstance (javax.cim.CIMInstance)1