Search in sources :

Example 1 with SmisBlockResyncSnapshotJob

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

the class VmaxSnapshotOperations method resyncSingleVolumeSnapshot.

/**
 * Implementation for a single volume snapshot resynchronization.
 *
 * @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 resyncSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        if (storage.checkIfVmax3()) {
            throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
        }
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
        BlockSnapshot from = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, from);
        CIMObjectPath cimJob = _helper.callModifyReplica(storage, _helper.getResyncSnapshotWithWaitInputArguments(syncObjectPath));
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockResyncSnapshotJob(cimJob, storage.getId(), taskCompleter)));
    } catch (WBEMException e) {
        String message = String.format("Error encountered when trying to resync 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 resync snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("resyncSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisBlockResyncSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResyncSnapshotJob) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) 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 2 with SmisBlockResyncSnapshotJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResyncSnapshotJob 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisBlockResyncSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResyncSnapshotJob) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) 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 3 with SmisBlockResyncSnapshotJob

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

the class AbstractCloneOperations method createSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void createSingleClone(StorageSystem storageSystem, URI sourceVolume, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
    _log.info("START createSingleClone operation");
    try {
        BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceVolume);
        URI tenantUri = null;
        Volume baseVolume = null;
        boolean isSourceSnap = false;
        if (sourceObj instanceof BlockSnapshot) {
            // In case of snapshot, get the tenant from its parent volume
            NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
            Volume parentVolume = _dbClient.queryObject(Volume.class, parentVolUri);
            tenantUri = parentVolume.getTenant().getURI();
            baseVolume = parentVolume;
            isSourceSnap = true;
        } else {
            // This is a default flow
            tenantUri = ((Volume) sourceObj).getTenant().getURI();
            baseVolume = (Volume) sourceObj;
        }
        // CTRL-1992: Need to resync any existing snapshot restore sessions, if applicable
        if (_helper.arraySupportsResync(storageSystem)) {
            CloseableIterator<CIMObjectPath> syncObjectIter = _cimPath.getSyncObjects(storageSystem, sourceObj);
            CIMObjectPath path = null;
            while (syncObjectIter.hasNext()) {
                path = syncObjectIter.next();
                CIMInstance instance = _helper.getInstance(storageSystem, path, false, false, SmisConstants.PS_COPY_STATE_AND_DESC_SYNCTYPE);
                String copyState = instance.getPropertyValue(SmisConstants.CP_COPY_STATE).toString();
                String copyStateDesc = instance.getPropertyValue(SmisConstants.EMC_COPY_STATE_DESC).toString();
                String syncType = instance.getPropertyValue(SmisConstants.CP_SYNC_TYPE).toString();
                _log.info(String.format("Sync %s has copyState %s (%s) syncType %s", path.toString(), copyState, copyStateDesc, syncType));
                if (copyState.equals(COPY_STATE_RESTORED_INT_VALUE) && syncType.equals(Integer.toString(SmisConstants.SNAPSHOT_VALUE))) {
                    // This snapshot is in the 'Restored' state, need to
                    // resync it, before we can create a full copy
                    _log.info("Sync {} is in restored state, need to resync", path);
                    SmisBlockResyncSnapshotJob job = new SmisBlockResyncSnapshotJob(null, storageSystem.getId(), new TaskCompleter() {

                        @Override
                        protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
                        }
                    });
                    CIMArgument[] result = new CIMArgument[5];
                    _helper.invokeMethodSynchronously(storageSystem, _cimPath.getControllerReplicationSvcPath(storageSystem), SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, _helper.getResyncSnapshotInputArguments(path), result, job);
                    if (job.isSuccess()) {
                        _log.info("{} was successfully resynchronized", path.toString());
                    } else {
                        _log.error("Encountered a failure while trying to resynchronize a restored snapshot");
                        ServiceError error = DeviceControllerErrors.smis.resyncActiveRestoreSessionFailure(sourceObj.getLabel());
                        taskCompleter.error(_dbClient, error);
                        return;
                    }
                }
            }
        }
        Volume cloneObj = _dbClient.queryObject(Volume.class, cloneVolume);
        StoragePool targetPool = _dbClient.queryObject(StoragePool.class, cloneObj.getPool());
        TenantOrg tenantOrg = _dbClient.queryObject(TenantOrg.class, tenantUri);
        String cloneLabel = generateLabel(tenantOrg, cloneObj);
        CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storageSystem, storageSystem, baseVolume, targetPool);
        CIMObjectPath sourceVolumePath = _cimPath.getBlockObjectPath(storageSystem, sourceObj);
        CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storageSystem);
        CIMArgument[] inArgs = null;
        CIMInstance repSettingData = null;
        if (storageSystem.deviceIsType(Type.vmax)) {
            if (createInactive && storageSystem.getUsingSmis80()) {
                repSettingData = _helper.getReplicationSettingDataInstanceForDesiredCopyMethod(storageSystem, COPY_BEFORE_ACTIVATE, true);
            } else if (storageSystem.checkIfVmax3() && ControllerUtils.isVmaxUsing81SMIS(storageSystem, _dbClient)) {
                /**
                 * VMAX3 using SMI 8.1 provider needs to send DesiredCopyMethodology=32770
                 * to create TimeFinder differential clone.
                 */
                repSettingData = _helper.getReplicationSettingDataInstanceForDesiredCopyMethod(storageSystem, SMIS810_TF_DIFFERENTIAL_CLONE_VALUE, true);
            } else {
                repSettingData = _helper.getReplicationSettingDataInstanceForDesiredCopyMethod(storageSystem, DIFFERENTIAL_CLONE_VALUE, true);
            }
            inArgs = _helper.getCloneInputArguments(cloneLabel, sourceVolumePath, volumeGroupPath, storageSystem, targetPool, createInactive, repSettingData);
        } else if (storageSystem.deviceIsType(Type.vnxblock)) {
            if (!isSourceSnap) {
                repSettingData = getReplicationSettingDataInstanceForThinProvisioningPolicy(storageSystem, PROVISIONING_TARGET_SAME_AS_SOURCE);
                // don't supply target pool when using thinlyProvisioningPolicy=PROVISIONING_TARGET_SAME_AS_SOURCE
                inArgs = _helper.getCreateElementReplicaMirrorInputArgumentsWithReplicationSettingData(storageSystem, sourceObj, null, false, repSettingData, cloneLabel);
                cloneObj.setPool(baseVolume.getPool());
                _dbClient.persistObject(cloneObj);
            } else {
                // when source is snapshot, create clone instead of mirror, since creating mirror from a snap is not supported.
                inArgs = _helper.getCloneInputArguments(cloneLabel, sourceVolumePath, volumeGroupPath, storageSystem, targetPool, createInactive, null);
            }
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storageSystem, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneVolumeJob(job, storageSystem.getId(), taskCompleter)));
        }
    } catch (Exception e) {
        Volume clone = _dbClient.queryObject(Volume.class, cloneVolume);
        if (clone != null) {
            clone.setInactive(true);
            _dbClient.persistObject(clone);
        }
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceVolume, cloneVolume);
        _log.error(errorMsg, e);
        SmisException serviceCode = DeviceControllerExceptions.smis.createFullCopyFailure(errorMsg, e);
        taskCompleter.error(_dbClient, serviceCode);
        throw serviceCode;
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) SmisBlockResyncSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResyncSnapshotJob) SmisCloneVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneVolumeJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockObject(com.emc.storageos.db.client.model.BlockObject) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DbClient(com.emc.storageos.db.client.DbClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)3 SmisBlockResyncSnapshotJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResyncSnapshotJob)3 CIMObjectPath (javax.cim.CIMObjectPath)3 WBEMException (javax.wbem.WBEMException)3 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)2 CIMArgument (javax.cim.CIMArgument)2 DbClient (com.emc.storageos.db.client.DbClient)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 Operation (com.emc.storageos.db.client.model.Operation)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Volume (com.emc.storageos.db.client.model.Volume)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 SmisCloneVolumeJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneVolumeJob)1 URI (java.net.URI)1