Search in sources :

Example 21 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method generateZoningAddVolumesWorkflow.

protected String generateZoningAddVolumesWorkflow(Workflow workflow, String previousStep, ExportGroup exportGroup, List<ExportMask> exportMasks, List<URI> volumeURIs) throws WorkflowException {
    URI exportGroupURI = exportGroup.getId();
    List<URI> exportMaskURIs = new ArrayList<URI>();
    for (ExportMask mask : exportMasks) {
        exportMaskURIs.add(mask.getId());
    }
    String zoningStep = workflow.createStepId();
    Workflow.Method zoningExecuteMethod = _networkDeviceController.zoneExportAddVolumesMethod(exportGroupURI, exportMaskURIs, volumeURIs);
    Workflow.Method rollbackMethod = _networkDeviceController.zoneRollbackMethod(exportGroupURI, zoningStep);
    zoningStep = workflow.createStep((previousStep == null ? EXPORT_GROUP_ZONING_TASK : null), "Zoning subtask for export-group: " + exportGroupURI, previousStep, NullColumnValueGetter.getNullURI(), "network-system", _networkDeviceController.getClass(), zoningExecuteMethod, rollbackMethod, zoningStep);
    return zoningStep;
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI)

Example 22 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method logExportGroup.

/**
 * Method to display the ExportGroup collections and its related ExportMasks per StorageSystem
 *
 * @param exportGroup
 *            [in] - ExportGroup to display
 * @param storage
 *            [in] - Used to filter the associated ExportMasks to display
 */
protected void logExportGroup(ExportGroup exportGroup, URI storage) {
    if (exportGroup != null) {
        StackTraceElement[] elements = new Throwable().getStackTrace();
        String caller = String.format("%s#%s", elements[1].getClassName(), elements[1].getMethodName());
        StringBuilder message = new StringBuilder();
        message.append(String.format("ExportGroup before %s %n %s", caller, exportGroup.toString()));
        message.append(String.format("ExportMasks associated with ExportGroup and StorageSystem %s:", storage));
        for (ExportMask exportMask : ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storage)) {
            message.append('\n').append(exportMask.toString());
        }
        _log.info(message.toString());
    }
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask)

Example 23 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method generateZoningDeleteWorkflow.

protected String generateZoningDeleteWorkflow(Workflow workflow, String previousStep, ExportGroup exportGroup, List<ExportMask> exportMasks) throws WorkflowException {
    URI exportGroupURI = exportGroup.getId();
    List<URI> exportMaskURIs = new ArrayList<URI>();
    Set<URI> volumeURIs = new HashSet<>();
    for (ExportMask mask : exportMasks) {
        exportMaskURIs.add(mask.getId());
        volumeURIs.addAll(ExportMaskUtils.getVolumeURIs(mask));
    }
    List<NetworkZoningParam> zoningParams = NetworkZoningParam.convertExportMasksToNetworkZoningParam(exportGroupURI, exportMaskURIs, _dbClient);
    String zoningStep = workflow.createStepId();
    Workflow.Method zoningExecuteMethod = _networkDeviceController.zoneExportMasksDeleteMethod(zoningParams, volumeURIs);
    zoningStep = workflow.createStep((previousStep == null ? EXPORT_GROUP_ZONING_TASK : null), "Zoning subtask for export-group: " + exportGroupURI, previousStep, NullColumnValueGetter.getNullURI(), "network-system", _networkDeviceController.getClass(), zoningExecuteMethod, null, zoningStep);
    return zoningStep;
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) HashSet(java.util.HashSet) NetworkZoningParam(com.emc.storageos.networkcontroller.impl.NetworkZoningParam)

Example 24 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class NetworkZoningParam method convertExportMaskInitiatorMapsToNetworkZoningParam.

/**
 * Generates a list of NetworkZoningParam objects from a map of export mask URI to a list of initiator URIs.
 * Only the initiators in the exportMaskToInitiators map are retained from the ExportMask initiators.
 * @param exportGroupURI
 * @param exportMaskToInitiators
 * @param dbClient
 * @return
 */
