Search in sources :

Example 1 with SmisCloneRestoreJob

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

the class VmaxCloneOperations method restoreGroupClones.

/**
 * Implementation for restoring of clones in CG.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param clones [required] - URIs representing the previously created clones
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
@SuppressWarnings("rawtypes")
public void restoreGroupClones(StorageSystem storage, List<URI> clones, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("START restore group clone operation");
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, clones);
        Volume clone = _dbClient.queryObject(Volume.class, clones.get(0));
        Volume sourceVol = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
        String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVol, _dbClient);
        String replicationGroupName = clone.getReplicationGroupInstance();
        CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, replicationGroupName);
        if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
            CIMObjectPath cimJob = null;
            CIMArgument[] restoreCGCloneInput = _helper.getRestoreFromReplicaInputArgumentsWithForce(groupSynchronized);
            cimJob = _helper.callModifyReplica(storage, restoreCGCloneInput);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneRestoreJob(cimJob, storage.getId(), taskCompleter)));
        } else {
            ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(consistencyGroupName);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        String message = String.format("Exception when trying to restoring clones from consistency group on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreGroupClones", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisCloneRestoreJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneRestoreJob) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 2 with SmisCloneRestoreJob

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

the class AbstractCloneOperations method restoreFromSingleClone.

/**
 * Implementation for restoring of a single volume clone restore.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param volume [required] - Volume URI for the volume to be restored
 * @param clone [required] - URI representing the previously created clone
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
@SuppressWarnings("rawtypes")
public void restoreFromSingleClone(StorageSystem storage, URI clone, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("START restore Single clone operation");
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(clone));
        Volume cloneVol = _dbClient.queryObject(Volume.class, clone);
        Volume originalVol = _dbClient.queryObject(Volume.class, cloneVol.getAssociatedSourceVolume());
        CIMObjectPath syncObjectPath = _cimPath.getStorageSynchronized(storage, originalVol, storage, cloneVol);
        if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
            CIMArgument[] outArgs = new CIMArgument[5];
            CIMArgument[] inArgs = _helper.getRestoreFromReplicaInputArgumentsWithForce(syncObjectPath);
            _helper.callModifyReplica(storage, inArgs, outArgs);
            CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneRestoreJob(job, 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 clone %s on array %s", clone.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 clone %s on array %s", clone.toString(), storage.getSerialNumber());
        _log.error(message, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.restoreVolumeFromFullCopyFailed(e));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisCloneRestoreJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneRestoreJob) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 SmisCloneRestoreJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneRestoreJob)2 CIMArgument (javax.cim.CIMArgument)2 CIMObjectPath (javax.cim.CIMObjectPath)2 WBEMException (javax.wbem.WBEMException)1