Search in sources :

Example 1 with XtremIOPort

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

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

the class XtremIOCommunicationInterface method discoverPorts.

private Map<String, List<StoragePort>> discoverPorts(XtremIOClient restClient, StorageSystem system) throws Exception {
    Map<String, List<StoragePort>> portMap = new HashMap<String, List<StoragePort>>();
    try {
        String clusterName = restClient.getClusterDetails(system.getSerialNumber()).getName();
        List<XtremIOPort> targetPorts = restClient.getXtremIOPortInfo(clusterName);
        Map<String, List<XtremIOPort>> storageControllerPortMap = new HashMap<String, List<XtremIOPort>>();
        for (XtremIOPort targetPort : targetPorts) {
            String scName = targetPort.getNodeInfo().get(1);
            List<XtremIOPort> scPorts = storageControllerPortMap.get(scName);
            if (scPorts == null) {
                scPorts = new ArrayList<XtremIOPort>();
                storageControllerPortMap.put(scName, scPorts);
            }
            scPorts.add(targetPort);
        }
        portMap.put(NEW, new ArrayList<StoragePort>());
        portMap.put(EXISTING, new ArrayList<StoragePort>());
        Long portSpeed = 0L;
        StoragePort port = null;
        for (String scName : storageControllerPortMap.keySet()) {
            List<XtremIOPort> scPorts = storageControllerPortMap.get(scName);
            StorageHADomain haDomain = createStorageHADomain(system, scName, scPorts.size());
            for (XtremIOPort targetPort : scPorts) {
                if (targetPort.getPortSpeed() != null) {
                    String portSpeedStr = targetPort.getPortSpeed().split("G")[0];
                    try {
                        portSpeed = Long.parseLong(portSpeedStr);
                    } catch (NumberFormatException nfe) {
                        portSpeed = 0L;
                    }
                }
                String nativeGuid = NativeGUIDGenerator.generateNativeGuid(system, targetPort.getPortAddress(), NativeGUIDGenerator.PORT);
                _logger.info("Speed, Target Port Native Guid {} {}", portSpeed, nativeGuid);
                @SuppressWarnings("deprecation") List<URI> uriList = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(nativeGuid));
                if (uriList.isEmpty()) {
                    _logger.info("Creating a Target Port {}", nativeGuid);
                    port = new StoragePort();
                    port.setId(URIUtil.createId(StoragePort.class));
                    port.setNativeGuid(nativeGuid);
                    port.setPortSpeed(portSpeed);
                    port.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
                    port.setPortType(PortType.frontend.toString());
                    if ("iscsi".equalsIgnoreCase(targetPort.getPortType().toLowerCase())) {
                        port.setTransportType(StoragePort.TransportType.IP.toString());
                        port.setPortNetworkId(targetPort.getPortAddress().toLowerCase());
                    } else {
                        port.setTransportType(targetPort.getPortType().toUpperCase());
                        // to make it uniform across other arrays
                        port.setPortNetworkId(targetPort.getPortAddress().toUpperCase());
                    }
                    port.setStorageDevice(system.getId());
                    port.setPortName(targetPort.getName());
                    port.setLabel(nativeGuid);
                    port.setOperationalStatus(getOperationalStatus(targetPort).toString());
                    port.setPortGroup(haDomain.getAdapterName());
                    port.setStorageHADomain(haDomain.getId());
                    port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    portMap.get(NEW).add(port);
                    _dbClient.createObject(port);
                } else {
                    _logger.info("Updating a Target Port {}", nativeGuid);
                    port = _dbClient.queryObject(StoragePort.class, uriList.get(0));
                    port.setPortSpeed(portSpeed);
                    port.setPortName(targetPort.getName());
                    port.setLabel(nativeGuid);
                    port.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
                    port.setOperationalStatus(getOperationalStatus(targetPort).toString());
                    // Prior to release-2.4, we only had one default StorageHADomain for XIO array.
                    // During re-discovery when new StorageHADomains are created, update that info on storage ports.
                    port.setPortGroup(haDomain.getAdapterName());
                    port.setStorageHADomain(haDomain.getId());
                    port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    portMap.get(EXISTING).add(port);
                    _dbClient.persistObject(port);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Discovering XtremIO target ports failed", e);
        throw e;
    }
    return portMap;
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) XtremIOPort(com.emc.storageos.xtremio.restapi.model.response.XtremIOPort) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ArrayList(java.util.ArrayList) List(java.util.List) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 3 with XtremIOPort

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

the class XtremIOV2Client method getXtremIOPortInfo.

@Override
public List<XtremIOPort> getXtremIOPortInfo(String clusterName) throws Exception {
    String uriString = XtremIOConstants.XTREMIO_V2_TARGETS_STR.concat(XtremIOConstants.getInputClusterString(clusterName));
    ClientResponse response = get(URI.create(uriString));
    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().concat(XtremIOConstants.getInputClusterString(clusterName))));
        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)

Aggregations

XtremIOPort (com.emc.storageos.xtremio.restapi.model.response.XtremIOPort)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)2 XtremIOPorts (com.emc.storageos.xtremio.restapi.model.response.XtremIOPorts)2 XtremIOPortsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOPortsInfo)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)1 HashMap (java.util.HashMap)1 List (java.util.List)1