public static List<NetworkZoningParam> convertExportMaskInitiatorMapsToNetworkZoningParam(URI exportGroupURI, Map<URI, List<URI>> exportMaskToInitiators, DbClient dbClient) {
    ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, exportGroupURI);
    List<NetworkZoningParam> zoningParams = new ArrayList<NetworkZoningParam>();
    for (Map.Entry<URI, List<URI>> entry : exportMaskToInitiators.entrySet()) {
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, entry.getKey());
        if (exportMask == null || exportMask.getInactive()) {
            throw WorkflowException.exceptions.workflowConstructionError("ExportMask is null: " + entry.getKey().toString());
        }
        NetworkZoningParam zoningParam = new NetworkZoningParam(exportGroup, exportMask, dbClient);
        // Filter out entries in the zoning map not in the initiator list.
        // This is done by retaining all the initiators in the exportMaskToInitiators value.
        Set<String> retainedInitiators = StringSetUtil.uriListToSet(entry.getValue());
        zoningParam.getZoningMap().keySet().retainAll(retainedInitiators);
        // Add zoningParam to result
        zoningParams.add(zoningParam);
    }
    return zoningParams;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Map(java.util.Map) URI(java.net.URI)

Example 25 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class ExportGroupService method validatePathAdjustment.

/**
 * Validate the path adjustment request parameters
 *
 * @param exportGroup ExportGroup object
 * @param system StorageSystem object
 * @param param Export Path Adjustment Parameters
 * @param varray URI of the virtual array, used to check any supplied ports are in correct varray
 */
