Search in sources :

Example 51 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class CephStorageDevice method doDeleteVolumes.

@Override
public void doDeleteVolumes(StorageSystem storage, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
    HashMap<URI, String> pools = new HashMap<URI, String>();
    try (CephClient cephClient = getClient(storage)) {
        for (Volume volume : volumes) {
            if (volume.getNativeId() != null && !volume.getNativeId().isEmpty()) {
                URI poolUri = volume.getPool();
                String poolName = pools.get(poolUri);
                if (poolName == null) {
                    StoragePool pool = _dbClient.queryObject(StoragePool.class, poolUri);
                    poolName = pool.getPoolName();
                    pools.put(poolUri, poolName);
                }
                cephClient.deleteImage(poolName, volume.getNativeId());
            } else {
                _log.info("Volume {} was not created completely, so skipping deletion from ceph array and just deleting from the controller's inventory", volume.getLabel());
            }
            volume.setInactive(true);
            _dbClient.updateObject(volume);
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Error while deleting volumes", e);
        ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("deleteVolume", e.getMessage());
        taskCompleter.error(_dbClient, code);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) URI(java.net.URI) CephClient(com.emc.storageos.ceph.CephClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 52 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method deleteSecondaryVolumeSnapshot.

public void deleteSecondaryVolumeSnapshot(StorageSystem storageSystem, BlockSnapshot snapshotObj, TaskCompleter taskCompleter) throws Exception {
    log.info("Snapshot deletion operation started");
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    String logicalUnitObjId = HDSUtils.getLogicalUnitObjectId(snapshotObj.getNativeId(), storageSystem);
    asyncTaskMessageId = hdsApiClient.deleteSnapshotVolume(systemObjectID, logicalUnitObjId, storageSystem.getModel());
    if (null != asyncTaskMessageId) {
        HDSJob deleteSnapshotJob = new HDSDeleteSnapshotJob(asyncTaskMessageId, snapshotObj.getStorageController(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(deleteSnapshotJob);
        log.info("Snapshot deletion operation completed successfully");
    } else {
        // This path should never be taken as the HDS client should always return
        // the asynchronous task id. If it does not, this will be treated as an
        // error.
        log.error("Unexpected null asynchronous task id from HDS client call to delete volume snapshot.");
        ServiceCoded sc = DeviceControllerExceptions.hds.nullAsyncTaskIdForDeleteSnapshot(snapshotObj.forDisplay());
        taskCompleter.error(dbClient, sc);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) HDSDeleteSnapshotJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSDeleteSnapshotJob) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded)

Example 53 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class SRDFMirrorRollbackCompleter method logRollbackStatus.

/**
 * Write a log message to help the user understand the potential state of a given
 * source & target volume pair.
 *
 * @param source    Source volume
 * @param target    Target volume
 */
private void logRollbackStatus(Volume source, Volume target) {
    StringBuilder msg = new StringBuilder();
    msg.append(String.format("Rollback of Source:%s, Target:%s for Task:%s ", source.getNativeGuid(), target.getNativeGuid(), getOpId()));
    String key = rollbackStatusKey(source, target);
    if (rollbackFailures.containsKey(key)) {
        ServiceCoded coded = rollbackFailures.get(rollbackStatusKey(source, target));
        msg.append(String.format("failed: %s\n%s.", coded, UNKNOWN_STATUS_MSG));
    } else if (rollbackSuccesses.contains(key)) {
        msg.append("complete.");
    } else {
        msg.append(String.format("did not occur.  %s", UNKNOWN_STATUS_MSG));
    }
    log.info(msg.toString());
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded)

Example 54 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class ScaleIOSnapshotOperations method deleteSingleVolumeSnapshot.

@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
        BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
        if (blockSnapshot != null && !blockSnapshot.getInactive() && // state against the BlockSnapshot object can be set.
        !Strings.isNullOrEmpty(blockSnapshot.getNativeId())) {
            scaleIOHandle.removeVolume(blockSnapshot.getNativeId());
        }
        if (blockSnapshot != null) {
            blockSnapshot.setInactive(true);
            dbClient.updateObject(blockSnapshot);
            ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, blockSnapshot);
        }
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        log.error("Encountered an exception", e);
        ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("deleteSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(dbClient, code);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 55 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class ScaleIOStorageDevice method unmapVolumes.

/**
 * Given a mapping of volumes and initiators, make the ScaleIO API calls to un-map the volume
 * to the specified ScaleIO initiators
 *
 * @param storage
 *            [in] - StorageSystem object (ScaleIO array abstraction)
 * @param volumeURIs
 *            [in] - Collection of Volume URIs
 * @param initiators
 *            [in] - Collection of Initiator objects
 * @param completer
 *            [in] - TaskCompleter
 */
private void unmapVolumes(StorageSystem storage, Collection<URI> volumeURIs, Collection<Initiator> initiators, TaskCompleter completer) {
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
        for (URI volumeURI : volumeURIs) {
            BlockObject blockObject = BlockObject.fetch(dbClient, volumeURI);
            if (blockObject == null || blockObject.getInactive()) {
                log.warn(String.format("Attempted to unmap BlockObject %s, which was either not found in the DB or was inactive", volumeURI.toString()));
                continue;
            }
            String nativeId = blockObject.getNativeId();
            for (Initiator initiator : initiators) {
                String port = initiator.getInitiatorPort();
                boolean wasUnMapped = false;
                if (initiator.getProtocol().equals(HostInterface.Protocol.ScaleIO.name())) {
                    wasUnMapped = unmapFromSDC(scaleIOHandle, nativeId, port, completer);
                } else if (initiator.getProtocol().equals(HostInterface.Protocol.iSCSI.name())) {
                    wasUnMapped = unmapFromSCSI(scaleIOHandle, nativeId, port, initiator.getLabel(), completer);
                } else {
                    ServiceCoded code = DeviceControllerErrors.scaleio.unmapVolumeToClientFailed(nativeId, port, String.format("Unexpected initiator type %s", initiator.getProtocol()));
                    completer.error(dbClient, code);
                }
                if (!wasUnMapped) {
                    // Failed to map the volume
                    return;
                }
            }
        }
        completer.ready(dbClient);
    } catch (Exception e) {
        log.error("Encountered an exception", e);
        ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("unmapVolume", e.getMessage());
        completer.error(dbClient, code);
    }
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException)

Aggregations

ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)94 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)48 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)44 URI (java.net.URI)41 Volume (com.emc.storageos.db.client.model.Volume)31 ControllerException (com.emc.storageos.volumecontroller.ControllerException)27 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 WorkflowException (com.emc.storageos.workflow.WorkflowException)22 ArrayList (java.util.ArrayList)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)18 Operation (com.emc.storageos.db.client.model.Operation)17 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)15 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)14 HashMap (java.util.HashMap)14 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)13 URISyntaxException (java.net.URISyntaxException)13 Host (com.emc.storageos.db.client.model.Host)12