Search in sources :

Example 11 with ITLRestRep

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

the class BlockSnapshots method snapshotExports.

public static void snapshotExports(String snapshotId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    Map<URI, ExportGroupRestRep> exportGroups = Maps.newHashMap();
    Map<URI, List<ITLRestRep>> exportGroupItlMap = Maps.newHashMap();
    List<ITLRestRep> itls = client.blockSnapshots().listExports(uri(snapshotId));
    for (ITLRestRep itl : itls) {
        NamedRelatedResourceRep export = itl.getExport();
        if (export != null && export.getId() != null) {
            List<ITLRestRep> exportGroupItls = exportGroupItlMap.get(export.getId());
            if (exportGroupItls == null) {
                exportGroupItls = Lists.newArrayList();
                exportGroupItlMap.put(export.getId(), exportGroupItls);
            }
            exportGroupItls.add(itl);
            if (exportGroups.keySet().contains(export.getId()) == false) {
                ExportGroupRestRep exportGroup = client.blockExports().get(export.getId());
                exportGroups.put(exportGroup.getId(), exportGroup);
            }
        }
    }
    render(itls, exportGroups, exportGroupItlMap);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) List(java.util.List) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 12 with ITLRestRep

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

the class BlockVolumes method volumeExports.

public static void volumeExports(String volumeId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    Map<URI, ExportGroupRestRep> exportGroups = Maps.newHashMap();
    Map<URI, List<ITLRestRep>> exportGroupItlMap = Maps.newHashMap();
    List<ITLRestRep> itls = Lists.newArrayList();
    VolumeRestRep volume = client.blockVolumes().get(uri(volumeId));
    if (volume != null && volume.getInactive() == false) {
        itls = client.blockVolumes().getExports(uri(volumeId));
        for (ITLRestRep itl : itls) {
            NamedRelatedResourceRep export = itl.getExport();
            if (export != null && export.getId() != null) {
                List<ITLRestRep> exportGroupItls = exportGroupItlMap.get(export.getId());
                if (exportGroupItls == null) {
                    exportGroupItls = Lists.newArrayList();
                    exportGroupItlMap.put(export.getId(), exportGroupItls);
                }
                exportGroupItls.add(itl);
                if (exportGroups.keySet().contains(export.getId()) == false) {
                    ExportGroupRestRep exportGroup = client.blockExports().get(export.getId());
                    exportGroups.put(exportGroup.getId(), exportGroup);
                }
            }
        }
    }
    // Remove 'internal' marked export groups, we don't want to show these in the exports list
    Set<URI> internalExportGroups = Sets.newHashSet();
    for (ExportGroupRestRep exportGroup : exportGroups.values()) {
        if (Boolean.TRUE.equals(exportGroup.getInternal())) {
            internalExportGroups.add(exportGroup.getId());
        }
    }
    // Remove internal export groups
    exportGroups.keySet().removeAll(internalExportGroups);
    // Remove initiators from interal export groups
    exportGroupItlMap.keySet().removeAll(internalExportGroups);
    render(itls, exportGroups, exportGroupItlMap);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) List(java.util.List) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 13 with ITLRestRep

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

the class ExportService method populateIscsiConnectionInfo.

/*
     * Populate the connection info of the ISCSI volume after completing the 
     * export of volume to the host in ViPR
     */
