Search in sources :

Example 81 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method linkSnapshotSessionTarget.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void linkSnapshotSessionTarget(StorageSystem system, URI snapSessionURI, URI snapshotURI, String copyMode, Boolean targetExists, TaskCompleter completer) throws DeviceControllerException {
    if (system.checkIfVmax3()) {
        // Only supported for VMAX3 storage systems.
        try {
            _log.info("Link new target {} to snapshot session {} START", snapshotURI, snapSessionURI);
            CIMObjectPath sourcePath = null;
            CIMObjectPath targetPath = null;
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
            URI sourceObjURI = snapshot.getParent().getURI();
            BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceObjURI);
            if (!targetExists) {
                // of snapshot.
                if (URIUtil.isType(sourceObjURI, Volume.class)) {
                    // Provision the new target volume.
                    Volume sourceVolume = (Volume) sourceObj;
                    CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(system, system, sourceVolume, null);
                    // COP-17240: For VMAX3, we will derive the target volumes from the source volumes SRP Pool
                    CIMObjectPath poolPath = _helper.getVolumeStoragePoolPath(system, sourceVolume);
                    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, sourceVolume.getTenant().getURI());
                    String tenantName = tenant.getLabel();
                    String label = _nameGenerator.generate(tenantName, snapshot.getLabel(), snapshotURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
                    List<String> targetDeviceIds = createTargetDevices(system, poolPath, volumeGroupPath, null, "SingleSnapshot", label, Boolean.FALSE, 1, sourceVolume.getCapacity(), completer);
                    if (targetDeviceIds.isEmpty()) {
                        throw DeviceControllerException.exceptions.createTargetForSnapshotSessionFailed(snapSessionURI.toString());
                    }
                    sourcePath = _cimPath.getVolumePath(system, sourceVolume.getNativeId());
                    targetPath = _cimPath.getVolumePath(system, targetDeviceIds.get(0));
                    // Set the native id into the snapshot. This will allow a rollback
                    // to delete the target if we subsequently fail to link the target
                    // to the array snapshot.
                    String targetDeviceId = targetDeviceIds.get(0);
                    snapshot.setNativeId(targetDeviceId);
                    _dbClient.updateObject(snapshot);
                } else {
                    throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
                }
            } else {
                // When the passed flag indicates the target exists and just needs to be
                // linked, this is the special case where we link a source volume to a snapshot
                // session of a linked target volume for the purpose of restoring the source
                // volume from the linked target volume for VMAX3. In this case, the source
                // of the passed snapshot is itself a BlockSnapshot.
                sourcePath = _cimPath.getBlockObjectPath(system, sourceObj);
                targetPath = _cimPath.getBlockObjectPath(system, snapshot);
            }
            // Now link the target to the array snapshot represented by the session.
            CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
            BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
            String syncAspectPath = snapSession.getSessionInstance();
            CIMObjectPath settingsStatePath = _cimPath.getSyncSettingsPath(system, sourcePath, syncAspectPath);
            CIMArgument[] inArgs = null;
            CIMArgument[] outArgs = new CIMArgument[5];
            inArgs = _helper.getModifySettingsDefinedStateForLinkTargets(system, settingsStatePath, targetPath, copyMode);
            _helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
            CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionLinkTargetJob(jobPath, system.getId(), snapshotURI, copyMode, completer)));
        } catch (Exception e) {
            _log.error("Exception creating and linking snapshot session target", e);
            ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
            completer.error(_dbClient, error);
        }
    } else {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) SmisBlockSnapshotSessionLinkTargetJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionLinkTargetJob) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 82 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method deleteSnapshotSession.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void deleteSnapshotSession(StorageSystem system, URI snapSessionURI, String groupName, TaskCompleter completer) throws DeviceControllerException {
    if (system.checkIfVmax3()) {
        // Only supported for VMAX3 storage systems.
        try {
            _log.info("Delete snapshot session {} START", snapSessionURI);
            BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
            String syncAspectPath = snapSession.getSessionInstance();
            if (NullColumnValueGetter.isNullValue(syncAspectPath)) {
                // If there is no session instance, it must have failed creation and
                // this is method is being called due to a rollback.
                _log.info("No session instance specified for snapshot session {}", snapSessionURI);
                completer.ready(_dbClient);
            } else {
                CIMObjectPath settingsStatePath = null;
                if (snapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(groupName)) {
                    settingsStatePath = _cimPath.getGroupSynchronizedSettingsPath(system, groupName, syncAspectPath);
                } else {
                    BlockObject sourceObj = BlockObject.fetch(_dbClient, snapSession.getParent().getURI());
                    CIMObjectPath sourcePath = _cimPath.getBlockObjectPath(system, sourceObj);
                    settingsStatePath = _cimPath.getSyncSettingsPath(system, sourcePath, syncAspectPath);
                }
                CIMArgument[] inArgs = null;
                CIMArgument[] outArgs = new CIMArgument[5];
                inArgs = _helper.getDeleteSettingsForSnapshotInputArguments(settingsStatePath, false);
                CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
                _helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
                CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionDeleteJob(jobPath, system.getId(), completer)));
            }
        } catch (Exception e) {
            _log.error("Exception deleting snapshot session", e);
            ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
            completer.error(_dbClient, error);
        }
    } else {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) SmisBlockSnapshotSessionDeleteJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionDeleteJob) CIMObjectPath(javax.cim.CIMObjectPath) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 83 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method createSnapshotSession.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void createSnapshotSession(StorageSystem system, URI snapSessionURI, TaskCompleter completer) throws DeviceControllerException {
    if (system.checkIfVmax3()) {
        // Only supported for VMAX3 storage systems.
        try {
            _log.info("Create snapshot session operation START");
            BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
            URI sourceObjURI = snapSession.getParent().getURI();
            BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceObjURI);
            // Need to terminate an restore sessions, so that we can
            // restore from the same snapshot multiple times
            terminateAnyRestoreSessionsForVolume(system, sourceObj, completer);
            URI tenantURI = null;
            if (URIUtil.isType(sourceObjURI, Volume.class)) {
                tenantURI = ((Volume) sourceObj).getTenant().getURI();
            } else {
                Volume sourceObjParent = _dbClient.queryObject(Volume.class, ((BlockSnapshot) sourceObj).getParent().getURI());
                tenantURI = sourceObjParent.getTenant().getURI();
            }
            TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, tenantURI);
            String tenantName = tenant.getLabel();
            String snapSessionLabelToUse = _nameGenerator.generate(tenantName, snapSession.getSessionLabel(), snapSessionURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
            CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
            CIMObjectPath sourceObjPath = _cimPath.getBlockObjectPath(system, sourceObj);
            CIMArgument[] inArgs = null;
            CIMArgument[] outArgs = new CIMArgument[5];
            inArgs = _helper.getCreateSynchronizationAspectInput(sourceObjPath, false, snapSessionLabelToUse, new Integer(SmisConstants.MODE_SYNCHRONOUS));
            _helper.invokeMethod(system, replicationSvcPath, SmisConstants.CREATE_SYNCHRONIZATION_ASPECT, inArgs, outArgs);
            CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionCreateJob(jobPath, system.getId(), completer)));
        } catch (Exception e) {
            _log.error("Exception creating snapshot session ", e);
            ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
            completer.error(_dbClient, error);
        }
    } else {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisBlockSnapshotSessionCreateJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionCreateJob) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 84 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method relinkSnapshotSessionTargetGroup.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void relinkSnapshotSessionTargetGroup(StorageSystem system, URI tgtSnapSessionURI, URI snapshotURI, TaskCompleter completer) throws DeviceControllerException {
    // Only supported for VMAX3 storage systems.
    if (!system.checkIfVmax3()) {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
    try {
        _log.info("Re-link target {} to snapshot session {} START", snapshotURI, tgtSnapSessionURI);
        BlockSnapshotSession tgtSnapSession = _dbClient.queryObject(BlockSnapshotSession.class, tgtSnapSessionURI);
        String syncAspectPath = tgtSnapSession.getSessionInstance();
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
        String groupName = ControllerUtils.extractGroupName(snapshot.getReplicationGroupInstance());
        CIMObjectPath replicationGroupPath = _cimPath.getReplicationGroupPath(system, groupName);
        // get source group name from the session.
        String sourceGroupName = tgtSnapSession.getReplicationGroupInstance();
        CIMObjectPath settingsStatePath = _cimPath.getGroupSynchronizedSettingsPath(system, sourceGroupName, syncAspectPath);
        // We need to know if the group was linked in copy mode or nocopy mode.
        CIMObjectPath groupSyncPath = _cimPath.getGroupSynchronizedPath(system, sourceGroupName, groupName);
        boolean targetGroupLinkedInCopyMode = isTargetOrGroupCopyMode(system, groupSyncPath);
        CIMArgument[] inArgs = null;
        CIMArgument[] outArgs = new CIMArgument[5];
        inArgs = _helper.getModifySettingsDefinedStateForRelinkTargetGroups(system, settingsStatePath, replicationGroupPath, targetGroupLinkedInCopyMode);
        CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
        _helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
        CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionRelinkTargetJob(jobPath, system.getId(), completer)));
    } catch (Exception e) {
        _log.error("Exception re-linking snapshot session", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        completer.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisBlockSnapshotSessionRelinkTargetJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionRelinkTargetJob) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) 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 85 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method createGroupSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void createGroupSnapshotSession(StorageSystem system, URI snapSessionURI, String groupName, TaskCompleter completer) throws DeviceControllerException {
    if (system.checkIfVmax3()) {
        _log.info("Create snapshot session group operation START");
        BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
        BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, snapSession.getConsistencyGroup());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, consistencyGroup.getTenant().getURI());
        String tenantName = tenant.getLabel();
        final String label = _nameGenerator.generate(tenantName, snapSession.getSessionLabel(), snapSessionURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
        CIMObjectPath groupPath = _cimPath.getReplicationGroupPath(system, groupName);
        try {
            CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
            CIMArgument[] outArgs = new CIMArgument[5];
            CIMArgument[] inArgs = _helper.getCreateSynchronizationAspectForGroupInput(groupPath, false, label, new Integer(SmisConstants.MODE_SYNCHRONOUS));
            _helper.invokeMethod(system, replicationSvcPath, SmisConstants.CREATE_SYNCHRONIZATION_ASPECT, inArgs, outArgs);
            CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionCGCreateJob(jobPath, system.getId(), completer)));
        } catch (Exception e) {
            _log.error("Exception creating group snapshot session ", e);
            ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
            completer.error(_dbClient, error);
        }
        _log.info("Create snapshot session group operation FINISH");
    } else {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockSnapshotSessionCGCreateJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionCGCreateJob) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) CIMArgument(javax.cim.CIMArgument)

Aggregations

BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)112 URI (java.net.URI)64 Volume (com.emc.storageos.db.client.model.Volume)43 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)41 NamedURI (com.emc.storageos.db.client.model.NamedURI)38 ArrayList (java.util.ArrayList)33 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)27 StringSet (com.emc.storageos.db.client.model.StringSet)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 HashMap (java.util.HashMap)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)16 CIMObjectPath (javax.cim.CIMObjectPath)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)11 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)11 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)11 DataObject (com.emc.storageos.db.client.model.DataObject)10 Project (com.emc.storageos.db.client.model.Project)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10