Search in sources :

Example 91 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method activateSingleVolumeSnapshot.

/**
 * This interface is for the snapshot active. The createSnapshot may have done
 * whatever is necessary to setup the snapshot for this call. The goal is to
 * make this a quick operation and the create operation has already done a lot
 * of the "heavy lifting".
 *
 * @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 activateSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        if (snapshotObj.getIsSyncActive()) {
            _log.warn("Trying to activate snapshot, which is already active", snapshotObj.getId().toString());
            return;
        }
        _log.info("activateSingleVolumeSnapshot operation START");
        CIMArgument[] inArgs = _helper.getActivateSnapshotInputArguments(storage, snapshotObj);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callModifyReplica(storage, inArgs, outArgs);
        setIsSyncActive(snapshotObj, true);
        snapshotObj.setRefreshRequired(true);
        _dbClient.persistObject(snapshotObj);
        // Success -- Update status
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } finally {
        _log.info("activateSingleVolumeSnapshot operation END");
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 92 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method deleteTargetDevices.

/**
 * Method will invoke the SMI-S operation to return the Volumes represented by the native ids to the storage pool
 *
 * @param storageSystem - StorageSystem where the pool and volume exist
 * @param deviceIds - List of native Ids representing the elements to be returned to the pool
 * @param taskCompleter - Completer object used for task status update
 *
 * @throws DeviceControllerException
 */
