Search in sources :

Example 1 with VNXeDeleteVolumesJob

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

the class VNXeStorageDevice method doDeleteVolumes.

/*
     * @Override
     * public void doExpandAsMetaVolume(StorageSystem storageSystem,
     * StoragePool storagePool, Volume volume, long size,
     * MetaVolumeRecommendation recommendation,
     * TaskCompleter volumeCompleter) throws DeviceControllerException {
     * // TODO Auto-generated method stub
     * 
     * }
     */
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter completer) throws DeviceControllerException {
    _logger.info("deleting volumes, array: {}", storageSystem.getSerialNumber());
    VNXeApiClient apiClient = getVnxeClient(storageSystem);
    List<String> jobs = new ArrayList<String>();
    Map<String, List<String>> consistencyGroupMap = new HashMap<String, List<String>>();
    try {
        for (Volume volume : volumes) {
            if (volume.getConsistencyGroup() != null) {
                BlockConsistencyGroup consistencyGroupObj = _dbClient.queryObject(BlockConsistencyGroup.class, volume.getConsistencyGroup());
                List<String> lunIds = consistencyGroupMap.get(consistencyGroupObj.getCgNameOnStorageSystem(storageSystem.getId()));
                if (lunIds == null) {
                    lunIds = new ArrayList<String>();
                    consistencyGroupMap.put(consistencyGroupObj.getCgNameOnStorageSystem(storageSystem.getId()), lunIds);
                }
                lunIds.add(volume.getNativeId());
            } else {
                VNXeCommandJob job = apiClient.deleteLun(volume.getNativeId(), true);
                jobs.add(job.getId());
            }
        }
        for (String consistencyGroup : consistencyGroupMap.keySet()) {
            List<String> lunIDs = consistencyGroupMap.get(consistencyGroup);
            VNXeCommandJob job = apiClient.deleteLunsFromLunGroup(consistencyGroup, lunIDs);
            jobs.add(job.getId());
        }
        VNXeDeleteVolumesJob deleteVolumesJob = new VNXeDeleteVolumesJob(jobs, storageSystem.getId(), completer);
        ControllerServiceImpl.enqueueJob(new QueueJob(deleteVolumesJob));
    } catch (VNXeException e) {
        _logger.error("Delete volumes got the exception", e);
        completer.error(_dbClient, e);
    } catch (Exception ex) {
        _logger.error("Delete volumes got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteVolumes", ex.getMessage());
        completer.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) HashMap(java.util.HashMap) VNXeDeleteVolumesJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteVolumesJob) ArrayList(java.util.ArrayList) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Volume(com.emc.storageos.db.client.model.Volume) VNXeException(com.emc.storageos.vnxe.VNXeException) List(java.util.List) ArrayList(java.util.ArrayList) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)1 VNXeException (com.emc.storageos.vnxe.VNXeException)1 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 VNXeDeleteVolumesJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteVolumesJob)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1