Search in sources :

Example 1 with ITLRestRep

use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.

the class ExportUtils method createInitiatorTargetRefRep.

/**
 * Creates and returns an instance of REST response object.
 *
 * @param exportGroup the export group the initiator is in
 * @param blockObject the block object
 * @param hlu the lun id used for the block object by the initiator
 * @param initiator the initiator
 * @param port the target port
 * @param fcZoneReference the record of the SAN zone created on the switch when a zone is created.
 *            Returns null when zoning is not required or when the zone creation failed.
 * @return the export REST response object.
 */
private static ITLRestRep createInitiatorTargetRefRep(ExportGroup exportGroup, BlockObject blockObject, String hlu, Initiator initiator, StoragePort port, FCZoneReference fcZoneReference) {
    ITLRestRep rep = new ITLRestRep();
    rep.setHlu(Integer.parseInt(hlu));
    // Set block object
    ITLRestRep.ITLBlockObjectRestRep blockObjectRestRep = new ITLRestRep.ITLBlockObjectRestRep();
    blockObjectRestRep.setId(blockObject.getId());
    blockObjectRestRep.setLink(new RestLinkRep("self", RestLinkFactory.newLink(blockObject)));
    blockObjectRestRep.setWwn(getBlockObjectFormattedWWN(blockObject));
    rep.setBlockObject(blockObjectRestRep);
    // Set initiator
    ITLRestRep.ITLInitiatorRestRep initiatorRestRep = new ITLRestRep.ITLInitiatorRestRep();
    initiatorRestRep.setId(initiator.getId());
    initiatorRestRep.setLink(new RestLinkRep("self", RestLinkFactory.newLink(initiator)));
    initiatorRestRep.setPort(initiator.getInitiatorPort());
    rep.setInitiator(initiatorRestRep);
    // Set storage port
    ITLRestRep.ITLStoragePortRestRep storagePortRestRep = new ITLRestRep.ITLStoragePortRestRep();
    if (port != null) {
        storagePortRestRep.setId(port.getId());
        storagePortRestRep.setLink(new RestLinkRep("self", RestLinkFactory.newLink(port)));
        storagePortRestRep.setPort(port.getPortNetworkId());
        if (port.getIpAddress() != null) {
            storagePortRestRep.setIpAddress(port.getIpAddress());
            storagePortRestRep.setTcpPort(String.valueOf(port.getTcpPortNumber()));
        }
    }
    rep.setStoragePort(storagePortRestRep);
    // Export
    rep.setExport(toNamedRelatedResource(exportGroup, exportGroup.getLabel()));
    if (fcZoneReference != null) {
        rep.setSanZoneName(fcZoneReference.getZoneName());
    }
    return rep;
}
Also used : RestLinkRep(com.emc.storageos.model.RestLinkRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep)

Example 2 with ITLRestRep

use of com.emc.storageos.model.block.export.ITLRestRep 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 3 with ITLRestRep

use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.

the class ResourceUtils method getExportMap.

private static Map<ITLRestRep, ExportGroupRestRep> getExportMap(Collection<ITLRestRep> itls) {
    Map<URI, ExportGroupRestRep> blockExports = getBlockExports(itls);
    Map<ITLRestRep, ExportGroupRestRep> exports = Maps.newLinkedHashMap();
    for (ITLRestRep itl : itls) {
        URI exportId = id(itl.getExport());
        if (exportId != null) {
            exports.put(itl, blockExports.get(exportId));
        }
    }
    return exports;
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) URI(java.net.URI)

Example 4 with ITLRestRep

use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.

the class VMWareProvider method getVolumeHLUs.

private Map<URI, Integer> getVolumeHLUs(AssetOptionsContext context, List<URI> volumeIds) {
    BulkIdParam bulkParam = new BulkIdParam();
    Map<URI, Integer> volumeHLUs = Maps.newHashMap();
    bulkParam.getIds().addAll(volumeIds);
    List<ITLRestRep> bulkResponse = api(context).blockVolumes().getExports(bulkParam).getExportList();
    for (ITLRestRep export : bulkResponse) {
        volumeHLUs.put(export.getBlockObject().getId(), export.getHlu());
    }
    return volumeHLUs;
}
Also used : BulkIdParam(com.emc.storageos.model.BulkIdParam) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) URI(java.net.URI)

Example 5 with ITLRestRep

use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method removeBlockResourcesFromExports.

public static void removeBlockResourcesFromExports(Collection<URI> blockResourceIds) {
    Map<URI, Set<URI>> resourcesInExport = Maps.newHashMap();
    for (URI blockResourceId : blockResourceIds) {
        List<ITLRestRep> exports = getExportsForBlockObject(blockResourceId);
        for (ITLRestRep export : exports) {
            URI exportId = export.getExport().getId();
            if (resourcesInExport.containsKey(exportId)) {
                resourcesInExport.get(exportId).add(blockResourceId);
            } else {
                resourcesInExport.put(exportId, Sets.newHashSet(blockResourceId));
            }
        }
    }
    removeBlockResourcesFromExports(resourcesInExport);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) GetBlockSnapshotSet(com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSet) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) URI(java.net.URI)

Aggregations

ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)14 URI (java.net.URI)8 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 List (java.util.List)3 GetBlockSnapshotSet (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSet)2 VolumeAttachResponse (com.emc.storageos.cinder.model.VolumeAttachResponse)2 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 ITLRestRepList (com.emc.storageos.model.block.export.ITLRestRepList)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 VerifyMountPoint (com.emc.sa.service.linux.tasks.VerifyMountPoint)1 FindBlockVolumeHlus (com.emc.sa.service.vipr.block.tasks.FindBlockVolumeHlus)1 SearchedResRepList (com.emc.storageos.api.service.impl.response.SearchedResRepList)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1 FCZoneReference (com.emc.storageos.db.client.model.FCZoneReference)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1