private void deleteTargetDevices(final StorageSystem storageSystem, final String[] deviceIds, final TaskCompleter taskCompleter) {
    _log.info(format("Removing target devices {0} from storage system {1}", Joiner.on("\t").join(deviceIds), storageSystem.getId()));
    try {
        if (storageSystem.checkIfVmax3()) {
            _helper.removeVolumeFromParkingSLOStorageGroup(storageSystem, deviceIds, false);
            _log.info("Done invoking remove volumes from parking SLO storage group");
        }
        final CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        final CIMObjectPath[] theElements = _cimPath.getVolumePaths(storageSystem, deviceIds);
        final CIMArgument[] inArgs = _helper.getReturnElementsToStoragePoolArguments(theElements, SmisConstants.CONTINUE_ON_NONEXISTENT_ELEMENT);
        final CIMArgument[] outArgs = new CIMArgument[5];
        final SmisDeleteVmaxCGTargetVolumesJob job = new SmisDeleteVmaxCGTargetVolumesJob(null, storageSystem.getId(), deviceIds, taskCompleter);
        _helper.invokeMethodSynchronously(storageSystem, configSvcPath, RETURN_ELEMENTS_TO_STORAGE_POOL, inArgs, outArgs, job);
    } catch (Exception e) {
        _log.error(format("An error occurred when removing target devices {0} from storage system {1}", Joiner.on("\t").join(deviceIds), storageSystem.getId()), e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) SmisDeleteVmaxCGTargetVolumesJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisDeleteVmaxCGTargetVolumesJob) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 93 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method unlinkSnapshotSessionTarget.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void unlinkSnapshotSessionTarget(StorageSystem system, URI snapSessionURI, URI snapshotURI, Boolean deleteTarget, TaskCompleter completer) throws DeviceControllerException {
    // Only supported for VMAX3 storage systems.
    if (!system.checkIfVmax3()) {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
    try {
        _log.info("Unlink target {} from snapshot session {} START", snapshotURI, snapSessionURI);
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
        String targetDeviceId = snapshot.getNativeId();
        if (isNullOrEmpty(targetDeviceId)) {
            // The snapshot has no target device id. This means we must
            // have failed creating the target device for a link target
            // request and unlink target is being called in rollback.
            // Since the target was never created, we just return
            // success.
            _log.info("Snapshot target {} was never created.", snapshotURI);
            completer.ready(_dbClient);
            return;
        }
        // If the snapshot has a native id, then we at least
        // know the target device was created. Now we try and get
        // the sync object path representing the linked target so
        // that it can be detached.
        boolean syncObjectFound = false;
        List<BlockSnapshot> snapshots = null;
        BlockObject sourceObj = BlockObject.fetch(_dbClient, snapshot.getParent().getURI());
        CIMObjectPath syncObjectPath = SmisConstants.NULL_CIM_OBJECT_PATH;
        if (snapshot.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshot.getReplicationGroupInstance())) {
            String replicationGroupName = snapshot.getReplicationGroupInstance();
            String sourceReplicationGroupName = sourceObj.getReplicationGroupInstance();
            List<CIMObjectPath> groupSyncs = getAllGroupSyncObjects(system, snapshot);
            if (groupSyncs != null && !groupSyncs.isEmpty()) {
                // the passed snapshot is the sync'd element.
                for (CIMObjectPath groupSynchronized : groupSyncs) {
                    String syncElementPath = groupSynchronized.getKeyValue(SmisConstants.CP_SYNCED_ELEMENT).toString();
                    String systemElementPath = groupSynchronized.getKeyValue(SmisConstants.CP_SYSTEM_ELEMENT).toString();
                    if (syncElementPath.contains(replicationGroupName) && systemElementPath.contains(sourceReplicationGroupName)) {
                        syncObjectPath = groupSynchronized;
                        break;
                    }
                }
            }
            snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient);
        } else {
            syncObjectPath = getSyncObject(system, snapshot, sourceObj);
            snapshots = Lists.newArrayList(snapshot);
        }
        if (!SmisConstants.NULL_CIM_OBJECT_PATH.equals(syncObjectPath)) {
            syncObjectFound = true;
            CIMArgument[] inArgs = _helper.getUnlinkBlockSnapshotSessionTargetInputArguments(syncObjectPath);
            CIMArgument[] outArgs = new CIMArgument[5];
            CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
            SmisBlockSnapshotSessionUnlinkTargetJob job = new SmisBlockSnapshotSessionUnlinkTargetJob(null, system.getId(), completer);
            _helper.invokeMethodSynchronously(system, replicationSvcPath, SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, inArgs, outArgs, job);
            // Succeeded in unlinking the target from the snapshot.
            for (BlockSnapshot snapshotToUpdate : snapshots) {
                snapshotToUpdate.setSettingsInstance(NullColumnValueGetter.getNullStr());
            }
            _dbClient.updateObject(snapshots);
        } else {
            // For some reason we could not find the path for the
            // CIM_StorageSychronized instance for the linked target.
            // If the settingsInstance for the snapshot is not set,
            // this may mean we just failed a link target request
            // and unlink target is being called in rollback. In this
            // case we successfully created the target volume, but
            // failed to link the target to the snapshot, in which
            // case the settingsInstance would be null. Otherwise,
            // we could be retrying a failed unlink request. In this
            // case, we must have succeeded in unlinking the target
            // from the array snapshot, but failed attempting to
            // delete the target volume. If the unlink is successful,
            // the settingsInstance is reset to null. So, if the
            // settingsInstance is null, we move on without failing.
            // Otherwise, we should throw an exception.
            String settingsInstance = snapshot.getSettingsInstance();
            if (NullColumnValueGetter.isNotNullValue(settingsInstance)) {
                throw DeviceControllerException.exceptions.couldNotFindSyncObjectToUnlinkTarget(targetDeviceId);
            }
        }
        if (deleteTarget) {
            _log.info("Delete target device {} :{}", targetDeviceId, snapshotURI);
            Collection<String> nativeIds = transform(snapshots, fctnBlockObjectToNativeID());
            if (snapshot.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshot.getReplicationGroupInstance())) {
                try {
                    checkReplicationGroupAccessibleOrFail(system, snapshot, _dbClient, _helper, _cimPath);
                    deleteTargetGroup(system, snapshot.getReplicationGroupInstance());
                } catch (DeviceControllerException | WBEMException e) {
                    _log.info("Failed to delete the target group.  It may have already been deleted.");
                }
            }
            // remove snapshot from them before deleting it.
            for (BlockSnapshot snap : snapshots) {
                try {
                    _helper.removeVolumeFromStorageGroupsIfVolumeIsNotInAnyMV(system, snap);
                } catch (Exception e) {
                    _log.info("Failed to remove snap {} from storage groups.  It may have already been removed.", snap.getNativeGuid());
                }
            }
            callEMCRefresh(_helper, system, true);
            deleteTargetDevices(system, nativeIds.toArray(new String[] {}), completer);
            _log.info("Delete target device complete");
        } else if (!syncObjectFound) {
            // Need to be sure the completer is called.
            completer.ready(_dbClient);
        }
    } catch (Exception e) {
        _log.error("Exception unlinking snapshot session target", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        completer.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisBlockSnapshotSessionUnlinkTargetJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionUnlinkTargetJob) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 94 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method establishVolumeSnapshotGroupRelation.

@Override
public void establishVolumeSnapshotGroupRelation(StorageSystem storage, URI sourceVolume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("establishVolumeSnapshotGroupRelation operation START");
    try {
        /**
         * get groupPath for source volume
         * get groupPath for snapshot
         * get snapshots belonging to the same Replication Group
         * get Element synchronizations between volumes and snapshots
         * call CreateGroupReplicaFromElementSynchronizations
         */
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
        CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
        CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
        CIMObjectPath snapshotGroupPath = _cimPath.getReplicationGroupPath(storage, snapshotObj.getReplicationGroupInstance());
        // Check if snapshot is referenced by a BlockSnapshotSession
        // if so, we must pass in the RelationshipName with the value of the session name.
        // NB. a SourceGroup aspect must exist
        List<BlockSnapshotSession> snapshotSessions = queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, getLinkedTargetSnapshotSessionConstraint(snapshot));
        String relationshipName = null;
        if (!snapshotSessions.isEmpty()) {
            relationshipName = snapshotSessions.get(0).getSessionLabel();
            _log.info("Found snapshot session relationship: {}", relationshipName);
        }
        CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, snapshotGroupPath);
        CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
        if (syncInstance == null) {
            // get all snapshots belonging to a Replication Group. There may be multiple snapshots available for a Volume
            List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
            List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
            for (BlockSnapshot snapshotObject : snapshots) {
                Volume volume = _dbClient.queryObject(Volume.class, snapshotObject.getParent());
                elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, snapshotObject));
            }
            _log.info("Creating Group synchronization between volume group and snapshot group");
            CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, snapshotGroupPath, elementSynchronizations, relationshipName);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
        // No Job returned
        } else {
            _log.info("Link already established..");
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        String msg = String.format("Failed to establish group relation between volume group and snapshot group. Volume: %s, Snapshot: %s", sourceVolume, snapshot);
        _log.error(msg, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
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) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) 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) CIMArgument(javax.cim.CIMArgument)

Example 95 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException 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)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)393 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 URI (java.net.URI)157 Volume (com.emc.storageos.db.client.model.Volume)115 ArrayList (java.util.ArrayList)115 WBEMException (javax.wbem.WBEMException)113 CIMObjectPath (javax.cim.CIMObjectPath)104 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)85 ExportMask (com.emc.storageos.db.client.model.ExportMask)83 CIMArgument (javax.cim.CIMArgument)81 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)75 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)63 BlockObject (com.emc.storageos.db.client.model.BlockObject)55 HashMap (java.util.HashMap)54 Initiator (com.emc.storageos.db.client.model.Initiator)52 HashSet (java.util.HashSet)52 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)48 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)46 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)46 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)43