private void validatePathAdjustment(ExportGroup exportGroup, StorageSystem system, ExportPathsAdjustmentParam param, URI varray) {
    String systemType = system.getSystemType();
    if (!Type.vmax.name().equalsIgnoreCase(systemType) && !Type.vplex.name().equalsIgnoreCase(systemType)) {
        throw APIException.badRequests.exportPathAdjustmentSystemNotSupported(systemType);
    }
    List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, system.getId());
    if (exportMasks.isEmpty()) {
        throw APIException.badRequests.exportPathAdjustmentSystemExportGroupNotMatch(exportGroup.getLabel(), system.getNativeGuid());
    }
    ExportPathParameters pathParam = param.getExportPathParameters();
    if (pathParam == null) {
        throw APIException.badRequests.exportPathAdjustementNoPathParameters();
    }
    URI pgURI = pathParam.getPortGroup();
    // Check if exportMask has existing volumes, if it does, make sure no remove paths.
    for (ExportMask exportMask : exportMasks) {
        List<InitiatorPathParam> removePaths = param.getRemovedPaths();
        if (removePaths.isEmpty() || !exportMask.hasAnyExistingVolumes()) {
            continue;
        }
        Map<URI, List<URI>> removes = new HashMap<URI, List<URI>>();
        for (InitiatorPathParam initPath : removePaths) {
            removes.put(initPath.getInitiator(), initPath.getStoragePorts());
        }
        Map<URI, List<URI>> removedPathForMask = ExportMaskUtils.getRemovePathsForExportMask(exportMask, removes);
        if (removedPathForMask != null && !removedPathForMask.isEmpty() && pgURI == null) {
            _log.error("It has removed path for the ExportMask with existing volumes: " + exportMask.getMaskName());
            throw APIException.badRequests.externallyAddedVolumes(exportMask.getMaskName(), exportMask.getExistingVolumes().toString());
        }
    }
    // check adjusted paths are valid. initiators are in the export group, and the targets are in the storage system, and
    // in valid state.
    Map<URI, List<URI>> adjustedPaths = convertInitiatorPathParamToMap(param.getAdjustedPaths());
    List<URI> pathInitiatorURIs = new ArrayList<URI>(adjustedPaths.keySet());
    StringSet initiatorIds = exportGroup.getInitiators();
    if (!initiatorIds.containsAll(StringSetUtil.uriListToStringSet(pathInitiatorURIs))) {
        // Determine all the host URIs for the egInitiators
        Set<URI> egHostURIs = new HashSet<URI>();
        List<Initiator> egInitiators = ExportUtils.getExportGroupInitiators(exportGroup, _dbClient);
        for (Initiator egInitiator : egInitiators) {
            if (!NullColumnValueGetter.isNullURI(egInitiator.getHost())) {
                egHostURIs.add(egInitiator.getHost());
            }
        }
        // Now, only throw error if there are initiators that are not of any of the egHostURIs
        List<Initiator> pathInitiators = _dbClient.queryObject(Initiator.class, pathInitiatorURIs);
        List<String> badInitiators = new ArrayList<String>();
        for (Initiator pathInitiator : pathInitiators) {
            // Bad if not in the EG initiatorIds AND not from an identifiable host or not from a host in EG
            if (!initiatorIds.contains(pathInitiator.getId().toString())) {
                if (pathInitiator.getHost() == null || !egHostURIs.contains(pathInitiator.getHost())) {
                    badInitiators.add(pathInitiator.getHostName() + "-" + pathInitiator.getInitiatorPort());
                }
            }
        }
        if (!badInitiators.isEmpty()) {
            throw APIException.badRequests.exportPathAdjustmentAdjustedPathNotValid(Joiner.on(", ").join(badInitiators));
        }
    }
    Set<URI> pathTargets = new HashSet<URI>();
    for (List<URI> targets : adjustedPaths.values()) {
        pathTargets.addAll(targets);
    }
    Set<URI> systemPorts = new HashSet<URI>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(system.getId()), storagePortURIs);
    // Validate the targets to be provisioned have a valid state (COMPATIBLE, REGISTERED, and VISIBLE) and
    // that their tagged virtual array contains our varray.
    List<StoragePort> storagePorts = _dbClient.queryObject(StoragePort.class, storagePortURIs);
    for (StoragePort port : storagePorts) {
        if (!port.getInactive() && port.getCompatibilityStatus().equals(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) && port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name()) && port.getDiscoveryStatus().equals(DiscoveryStatus.VISIBLE.name()) && port.getTaggedVirtualArrays() != null && port.getTaggedVirtualArrays().contains(varray.toString())) {
            systemPorts.add(port.getId());
        }
    }
    if (!systemPorts.containsAll(pathTargets)) {
        // List only the invalid targets
        pathTargets.removeAll(systemPorts);
        throw APIException.badRequests.exportPathAdjustmentAdjustedPathNotValid(Joiner.on(",").join(pathTargets));
    }
}
Also used : HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) SearchedResRepList(com.emc.storageos.api.service.impl.response.SearchedResRepList) InitiatorPathParam(com.emc.storageos.model.block.export.InitiatorPathParam) ExportPathParameters(com.emc.storageos.model.block.export.ExportPathParameters) HashSet(java.util.HashSet)

Aggregations

ExportMask (com.emc.storageos.db.client.model.ExportMask)368 URI (java.net.URI)274 ArrayList (java.util.ArrayList)224 Initiator (com.emc.storageos.db.client.model.Initiator)155 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)140 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)134 HashMap (java.util.HashMap)128 HashSet (java.util.HashSet)121 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)107 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)102 List (java.util.List)79 StringSet (com.emc.storageos.db.client.model.StringSet)68 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)65 Map (java.util.Map)65 StringMap (com.emc.storageos.db.client.model.StringMap)60 BlockObject (com.emc.storageos.db.client.model.BlockObject)56 NamedURI (com.emc.storageos.db.client.model.NamedURI)56 Workflow (com.emc.storageos.workflow.Workflow)54 Set (java.util.Set)51 Volume (com.emc.storageos.db.client.model.Volume)44