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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations