Search in sources :

Example 11 with ExportGroup

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

the class RpVplexVolumeIngestionContext method commit.

/* (non-Javadoc)
     * @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext#commit()
     */
@Override
public void commit() {
    // if this is an RP/VPLEX that is exported to a host or cluster, add the volume to the ExportGroup
    ExportGroup rootExportGroup = getRootIngestionRequestContext().getExportGroup();
    if (rootExportGroup != null && VolumeIngestionUtil.checkUnManagedResourceIsNonRPExported(getUnmanagedVolume())) {
        _logger.info("Adding exported RP/VPLEX virtual volume {} to ExportGroup {}", getManagedBlockObject().forDisplay(), rootExportGroup.forDisplay());
        rootExportGroup.addVolume(getManagedBlockObject().getId(), ExportGroup.LUN_UNASSIGNED);
    }
    _vplexVolumeIngestionContext.commit();
    super.commit();
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup)

Example 12 with ExportGroup

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

the class ExportUtils method getBlockObjectExportMasks.

/**
 * Fetches all the export masks in which a block object is member
 *
 * @param blockObject the block object
 * @param dbClient an instance of {@link DbClient}
 * @return a map of export masks in which a block object is member
 */
private static Map<ExportMask, List<ExportGroup>> getBlockObjectExportMasks(BlockObject blockObject, DbClient dbClient) {
    Map<ExportMask, List<ExportGroup>> exportMasks = new HashMap<ExportMask, List<ExportGroup>>();
    ContainmentConstraint constraint = ContainmentConstraint.Factory.getBlockObjectExportGroupConstraint(blockObject.getId());
    // permission are checked by the API service - no need to check again
    List<ExportGroup> exportGroups = getExportGroupsByConstraint(constraint, dbClient, null, null);
    List<ExportMask> masks = getMasksForExportGroups(exportGroups, dbClient);
    // Get the actual export block object associated with the snapshot (if applicable)
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        for (ExportMask exportMask : masks) {
            if (exportMask != null && !exportMask.getInactive() && exportMask.hasVolume(bo.getId()) && (exportMask.getInitiators() != null || exportMask.getExistingInitiators() != null)) {
                List<ExportGroup> maskGroups = new ArrayList<ExportGroup>();
                exportMasks.put(exportMask, maskGroups);
                for (ExportGroup group : exportGroups) {
                    if (group.getExportMasks() != null && group.getExportMasks().contains(exportMask.getId().toString())) {
                        maskGroups.add(group);
                    }
                }
            }
        }
        _log.debug("Found {} export masks for block object {}", exportMasks.size(), bo.getLabel());
    }
    return exportMasks;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 13 with ExportGroup

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

the class ExportUtils method getItlsForMaskInitiator.

/**
 * For a volume/snapshot-initiator pair find the target ports for the initiator in the list of
 * ports and find the zone name if zoning was performed. Return a list of ITLs for
 * each volume-initiator-target found.
 *
 * @param dbClient db client
 * @param exportMask the export mask the initiator is in
 * @param initiator the initiator
 * @param hlu the lun Id used by the initiator for the volume
 * @param blockObject the volume or snapshot
 * @param initiatorPorts ports to which the initiator is zoned in the export mask
 * @param zoneRefs a map of port-to-zone-reference
 * @param exportGroup the export groups in this export mask
 * @return all ITLs for a volume/snapshot-initiator pair.
 */
private static List<ITLRestRep> getItlsForMaskInitiator(DbClient dbClient, List<ExportGroup> exportGroups, ExportMask exportMask, Initiator initiator, String hlu, BlockObject blockObject, List<StoragePort> initiatorPorts, Map<StoragePort, List<FCZoneReference>> zoneRefs) {
    List<ITLRestRep> list = new ArrayList<ITLRestRep>();
    Map<StoragePort, FCZoneReference> initiatorZoneRefs = null;
    // Find the block object that would appear in the Export Mask
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        _log.debug("Finding target ports for initiator {} and block object {}", initiator.getInitiatorPort(), bo.getNativeGuid());
        initiatorZoneRefs = getZoneReferences(bo.getId(), initiator, initiatorPorts, zoneRefs);
        _log.debug("{} target ports and {} SAN zones were found for initiator {} and block object {}", new Object[] { initiatorPorts.size(), initiatorZoneRefs.size(), initiator.getInitiatorPort(), bo.getNativeGuid() });
        // TODO - Should we add special handling of iscsi initiators?
        for (ExportGroup exportGroup : exportGroups) {
            if (exportGroup.getVolumes() != null && exportGroup.getVolumes().containsKey(blockObject.getId().toString()) && exportGroup.getInitiators() != null && exportGroup.getInitiators().contains(initiator.getId().toString())) {
                // We want to check if there are any ports in this export group for this initiator
                List<StoragePort> portsInExportGroupVarray = filterPortsInVarray(exportGroup, exportMask.getStorageDevice(), initiatorPorts);
                if (!portsInExportGroupVarray.isEmpty()) {
                    for (StoragePort port : portsInExportGroupVarray) {
                        list.add(createInitiatorTargetRefRep(exportGroup, blockObject, hlu, initiator, port, initiatorZoneRefs.get(port)));
                    }
                } else {
                    list.add(createInitiatorTargetRefRep(exportGroup, blockObject, hlu, initiator, null, null));
                }
            }
        }
    }
    return list;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) BlockObject(com.emc.storageos.db.client.model.BlockObject) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 14 with ExportGroup

use of com.emc.storageos.db.client.model.ExportGroup 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 15 with ExportGroup

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

the class ExportUtilsTestUtils method createExportGroup.

public static ExportGroup createExportGroup(DbClientImpl _dbClient, List<Initiator> initiators, List<Volume> volumes, VirtualArray varray, int i) {
    ExportGroup eg = new ExportGroup();
    String label = "eg" + i;
    eg.setId(URI.create(label));
    eg.setLabel(label);
    eg.setVirtualArray(varray.getId());
    for (Initiator initiator : initiators) {
        eg.addInitiator(initiator);
    }
    for (Volume volume : volumes) {
        eg.addVolume(volume.getId(), i);
    }
    _dbClient.createObject(eg);
    return eg;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) Volume(com.emc.storageos.db.client.model.Volume)

Aggregations

ExportGroup (com.emc.storageos.db.client.model.ExportGroup)278 URI (java.net.URI)206 ArrayList (java.util.ArrayList)139 ExportMask (com.emc.storageos.db.client.model.ExportMask)138 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)111 HashMap (java.util.HashMap)94 Initiator (com.emc.storageos.db.client.model.Initiator)86 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)84 NamedURI (com.emc.storageos.db.client.model.NamedURI)80 HashSet (java.util.HashSet)70 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)63 Workflow (com.emc.storageos.workflow.Workflow)61 List (java.util.List)59 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)55 BlockObject (com.emc.storageos.db.client.model.BlockObject)49 Map (java.util.Map)47 ExportOrchestrationTask (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask)44 ControllerException (com.emc.storageos.volumecontroller.ControllerException)41 StringSet (com.emc.storageos.db.client.model.StringSet)38 StringMap (com.emc.storageos.db.client.model.StringMap)33