Search in sources :

Example 1 with ExportMaskOnlyRemoveVolumeCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter in project coprhd-controller by CoprHD.

the class VplexUnityMaskingOrchestrator method deleteOrRemoveVolumesFromExportMask.

@Override
public void deleteOrRemoveVolumesFromExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumes, List<URI> initiatorURIs, String stepId) {
    ExportTaskCompleter completer = null;
    try {
        completer = new ExportMaskOnlyRemoveVolumeCompleter(exportGroupURI, exportMaskURI, volumes, stepId);
        WorkflowStepCompleter.stepExecuting(stepId);
        StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
        BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        // If the exportMask isn't found, or has been deleted, nothing to do.
        if (exportMask == null || exportMask.getInactive()) {
            log.info(String.format("ExportMask %s inactive, returning success", exportMaskURI));
            completer.ready(_dbClient);
            return;
        }
        // Protect concurrent operations by locking {host, array}.
        // Lock will be released when workflow step completes.
        List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
        getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
        // Determine if we're deleting the last volume in the mask.
        StringMap maskVolumesMap = exportMask.getVolumes();
        Set<String> remainingVolumes = new HashSet<String>();
        List<URI> passedVolumesInMask = new ArrayList<>(volumes);
        if (maskVolumesMap != null) {
            remainingVolumes.addAll(maskVolumesMap.keySet());
        }
        for (URI volume : volumes) {
            remainingVolumes.remove(volume.toString());
            // are not in the mask to handle this condition.
            if ((maskVolumesMap != null) && (!maskVolumesMap.keySet().contains(volume.toString()))) {
                passedVolumesInMask.remove(volume);
            }
        }
        // None of the volumes is in the export mask, so we are done.
        if (passedVolumesInMask.isEmpty()) {
            log.info("None of these volumes {} are in export mask {}", passedVolumesInMask, exportMask.forDisplay());
            completer.ready(_dbClient);
            return;
        }
        // If it is last volume and there are no existing volumes, delete the ExportMask.
        if (remainingVolumes.isEmpty() && !exportMask.hasAnyExistingVolumes()) {
            // When deleting export mask due to removing last volumes, don't pass initiator list.
            // Initiator list should only be used when deleting export mask as a result of removing last initiators
            device.doExportDelete(array, exportMask, passedVolumesInMask, null, completer);
        } else {
            List<Initiator> initiators = null;
            if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
                initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
            }
            device.doExportRemoveVolumes(array, exportMask, passedVolumesInMask, initiators, completer);
        }
        completer.ready(_dbClient);
    } catch (Exception ex) {
        log.error("Failed to delete or remove volumes to export mask for vmax: ", ex);
        VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForDeleteVolumesFailed(ex);
        completer.error(_dbClient, vplexex);
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ExportMaskOnlyRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 2 with ExportMaskOnlyRemoveVolumeCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter in project coprhd-controller by CoprHD.

the class VplexXtremIOMaskingOrchestrator method deleteOrRemoveVolumesFromExportMask.

@Override
public void deleteOrRemoveVolumesFromExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumes, List<URI> initiatorURIs, String stepId) {
    ExportTaskCompleter completer = null;
    try {
        completer = new ExportMaskOnlyRemoveVolumeCompleter(exportGroupURI, exportMaskURI, volumes, stepId);
        WorkflowStepCompleter.stepExecuting(stepId);
        StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
        BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        // If the exportMask isn't found, or has been deleted, nothing to do.
        if (exportMask == null || exportMask.getInactive()) {
            _log.info(String.format("ExportMask %s inactive, returning success", exportMaskURI));
            completer.ready(_dbClient);
            return;
        }
        // Protect concurrent operations by locking {host, array} dupple.
        // Lock will be released when workflow step completes.
        List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
        getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
        // Determine if we're deleting the last volume in the mask.
        StringMap maskVolumesMap = exportMask.getVolumes();
        Set<String> remainingVolumes = new HashSet<String>();
        List<URI> passedVolumesInMask = new ArrayList<>(volumes);
        if (maskVolumesMap != null) {
            remainingVolumes.addAll(maskVolumesMap.keySet());
        }
        for (URI volume : volumes) {
            remainingVolumes.remove(volume.toString());
            // are not in the mask to handle this condition.
            if ((maskVolumesMap != null) && (!maskVolumesMap.keySet().contains(volume.toString()))) {
                passedVolumesInMask.remove(volume);
            }
        }
        // None of the volumes is in the export mask, so we are done.
        if (passedVolumesInMask.isEmpty()) {
            _log.info("None of these volumes {} are in export mask {}", volumes, exportMask.forDisplay());
            completer.ready(_dbClient);
            return;
        }
        // If it is last volume and there are no existing volumes, delete the ExportMask.
        if (remainingVolumes.isEmpty() && !exportMask.hasAnyExistingVolumes()) {
            device.doExportDelete(array, exportMask, passedVolumesInMask, initiatorURIs, completer);
        } else {
            List<Initiator> initiators = null;
            if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
                initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
            }
            device.doExportRemoveVolumes(array, exportMask, passedVolumesInMask, initiators, completer);
        }
        completer.ready(_dbClient);
    } catch (Exception ex) {
        _log.error("Failed to delete or remove volumes to export mask for vmax: ", ex);
        VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForCreateVolumesFailed(ex);
        completer.error(_dbClient, vplexex);
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ExportMaskOnlyRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 3 with ExportMaskOnlyRemoveVolumeCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter in project coprhd-controller by CoprHD.

the class VPlexHDSMaskingOrchestrator method deleteOrRemoveVolumesFromExportMask.

@Override
public void deleteOrRemoveVolumesFromExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumes, List<URI> initiatorURIs, String stepId) {
    ExportTaskCompleter completer = null;
    try {
        completer = new ExportMaskOnlyRemoveVolumeCompleter(exportGroupURI, exportMaskURI, volumes, stepId);
        WorkflowStepCompleter.stepExecuting(stepId);
        StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
        BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        // If the exportMask isn't found, or has been deleted, nothing to do.
        if (exportMask == null || exportMask.getInactive()) {
            _log.info(String.format("ExportMask %s inactive, returning success", exportMaskURI));
            completer.ready(_dbClient);
            return;
        }
        // Protect concurrent operations by locking {host, array} dupple.
        // Lock will be released when workflow step completes.
        List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
        getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
        // Refresh the ExportMask
        exportMask = refreshExportMask(array, device, exportMask);
        // Determine if we're deleting the last volume in the mask.
        StringMap maskVolumesMap = exportMask.getVolumes();
        Set<String> remainingVolumes = new HashSet<String>();
        List<URI> passedVolumesInMask = new ArrayList<>(volumes);
        if (maskVolumesMap != null) {
            remainingVolumes.addAll(maskVolumesMap.keySet());
        }
        for (URI volume : volumes) {
            remainingVolumes.remove(volume.toString());
            // are not in the mask to handle this condition.
            if ((maskVolumesMap != null) && (!maskVolumesMap.keySet().contains(volume.toString()))) {
                passedVolumesInMask.remove(volume);
            }
        }
        _log.info("passedVolumesInMask : {}", passedVolumesInMask);
        _log.info("remainingVolumes : {}", remainingVolumes);
        // None of the volumes is in the export mask, so we are done.
        if (passedVolumesInMask.isEmpty()) {
            _log.info("None of these volumes {} are in export mask {}", volumes, exportMask.forDisplay());
            completer.ready(_dbClient);
            return;
        }
        // If it is last volume and there are no existing volumes, delete the ExportMask.
        if (remainingVolumes.isEmpty() && !exportMask.hasAnyExistingVolumes()) {
            device.doExportDelete(array, exportMask, passedVolumesInMask, initiatorURIs, completer);
        } else {
            List<Initiator> initiators = null;
            if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
                initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
            }
            device.doExportRemoveVolumes(array, exportMask, passedVolumesInMask, initiators, completer);
        }
    } catch (Exception ex) {
        _log.error("Failed to delete or remove volumes to export mask for hds: ", ex);
        VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForCreateVolumesFailed(ex);
        completer.error(_dbClient, vplexex);
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ExportMaskOnlyRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 4 with ExportMaskOnlyRemoveVolumeCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter in project coprhd-controller by CoprHD.

the class VPlexVmaxMaskingOrchestrator method deleteOrRemoveVolumesFromExportMask.

@Override
public void deleteOrRemoveVolumesFromExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumes, List<URI> initiatorURIs, String stepId) {
    ExportTaskCompleter completer = null;
    try {
        completer = new ExportMaskOnlyRemoveVolumeCompleter(exportGroupURI, exportMaskURI, volumes, stepId);
        WorkflowStepCompleter.stepExecuting(stepId);
        StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
        BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        // If the exportMask isn't found, or has been deleted, nothing to do.
        if (exportMask == null || exportMask.getInactive()) {
            _log.info(String.format("ExportMask %s inactive, returning success", exportMaskURI));
            completer.ready(_dbClient);
            return;
        }
        // Protect concurrent operations by locking {host, array} dupple.
        // Lock will be released when workflow step completes.
        List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
        getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
        // Refresh the ExportMask
        exportMask = refreshExportMask(array, device, exportMask);
        // Determine if we're deleting the last volume in the mask.
        StringMap maskVolumesMap = exportMask.getVolumes();
        Set<String> remainingVolumes = new HashSet<String>();
        List<URI> passedVolumesInMask = new ArrayList<>(volumes);
        if (maskVolumesMap != null) {
            remainingVolumes.addAll(maskVolumesMap.keySet());
        }
        for (URI volume : volumes) {
            remainingVolumes.remove(volume.toString());
            // are not in the mask to handle this condition.
            if ((maskVolumesMap != null) && (!maskVolumesMap.keySet().contains(volume.toString()))) {
                passedVolumesInMask.remove(volume);
            }
        }
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_043);
        // None of the volumes is in the export mask, so we are done.
        if (passedVolumesInMask.isEmpty()) {
            _log.info("None of these volumes {} are in export mask {}", volumes, exportMask.forDisplay());
            completer.ready(_dbClient);
            return;
        }
        // If it is last volume and there are no existing volumes, delete the ExportMask.
        if (remainingVolumes.isEmpty() && !exportMask.hasAnyExistingVolumes()) {
            device.doExportDelete(array, exportMask, passedVolumesInMask, initiatorURIs, completer);
        } else {
            List<Initiator> initiators = null;
            if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
                initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
            }
            device.doExportRemoveVolumes(array, exportMask, passedVolumesInMask, initiators, completer);
        }
    } catch (Exception ex) {
        _log.error("Failed to delete or remove volumes to export mask for vmax: ", ex);
        VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForCreateVolumesFailed(ex);
        completer.error(_dbClient, vplexex);
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ExportMaskOnlyRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 5 with ExportMaskOnlyRemoveVolumeCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter in project coprhd-controller by CoprHD.

the class VPlexVnxMaskingOrchestrator method deleteOrRemoveVolumesFromExportMask.

@Override
public void deleteOrRemoveVolumesFromExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumes, List<URI> initiatorURIs, String stepId) {
    ExportTaskCompleter completer = null;
    try {
        completer = new ExportMaskOnlyRemoveVolumeCompleter(exportGroupURI, exportMaskURI, volumes, stepId);
        WorkflowStepCompleter.stepExecuting(stepId);
        StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
        BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        // If the exportMask isn't found, or has been deleted, nothing to do.
        if (exportMask == null || exportMask.getInactive()) {
            _log.info(String.format("ExportMask %s inactive, returning success", exportMaskURI));
            completer.ready(_dbClient);
            return;
        }
        // Protect concurrent operations by locking {host, array} dupple.
        // Lock will be released when workflow step completes.
        List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
        getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
        // Refresh the ExportMask
        exportMask = refreshExportMask(array, device, exportMask);
        // Determine if we're deleting the last volume in the mask.
        StringMap maskVolumesMap = exportMask.getVolumes();
        Set<String> remainingVolumes = new HashSet<String>();
        List<URI> passedVolumesInMask = new ArrayList<>(volumes);
        if (maskVolumesMap != null) {
            remainingVolumes.addAll(maskVolumesMap.keySet());
        }
        for (URI volume : volumes) {
            remainingVolumes.remove(volume.toString());
            // are not in the mask to handle this condition.
            if ((maskVolumesMap != null) && (!maskVolumesMap.keySet().contains(volume.toString()))) {
                passedVolumesInMask.remove(volume);
            }
        }
        // None of the volumes is in the export mask, so we are done.
        if (passedVolumesInMask.isEmpty()) {
            _log.info("None of these volumes {} are in export mask {}", volumes, exportMask.forDisplay());
            completer.ready(_dbClient);
            return;
        }
        // If it is last volume and there are no existing volumes, delete the ExportMask.
        if (remainingVolumes.isEmpty() && !exportMask.hasAnyExistingVolumes()) {
            device.doExportDelete(array, exportMask, passedVolumesInMask, initiatorURIs, completer);
        } else {
            List<Initiator> initiators = null;
            if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
                initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
            }
            device.doExportRemoveVolumes(array, exportMask, passedVolumesInMask, initiators, completer);
        }
        completer.ready(_dbClient);
    } catch (Exception ex) {
        _log.error("Failed to delete or remove volumes to export mask for vnx: ", ex);
        VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForCreateVolumesFailed(ex);
        completer.error(_dbClient, vplexex);
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ExportMaskOnlyRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Aggregations

ExportMask (com.emc.storageos.db.client.model.ExportMask)7 Initiator (com.emc.storageos.db.client.model.Initiator)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)7 StringMap (com.emc.storageos.db.client.model.StringMap)7 BlockStorageDevice (com.emc.storageos.volumecontroller.BlockStorageDevice)7 ExportMaskOnlyRemoveVolumeCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter)7 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)7 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)7 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7