Search in sources :

Example 6 with ITLRestRepList

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

ITLRestRepList (com.emc.storageos.model.block.export.ITLRestRepList)6 ArrayList (java.util.ArrayList)4 Initiator (com.emc.storageos.db.client.model.Initiator)3 List (java.util.List)3 VolumeAttachResponse (com.emc.storageos.cinder.model.VolumeAttachResponse)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)2 SearchedResRepList (com.emc.storageos.api.service.impl.response.SearchedResRepList)1 HashMap (java.util.HashMap)1 UriBuilder (javax.ws.rs.core.UriBuilder)1