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);
}
}
Aggregations