Search in sources :

Example 1 with XtremIOLunMap

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap in project coprhd-controller by CoprHD.

the class XtremIOExportOperations method findHLUsForInitiators.

@Override
public Set<Integer> findHLUsForInitiators(StorageSystem storage, List<String> initiatorNames, boolean mustHaveAllPorts) {
    Set<Integer> usedHLUs = new HashSet<Integer>();
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        Set<String> igNames = new HashSet<>();
        String xioClusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        for (String initiatorName : initiatorNames) {
            initiatorName = Initiator.toPortNetworkId(initiatorName);
            URIQueryResultList initiatorResult = new URIQueryResultList();
            dbClient.queryByConstraint(AlternateIdConstraint.Factory.getInitiatorPortInitiatorConstraint(initiatorName), initiatorResult);
            if (initiatorResult.iterator().hasNext()) {
                Initiator initiator = dbClient.queryObject(Initiator.class, initiatorResult.iterator().next());
                String igName = XtremIOProvUtils.getIGNameForInitiator(initiator, storage.getSerialNumber(), client, xioClusterName);
                if (igName != null && !igName.isEmpty()) {
                    igNames.add(igName);
                }
            }
        }
        // get the lun maps for IGs
        for (String igName : igNames) {
            List<XtremIOObjectInfo> lunMapLinks = XtremIOProvUtils.getInitiatorGroupLunMaps(igName, xioClusterName, client);
            List<XtremIOLunMap> lunMaps = client.getXtremIOLunMapsForLinks(lunMapLinks, xioClusterName);
            for (XtremIOLunMap lunMap : lunMaps) {
                _log.info("Looking at lun map {}; IG name: {}, Volume: {}, HLU: {}", lunMap.getMappingInfo().get(2), lunMap.getIgName(), lunMap.getVolumeName(), lunMap.getLun());
                usedHLUs.add(Integer.valueOf(lunMap.getLun()));
            }
        }
        _log.info(String.format("HLUs found for Initiators { %s }: %s", Joiner.on(',').join(initiatorNames), usedHLUs));
    } catch (Exception e) {
        String errMsg = "Encountered an error when attempting to query used HLUs for initiators: " + e.getMessage();
        _log.error(errMsg, e);
        throw XtremIOApiException.exceptions.hluRetrievalFailed(errMsg, e);
    }
    return usedHLUs;
}
Also used : XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) HashSet(java.util.HashSet)

Example 2 with XtremIOLunMap

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap in project coprhd-controller by CoprHD.

the class XtremIOV1Client method getXtremIOLunMapsForLinks.

@Override
public List<XtremIOLunMap> getXtremIOLunMapsForLinks(List<XtremIOObjectInfo> lunMapLinks, String clusterName) throws Exception {
    List<XtremIOLunMap> lunMapList = new ArrayList<XtremIOLunMap>();
    for (XtremIOObjectInfo lunMapInfo : lunMapLinks) {
        URI lunMapURI = URI.create(URIUtil.getFromPath(lunMapInfo.getHref()));
        ClientResponse response = get(lunMapURI);
        XtremIOLunMaps lunMaps = getResponseObject(XtremIOLunMaps.class, response);
        log.debug("LunMap {}", lunMaps.getContent().getMappingInfo().get(1) + " - " + lunMaps.getContent().getMappingInfo().get(2));
        lunMapList.add(lunMaps.getContent());
    }
    return lunMapList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOLunMaps(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMaps) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) URI(java.net.URI)

Example 3 with XtremIOLunMap

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap in project coprhd-controller by CoprHD.

the class XtremIOV2Client method getXtremIOLunMaps.

@Override
public List<XtremIOLunMap> getXtremIOLunMaps(String clusterName) throws Exception {
    String uriString = XtremIOConstants.XTREMIO_V2_LUNMAPS_STR.concat(XtremIOConstants.getInputClusterString(clusterName));
    ClientResponse response = get(URI.create(uriString));
    XtremIOLunMapsInfo lunMapLinks = getResponseObject(XtremIOLunMapsInfo.class, response);
    log.info("Returned LunMaps Links size : {}", lunMapLinks.getLunMapInfo().length);
    List<XtremIOLunMap> lunMapList = getXtremIOLunMapsForLinks(Arrays.asList(lunMapLinks.getLunMapInfo()), clusterName);
    return lunMapList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) XtremIOLunMapsInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapsInfo)

Example 4 with XtremIOLunMap

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap in project coprhd-controller by CoprHD.

the class XtremIOV2Client method getXtremIOLunMapsForLinks.

@Override
public List<XtremIOLunMap> getXtremIOLunMapsForLinks(List<XtremIOObjectInfo> lunMapLinks, String clusterName) throws Exception {
    List<XtremIOLunMap> lunMapList = new ArrayList<XtremIOLunMap>();
    for (XtremIOObjectInfo lunMapInfo : lunMapLinks) {
        URI lunMapURI = URI.create(URIUtil.getFromPath(lunMapInfo.getHref().concat(XtremIOConstants.getInputClusterString(clusterName))));
        ClientResponse response = get(lunMapURI);
        XtremIOLunMaps lunMaps = getResponseObject(XtremIOLunMaps.class, response);
        log.info("LunMap {}", lunMaps.getContent().getMappingInfo().get(1) + " - " + lunMaps.getContent().getMappingInfo().get(2));
        lunMapList.add(lunMaps.getContent());
    }
    return lunMapList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOLunMaps(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMaps) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) URI(java.net.URI)

Example 5 with XtremIOLunMap

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap in project coprhd-controller by CoprHD.

the class XtremIOV1Client method getXtremIOLunMaps.

@Override
public List<XtremIOLunMap> getXtremIOLunMaps(String clusterName) throws Exception {
    ClientResponse response = get(XtremIOConstants.XTREMIO_LUNMAPS_URI);
    XtremIOLunMapsInfo lunMapLinks = getResponseObject(XtremIOLunMapsInfo.class, response);
    log.info("Returned LunMaps Links size : {}", lunMapLinks.getLunMapInfo().length);
    List<XtremIOLunMap> lunMapList = getXtremIOLunMapsForLinks(Arrays.asList(lunMapLinks.getLunMapInfo()), clusterName);
    return lunMapList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) XtremIOLunMapsInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapsInfo)

Aggregations

XtremIOLunMap (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap)7 XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 XtremIOLunMaps (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMaps)2 XtremIOLunMapsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapsInfo)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)1 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)1 XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)1 XtremIOLunMapFull (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapFull)1 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)1 XtremIOVolumesFull (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolumesFull)1