Search in sources :

Example 31 with DeviceControllerException

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

the class CephSnapshotOperations method deleteSingleVolumeSnapshot.

@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try (CephClient cephClient = getClient(storage)) {
        BlockSnapshot blockSnapshot = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
        StoragePool pool = _dbClient.queryObject(StoragePool.class, volume.getPool());
        cephClient.deleteSnap(pool.getPoolName(), volume.getNativeId(), blockSnapshot.getNativeId());
        blockSnapshot.setInactive(true);
        _dbClient.updateObject(blockSnapshot);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Snapshot deletion failed", e);
        ServiceError error = DeviceControllerErrors.ceph.operationFailed("deleteSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CephClient(com.emc.storageos.ceph.CephClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 32 with DeviceControllerException

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

the class CephStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    try (CephClient cephClient = getClient(storage)) {
        for (Volume volume : volumes) {
            String id = CephUtils.createNativeId(volume);
            cephClient.createImage(storagePool.getPoolName(), id, volume.getCapacity());
            volume.setNativeId(id);
            volume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, volume));
            volume.setDeviceLabel(volume.getLabel());
            volume.setProvisionedCapacity(volume.getCapacity());
            volume.setAllocatedCapacity(volume.getCapacity());
        }
        _dbClient.updateObject(volumes);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Error while creating volumes", e);
        _dbClient.updateObject(volumes);
        ServiceError error = DeviceControllerErrors.ceph.operationFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) CephClient(com.emc.storageos.ceph.CephClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 33 with DeviceControllerException

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

the class CinderExportOperations method removeVolumes.

@Override
public void removeVolumes(StorageSystem storage, URI exportMaskId, List<URI> volumeURIs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} removeVolumes START...", storage.getSerialNumber());
    try {
        log.info("removeVolumes: Export mask id: {}", exportMaskId);
        log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumeURIs));
        if (initiatorList != null) {
            log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
        }
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskId);
        List<Volume> volumes = new ArrayList<Volume>();
        List<Initiator> userAddedInitiatorList = new ArrayList<Initiator>();
        StringMap initiators = exportMask.getUserAddedInitiators();
        for (URI volumeURI : volumeURIs) {
            Volume volume = dbClient.queryObject(Volume.class, volumeURI);
            volumes.add(volume);
        }
        for (String ini : initiators.values()) {
            Initiator initiator = dbClient.queryObject(Initiator.class, URI.create(ini));
            userAddedInitiatorList.add(initiator);
        }
        detachVolumesFromInitiators(storage, volumes, userAddedInitiatorList);
        taskCompleter.ready(dbClient);
    } catch (final Exception ex) {
        log.error("Problem in RemoveVolumes: ", ex);
        ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("doRemoveVolumes", ex.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} removeVolumes END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StringMap(com.emc.storageos.db.client.model.StringMap) Volume(com.emc.storageos.db.client.model.Volume) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 34 with DeviceControllerException

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

the class CinderStorageDevice method doDeleteVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes
     * (com.emc.storageos.db.client.model.StorageSystem,
     * java.lang.String,
     * java.util.List,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<String> volumeNativeIdsToDelete = new ArrayList<String>(volumes.size());
        List<String> volumeLabels = new ArrayList<String>(volumes.size());
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
        log.info(logMsgBuilder.toString());
        MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        for (Volume volume : volumes) {
            logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
            try {
                // Check if the volume is present on the back-end device
                cinderApi.showVolume(volume.getNativeId());
            } catch (CinderException ce) {
                // This means, the volume is not present on the back-end device
                log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                dbClient.persistObject(volume);
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(dbClient);
                continue;
            }
            volumeNativeIdsToDelete.add(volume.getNativeId());
            volumeLabels.add(volume.getLabel());
            // cleanup if there are any snapshots created for a volume
            cleanupAnyBackupSnapshots(volume, cinderApi);
        }
        // Now - trigger the delete
        if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
            cinderApi.deleteVolumes(volumeNativeIdsToDelete.toArray(new String[] {}));
            ControllerServiceImpl.enqueueJob(new QueueJob(new CinderDeleteVolumeJob(volumeNativeIdsToDelete.get(0), volumeLabels.get(0), volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter)));
        } else {
            // If we are here, there are no volumes to delete, we have
            // invoked ready() for the VolumeDeleteCompleter, and told
            // the multiVolumeTaskCompleter to skip these completers.
            // In this case, the multiVolumeTaskCompleter complete()
            // method will not be invoked and the result is that the
            // workflow that initiated this delete request will never
            // be updated. So, here we just call complete() on the
            // multiVolumeTaskCompleter to ensure the workflow status is
            // updated.
            multiVolumeTaskCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error("Problem in doDeleteVolume: ", e);
        ServiceError error = DeviceControllerErrors.cinder.operationFailed("doDeleteVolume", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    log.info(logMsgBuilder.toString());
}
Also used : CinderException(com.emc.storageos.cinder.errorhandling.CinderException) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CinderDeleteVolumeJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderDeleteVolumeJob) ArrayList(java.util.ArrayList) CinderApi(com.emc.storageos.cinder.api.CinderApi) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) CinderException(com.emc.storageos.cinder.errorhandling.CinderException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 35 with DeviceControllerException

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

the class ExternalBlockStorageDevice method doRemoveFromConsistencyGroup.

@Override
public void doRemoveFromConsistencyGroup(StorageSystem storageSystem, URI consistencyGroupId, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
    BlockConsistencyGroup consistencyGroup = null;
    try {
        _log.info("{} doRemoveVolumesFromConsistencyGroup START ...", storageSystem.getSerialNumber());
        BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
        List<Volume> volumes = dbClient.queryObject(Volume.class, blockObjects);
        List<StorageVolume> driverVolumes = new ArrayList<>();
        consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
        for (Volume volume : volumes) {
            StorageVolume driverVolume = new StorageVolume();
            driverVolume.setStorageSystemId(storageSystem.getNativeId());
            driverVolume.setNativeId(volume.getNativeId());
            driverVolume.setRequestedCapacity(volume.getCapacity());
            driverVolume.setThinlyProvisioned(volume.getThinlyProvisioned());
            driverVolume.setConsistencyGroup(consistencyGroup.getNativeId());
            driverVolume.setDisplayName(volume.getLabel());
            // add them to StorageVolumes list
            driverVolumes.add(driverVolume);
        }
        DriverTask task = driver.removeVolumesFromConsistencyGroup(driverVolumes, null);
        _log.info("doRemoveVolumesFromConsistencyGroup -- removing volumes {} from consistency Group: {}", volumes.toString(), consistencyGroupId);
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            for (Volume volume : volumes) {
                volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
            }
            dbClient.updateObject(volumes);
            taskCompleter.ready(dbClient);
        } else {
            _log.error(String.format("Remove volumes from Consistency Group operation failed %s", task.getMessage()));
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), task.getMessage()));
        }
        _log.info("{} doRemoveVolumesFromConsistencyGroup END ...", storageSystem.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Remove volumes from Consistency Group operation failed %s", e.getMessage()));
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

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