Search in sources :

Example 1 with XtremIOObjectInfo

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo 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 XtremIOObjectInfo

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

the class XtremIOProvUtils method getInitiatorGroupLunMaps.

/**
 * Gets the lun maps for the initiator group.
 *
 * @param igName
 *            the ig name
 * @param clusterName
 *            the cluster name
 * @param client
 *            the xtremio client
 * @return the initiator group lun maps
 * @throws Exception
 */
public static List<XtremIOObjectInfo> getInitiatorGroupLunMaps(String igName, String clusterName, XtremIOClient client) throws Exception {
    List<XtremIOObjectInfo> igLunMaps = new ArrayList<XtremIOObjectInfo>();
    if (client.isVersion2()) {
        igLunMaps = client.getLunMapsForInitiatorGroup(igName, clusterName);
    } else {
        XtremIOInitiatorGroup ig = client.getInitiatorGroup(igName, clusterName);
        if (ig == null) {
            return igLunMaps;
        }
        List<XtremIOObjectInfo> lunMaps = client.getLunMaps(clusterName);
        String igIndex = ig.getIndex();
        for (XtremIOObjectInfo lunMap : lunMaps) {
            String[] lunInfo = lunMap.getName().split(XtremIOConstants.UNDERSCORE);
            if (igIndex.equals(lunInfo[1])) {
                igLunMaps.add(lunMap);
            }
        }
    }
    return igLunMaps;
}
Also used : XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)

Example 3 with XtremIOObjectInfo

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo 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 4 with XtremIOObjectInfo

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

the class XtremIOV1Client method getXtremIOPortInfo.

@Override
public List<XtremIOPort> getXtremIOPortInfo(String clusterName) throws Exception {
    ClientResponse response = get(XtremIOConstants.XTREMIO_TARGETS_URI);
    XtremIOPortsInfo targetPortLinks = getResponseObject(XtremIOPortsInfo.class, response);
    log.info("Returned Target Links size : {}", targetPortLinks.getPortInfo().length);
    List<XtremIOPort> targetPortList = new ArrayList<XtremIOPort>();
    for (XtremIOObjectInfo targetPortInfo : targetPortLinks.getPortInfo()) {
        URI targetPortUri = URI.create(URIUtil.getFromPath(targetPortInfo.getHref()));
        response = get(targetPortUri);
        XtremIOPorts targetPorts = getResponseObject(XtremIOPorts.class, response);
        log.info("Target Port {}", targetPorts.getContent().getName() + "-" + targetPorts.getContent().getPortAddress());
        targetPortList.add(targetPorts.getContent());
    }
    return targetPortList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOPortsInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOPortsInfo) XtremIOPort(com.emc.storageos.xtremio.restapi.model.response.XtremIOPort) ArrayList(java.util.ArrayList) XtremIOPorts(com.emc.storageos.xtremio.restapi.model.response.XtremIOPorts) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) URI(java.net.URI)

Example 5 with XtremIOObjectInfo

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo 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)

Aggregations

XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)15 ArrayList (java.util.ArrayList)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 URI (java.net.URI)9 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)4 XtremIOLunMap (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap)4 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)4 XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)2 XtremIOInitiatorGroup (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup)2 XtremIOInitiators (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators)2 XtremIOInitiatorsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo)2 XtremIOLunMaps (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMaps)2 XtremIOPort (com.emc.storageos.xtremio.restapi.model.response.XtremIOPort)2 XtremIOPorts (com.emc.storageos.xtremio.restapi.model.response.XtremIOPorts)2 XtremIOPortsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOPortsInfo)2 XtremIOVolumes (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolumes)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2