Search in sources :

Example 26 with ExportMask

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

the class ExportGroupService method getVolumes.

// This was originally in the ExportGroupRestRep
private Map<String, Integer> getVolumes(ExportGroup exportGroup) {
    Map<String, Integer> volumesMap = new HashMap<String, Integer>();
    StringMap volumes = exportGroup.getVolumes();
    for (ExportMask exportMask : ExportMaskUtils.getExportMasks(_dbClient, exportGroup)) {
        try {
            if (exportMask != null && exportMask.getVolumes() != null) {
                for (Map.Entry<String, String> entry : exportMask.getVolumes().entrySet()) {
                    if (!volumesMap.containsKey(entry.getKey()) && (entry.getValue() != null)) {
                        // ensure that this volume is referenced by this export group
                        if (volumes != null && volumes.containsKey(entry.getKey())) {
                            volumesMap.put(entry.getKey(), Integer.valueOf(entry.getValue()));
                        }
                    }
                }
            }
        } catch (Exception e) {
            _log.error("Error getting volumes for export group {}", exportGroup.getId(), e);
        }
    }
    /*
         * Now include any volumes that might be a part of the Export Group
         * but not of the Export Mask.
         */
    if (volumes != null) {
        for (Map.Entry<String, String> entry : volumes.entrySet()) {
            if (!volumesMap.containsKey(entry.getKey()) && (entry.getValue() != null)) {
                volumesMap.put(entry.getKey(), Integer.valueOf(entry.getValue()));
            }
        }
    }
    return volumesMap;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) PlacementException(com.emc.storageos.volumecontroller.placement.PlacementException)

Example 27 with ExportMask

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

the class ExportGroupService method validateNoConflictingExports.

/**
 * Throw an error if we cannot override the Vpool path parameters because there is already
 * an existing export from the indicated host(s) to storage array(s).
 *
 * @param exportGroup
 * @param arrayURIs
 * @param pathParam -- New ExportPathParams to be used
 */
private void validateNoConflictingExports(ExportGroup exportGroup, Set<URI> arrayURIs, ExportPathParams pathParam) {
    _log.info("Requested path parameters: " + pathParam.toString());
    Map<String, String> conflictingMasks = new HashMap<String, String>();
    StringSet initiators = exportGroup.getInitiators();
    if (initiators == null) {
        // No initiators currently in export, nothing to do
        return;
    }
    for (String initiatorId : initiators) {
        Initiator initiator = _dbClient.queryObject(Initiator.class, URI.create(initiatorId));
        if (initiator == null || initiator.getInactive()) {
            continue;
        }
        // Look up all the Export Masks for this Initiator
        List<ExportMask> exportMasks = ExportUtils.getInitiatorExportMasks(initiator, _dbClient);
        for (ExportMask exportMask : exportMasks) {
            // If this mask is for the same Host and Storage combination, we cannot override
            if (arrayURIs.contains(exportMask.getStorageDevice())) {
                ExportPathParams maskParam = BlockStorageScheduler.calculateExportPathParamForExportMask(_dbClient, exportMask);
                _log.info(String.format("Existing mask %s (%s) parameters: %s", exportMask.getMaskName(), exportMask.getId(), maskParam));
                // i.e. maskParams.ppi = pathParms.ppi and pathParams.minPath <= maskParams.maxpath <= pathParams.maxPath
                if (pathParam.getPathsPerInitiator() == maskParam.getPathsPerInitiator() && (pathParam.getMinPaths() <= maskParam.getMaxPaths() && maskParam.getMaxPaths() <= pathParam.getMaxPaths())) {
                    _log.info(String.format("Export mask %s is compatible with the requested parameters", exportMask.getMaskName()));
                } else {
                    StorageSystem system = _dbClient.queryObject(StorageSystem.class, exportMask.getStorageDevice());
                    String hostName = (initiator.getHostName() != null) ? initiator.getHostName() : initiatorId;
                    String systemName = (system != null) ? system.getLabel() : exportMask.getStorageDevice().toString();
                    if (!conflictingMasks.containsKey(hostName)) {
                        String msg = String.format("Export Mask %s for Host %s and Array %s has %d paths and paths_per_initiator %d", exportMask.getMaskName(), hostName, systemName, maskParam.getMaxPaths(), maskParam.getPathsPerInitiator());
                        conflictingMasks.put(hostName, msg);
                    }
                }
            }
        }
    }
    if (!conflictingMasks.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        for (Entry<String, String> entry : conflictingMasks.entrySet()) {
            if (builder.length() != 0) {
                builder.append("; ");
            }
            builder.append(entry.getValue());
        }
        throw APIException.badRequests.cannotOverrideVpoolPathsBecauseExistingExports(builder.toString());
    }
}
Also used : HashMap(java.util.HashMap) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) StringSet(com.emc.storageos.db.client.model.StringSet) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 28 with ExportMask

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

the class ExportUtilsTests method populateDb.

/**
 * Populate the database with ITL components
 */