private VolumeAttachResponse populateIscsiConnectionInfo(Volume vol) throws InterruptedException {
    ITLRestRepList listOfItls = ExportUtils.getBlockObjectInitiatorTargets(vol.getId(), _dbClient, isIdEmbeddedInURL(vol.getId()));
    VolumeAttachResponse objCinderInit = new VolumeAttachResponse();
    objCinderInit.connection_info = objCinderInit.new ConnectionInfo();
    objCinderInit.connection_info.data = objCinderInit.new Data();
    objCinderInit.connection_info.driver_volume_type = "iscsi";
    objCinderInit.connection_info.data.access_mode = "rw";
    objCinderInit.connection_info.data.target_discovered = false;
    for (ITLRestRep itl : listOfItls.getExportList()) {
        // TODO: user setter methods to set the values of object below.
        objCinderInit.connection_info.data.target_iqn = itl.getStoragePort().getPort();
        objCinderInit.connection_info.data.target_portal = itl.getStoragePort().getIpAddress() + ":" + itl.getStoragePort().getTcpPort();
        objCinderInit.connection_info.data.volume_id = getCinderHelper().trimId(vol.getId().toString());
        objCinderInit.connection_info.data.target_lun = itl.getHlu();
        _log.info(String.format("itl.getStoragePort().getPort() is %s: itl.getStoragePort().getIpAddress():%s,itl.getHlu() :%s, objCinderInit.toString():%s", itl.getStoragePort().getPort(), itl.getStoragePort().getIpAddress() + ":" + itl.getStoragePort().getTcpPort(), itl.getHlu(), objCinderInit.toString()));
        return objCinderInit;
    }
    return objCinderInit;
}
Also used : VolumeAttachResponse(com.emc.storageos.cinder.model.VolumeAttachResponse) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep)

Example 14 with ITLRestRep

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

the class ExportService method populateFcConnectionInfo.

/*
     * Populate the connection info of the FC volume after completing the 
     * export of volume to the host in ViPR
     */
private VolumeAttachResponse populateFcConnectionInfo(String chosenProtocol, Volume vol, VolumeActionRequest action, String openstackTenantId) throws InterruptedException {
    // After the exportt ask is complete, sometimes there is a delay in the info being reflected in ITL's. So, we are adding a
    // small delay here.
    Thread.sleep(100000);
    ITLRestRepList listOfItls = ExportUtils.getBlockObjectInitiatorTargets(vol.getId(), _dbClient, isIdEmbeddedInURL(vol.getId()));
    VolumeAttachResponse objCinderInit = new VolumeAttachResponse();
    objCinderInit.connection_info = objCinderInit.new ConnectionInfo();
    objCinderInit.connection_info.data = objCinderInit.new Data();
    objCinderInit.connection_info.data.target_wwn = new ArrayList<String>();
    objCinderInit.connection_info.data.initiator_target_map = new HashMap<String, List<String>>();
    objCinderInit.connection_info.driver_volume_type = "fibre_channel";
    objCinderInit.connection_info.data.access_mode = "rw";
    objCinderInit.connection_info.data.target_discovered = true;
    for (ITLRestRep itl : listOfItls.getExportList()) {
        // TODO: user setter methods to set the values of object below.
        _log.info("itl.getStoragePort().getPort() is {}", itl.getStoragePort().getPort());
        if (itl.getStoragePort().getPort() == null)
            continue;
        objCinderInit.connection_info.data.target_wwn.add(itl.getStoragePort().getPort().toString().replace(":", "").toLowerCase());
        objCinderInit.connection_info.data.volume_id = getCinderHelper().trimId(vol.getId().toString());
        objCinderInit.connection_info.data.target_lun = itl.getHlu();
        _log.info(String.format("itl.getStoragePort().getPort() is %s: itl.getStoragePort().getIpAddress():%s,itl.getHlu() :%s, objCinderInit.toString():%s", itl.getStoragePort().getPort(), itl.getStoragePort().getIpAddress() + ":" + itl.getStoragePort().getTcpPort(), itl.getHlu(), objCinderInit.connection_info.data.toString()));
    }
    List<Initiator> lstInitiators = getListOfInitiators(action.attach.connector, openstackTenantId, chosenProtocol, vol);
    for (Initiator iter : lstInitiators) {
        _log.info("iter.getInitiatorPort() {}", iter.getInitiatorPort());
        _log.info("objCinderInit.connection_info.data.target_wwn {}", objCinderInit.connection_info.data.target_wwn);
        objCinderInit.connection_info.data.initiator_target_map.put(iter.getInitiatorPort().replace(":", "").toLowerCase(), objCinderInit.connection_info.data.target_wwn);
    }
    return objCinderInit;
}
Also used : VolumeAttachResponse(com.emc.storageos.cinder.model.VolumeAttachResponse) Initiator(com.emc.storageos.db.client.model.Initiator) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) SearchedResRepList(com.emc.storageos.api.service.impl.response.SearchedResRepList)

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