Search in sources :

Example 1 with XtremIOInitiators

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

the class XtremIOV1Client method getInitiator.

@Override
public XtremIOInitiator getInitiator(String initiatorName, String clusterName) throws Exception {
    try {
        String uriStr = XtremIOConstants.XTREMIO_INITIATORS_STR.concat(XtremIOConstants.getInputNameString(initiatorName));
        ClientResponse response = get(URI.create(uriStr));
        XtremIOInitiators initiators = getResponseObject(XtremIOInitiators.class, response);
        XtremIOInitiator initiator = initiators.getContent();
        log.info(initiator.toString());
        return initiator;
    } catch (Exception e) {
        if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
            throw e;
        } else {
            log.warn("Initiator {} not found on cluster {}", initiatorName, clusterName);
        }
    }
    log.info("Initiators not registered on Array with name : {}", initiatorName);
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiators(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Example 2 with XtremIOInitiators

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

the class XtremIOV2Client method getInitiator.

@Override
public XtremIOInitiator getInitiator(String initiatorName, String clusterName) throws Exception {
    try {
        String uriStr = XtremIOConstants.XTREMIO_V2_INITIATORS_STR.concat(XtremIOConstants.getInputNameForClusterString(initiatorName, clusterName));
        ClientResponse response = get(URI.create(uriStr));
        XtremIOInitiators initiators = getResponseObject(XtremIOInitiators.class, response);
        XtremIOInitiator initiator = initiators.getContent();
        log.info(initiator.toString());
        return initiator;
    } catch (Exception e) {
        if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
            throw e;
        } else {
            log.warn("Initiator {} not found on cluster {}", initiatorName, clusterName);
        }
    }
    log.info("Initiators not registered on Array with name : {}", initiatorName);
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiators(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Example 3 with XtremIOInitiators

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

the class XtremIOV1Client method getXtremIOInitiatorsInfo.

@Override
public List<XtremIOInitiator> getXtremIOInitiatorsInfo(String clusterName) throws Exception {
    ClientResponse response = get(XtremIOConstants.XTREMIO_INITIATORS_URI);
    XtremIOInitiatorsInfo initiatorPortLinks = getResponseObject(XtremIOInitiatorsInfo.class, response);
    log.info("Returned Initiator Links size : {}", initiatorPortLinks.getInitiators().length);
    List<XtremIOInitiator> initiatorPortList = new ArrayList<XtremIOInitiator>();
    for (XtremIOObjectInfo initiatorPortInfo : initiatorPortLinks.getInitiators()) {
        URI initiatorPortUri = URI.create(URIUtil.getFromPath(initiatorPortInfo.getHref()));
        try {
            response = get(initiatorPortUri);
            XtremIOInitiators initiatorPorts = getResponseObject(XtremIOInitiators.class, response);
            log.info("Initiator Port {}", initiatorPorts.getContent().getName() + "-" + initiatorPorts.getContent().getPortAddress());
            initiatorPortList.add(initiatorPorts.getContent());
        } catch (Exception e) {
            if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
                throw e;
            } else {
                log.warn("GET initiator - {} failed with obj_not_found. Initiator might be deleted from the system", initiatorPortUri.toString());
            }
        }
    }
    return initiatorPortList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiators(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) XtremIOInitiatorsInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Example 4 with XtremIOInitiators

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

the class XtremIOV2Client method getXtremIOInitiatorsInfo.

@Override
public List<XtremIOInitiator> getXtremIOInitiatorsInfo(String clusterName) throws Exception {
    String uriString = XtremIOConstants.XTREMIO_V2_INITIATORS_STR.concat(XtremIOConstants.getInputClusterString(clusterName));
    ClientResponse response = get(URI.create(uriString));
    XtremIOInitiatorsInfo initiatorPortLinks = getResponseObject(XtremIOInitiatorsInfo.class, response);
    log.info("Returned Initiator Links size : {}", initiatorPortLinks.getInitiators().length);
    List<XtremIOInitiator> initiatorPortList = new ArrayList<XtremIOInitiator>();
    for (XtremIOObjectInfo initiatorPortInfo : initiatorPortLinks.getInitiators()) {
        URI initiatorPortUri = URI.create(URIUtil.getFromPath(initiatorPortInfo.getHref().concat(XtremIOConstants.getInputClusterString(clusterName))));
        try {
            response = get(initiatorPortUri);
            XtremIOInitiators initiatorPorts = getResponseObject(XtremIOInitiators.class, response);
            log.info("Initiator Port {}", initiatorPorts.getContent().getName() + "-" + initiatorPorts.getContent().getPortAddress());
            initiatorPortList.add(initiatorPorts.getContent());
        } catch (Exception e) {
            if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
                throw e;
            } else {
                log.warn("GET initiator - {} failed with obj_not_found. Initiator might be deleted from the system", initiatorPortUri.toString());
            }
        }
    }
    return initiatorPortList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiators(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) XtremIOInitiatorsInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Aggregations

XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)4 XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)4 XtremIOInitiators (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 XtremIOInitiatorsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo)2 XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2