public void populateDb() {
    String[] vmaxFE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01", "50:FE:FE:FE:FE:FE:FE:02", "50:FE:FE:FE:FE:FE:FE:03" };
    // Create a Network
    Network network = ExportUtilsTestUtils.createNetwork(_dbClient, vmaxFE, "VSANFE", "FC+BROCADE+FE", null);
    // Create a Virtual Array
    VirtualArray varray = ExportUtilsTestUtils.createVirtualArray(_dbClient, "varray1");
    // Create a storage system
    StorageSystem storageSystem = ExportUtilsTestUtils.createStorageSystem(_dbClient, "vmax", "vmax1");
    // Create two front-end storage ports VMAX
    List<StoragePort> vmaxPorts = new ArrayList<StoragePort>();
    for (int i = 0; i < vmaxFE.length; i++) {
        vmaxPorts.add(ExportUtilsTestUtils.createStoragePort(_dbClient, storageSystem, network, vmaxFE[i], varray, StoragePort.PortType.frontend.name(), "portGroupvmax" + i, "C0+FC0" + i));
    }
    // Create initiators
    List<Initiator> initiators = new ArrayList<Initiator>();
    for (int i = 0; i < NUM_INITIATORS; i++) {
        initiators.add(ExportUtilsTestUtils.createInitiator(_dbClient, network, i));
    }
    // Create Volumes
    List<Volume> volumes = new ArrayList<Volume>();
    for (int i = 0; i < NUM_VOLUMES; i++) {
        Volume volume = ExportUtilsTestUtils.createVolume(_dbClient, varray, i);
        volumes.add(volume);
        _volumeIds.add(volume.getId());
    }
    // Create export groups
    List<ExportGroup> egs = new ArrayList<ExportGroup>();
    for (int i = 0; i < NUM_EXPORT_GROUPS; i++) {
        egs.add(ExportUtilsTestUtils.createExportGroup(_dbClient, initiators, volumes, varray, i));
    }
    // Create export masks
    List<ExportMask> ems = new ArrayList<ExportMask>();
    for (int i = 0; i < NUM_EXPORT_MASKS; i++) {
        ems.add(ExportUtilsTestUtils.createExportMask(_dbClient, egs, initiators, volumes, vmaxPorts, i));
    }
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) Volume(com.emc.storageos.db.client.model.Volume) Network(com.emc.storageos.db.client.model.Network) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 29 with ExportMask

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

the class UcsComputeDevice method getHBAToStoragePorts.

private Map<String, Map<String, Integer>> getHBAToStoragePorts(URI volumeId, URI hostId) {
    Host host = _dbClient.queryObject(Host.class, hostId);
    Map<String, String> initiatorToHBAMapping = getInitiatorToHBAMapping(host.getComputeElement());
    Volume volume = _dbClient.queryObject(Volume.class, volumeId);
    List<Initiator> initiators = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, hostId, Initiator.class, "host");
    Map<ExportMask, ExportGroup> exportMasks = ExportUtils.getExportMasks(volume, _dbClient);
    Map<String, Map<String, Integer>> hbaToStoragePortMapForBoot = new HashMap<String, Map<String, Integer>>();
    for (Initiator initiator : initiators) {
        for (ExportMask exportMask : exportMasks.keySet()) {
            List<URI> storagePorts = ExportUtils.getInitiatorPortsInMask(exportMask, initiator, _dbClient);
            if (storagePorts != null && !storagePorts.isEmpty()) {
                Integer volumeHLU = Integer.valueOf(exportMask.getVolumes().get(volumeId.toString()));
                for (URI storagePortUri : storagePorts) {
                    StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortUri);
                    String hbaName = initiatorToHBAMapping.get(initiator.getInitiatorPort());
                    if (hbaName != null) {
                        if (hbaToStoragePortMapForBoot.get(hbaName) == null) {
                            hbaToStoragePortMapForBoot.put(hbaName, new HashMap<String, Integer>());
                        }
                        hbaToStoragePortMapForBoot.get(hbaName).put(port.getPortNetworkId(), volumeHLU);
                    }
                }
            }
        }
    }
    return hbaToStoragePortMapForBoot;
}
Also used : HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) Initiator(com.emc.storageos.db.client.model.Initiator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 30 with ExportMask

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

the class MaskPerHostIngestOrchestrator method getExportMaskAlreadyIngested.

/**
 * maskPerHost Mode guaranteed to have initiators in only 1 export mask
 * always.
 */
@Override
protected ExportMask getExportMaskAlreadyIngested(UnManagedExportMask mask, DbClient dbClient) {
    ExportMask eMask = null;
    boolean maskFound = false;
    List<URI> initiatorUris = new ArrayList<URI>(Collections2.transform(mask.getKnownInitiatorUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
    for (URI ini : initiatorUris) {
        List<URI> exportMaskUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportMaskInitiatorConstraint(ini.toString()));
        if (null == exportMaskUris) {
            return eMask;
        }
        for (URI eMaskUri : exportMaskUris) {
            ExportMask potentialMask = _dbClient.queryObject(ExportMask.class, eMaskUri);
            if (potentialMask.getStorageDevice() != null && potentialMask.getStorageDevice().equals(mask.getStorageSystemUri())) {
                _logger.info("Found Mask {} with matching initiator and matching Storage System", eMaskUri);
                eMask = potentialMask;
                maskFound = true;
                break;
            } else {
                _logger.info("Found Mask {} with matching initiator and unmatched Storage System. Skipping mask", eMaskUri);
            }
        }
        if (maskFound) {
            break;
        }
    }
    return eMask;
}
Also used : UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI)

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