Search in sources :

Example 6 with NodeInfo

use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.

the class LogNetworkStreamMerger method getLogNetworkStreams.

private List<LogNetworkReader> getLogNetworkStreams() {
    List<NodeInfo> nodeInfo;
    List<LogNetworkReader> logNetworkStreams = new ArrayList<>();
    // Getting all nodes information
    if (request.getNodeIds().isEmpty()) {
        logger.info("No nodes specified, getting all nodes");
        nodeInfo = ClusterNodesUtil.getClusterNodeInfo();
    } else {
        nodeInfo = getClusterNodesWithIds(request.getNodeIds());
    }
    if (nodeInfo.isEmpty()) {
        throw APIException.internalServerErrors.noNodeAvailableError("collect logs info");
    }
    List<String> failedNodes = ClusterNodesUtil.getUnavailableControllerNodes();
    if (!request.getNodeIds().isEmpty()) {
        failedNodes.retainAll(request.getNodeIds());
    }
    if (!failedNodes.isEmpty()) {
        logger.error("Cannot collect logs from unavailable nodes: {}", failedNodes.toString());
    }
    for (final NodeInfo node : nodeInfo) {
        LogRequest req;
        SysClientFactory.SysClient sysClient;
        String baseNodeURL = String.format(SysClientFactory.BASE_URL_FORMAT, node.getIpAddress(), node.getPort());
        logger.debug("getting stream from node: " + baseNodeURL);
        logger.debug("connectTimeout=" + propertiesLoader.getNodeLogConnectionTimeout() * 1000);
        logger.debug("readTimeout=" + propertiesLoader.getNodeLogCollectorTimeout() * 1000);
        sysClient = SysClientFactory.getSysClient(URI.create(baseNodeURL), propertiesLoader.getNodeLogCollectorTimeout() * 1000, propertiesLoader.getNodeLogConnectionTimeout() * 1000);
        logger.debug("sysclient=" + sysClient + " uri=" + URI.create(baseNodeURL));
        try {
            req = request;
            req.setNodeIds(new ArrayList<String>() {

                {
                    add(node.getId());
                }
            });
            InputStream nodeResponseStream = sysClient.post(SysClientFactory.URI_NODE_LOGS, InputStream.class, req);
            if (nodeResponseStream != null && nodeResponseStream.available() > 0) {
                LogNetworkReader reader = new LogNetworkReader(node.getId(), node.getName(), nodeResponseStream, status);
                logNetworkStreams.add(reader);
            }
        } catch (Exception e) {
            logger.error("Exception accessing node {}:", baseNodeURL, e);
            // socketTimeoutException wrapped in ClientHandlerException
            if (e.getCause() != null && e.getCause().getCause() instanceof SocketTimeoutException) {
                throw InternalServerErrorException.internalServerErrors.logCollectionTimeout();
            }
        }
    }
    return logNetworkStreams;
}
Also used : LogNetworkReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) SysClientFactory(com.emc.storageos.systemservices.impl.client.SysClientFactory) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) SocketTimeoutException(java.net.SocketTimeoutException) CompressorException(org.apache.commons.compress.compressors.CompressorException) IOException(java.io.IOException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) SocketTimeoutException(java.net.SocketTimeoutException) NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo)

Example 7 with NodeInfo

use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.

the class NodeInfoTest method getPort.

/**
 * Tests the getPort method.
 */
@Test
public void getPort() {
    boolean wasException = false;
    try {
        NodeInfo nodeInfo = new NodeInfo(TEST_ID, TEST_NAME, TEST_ENDPOIT);
        Assert.assertEquals(nodeInfo.getPort(), Integer.parseInt(TEST_PORT));
    } catch (Exception e) {
        wasException = true;
    }
    Assert.assertFalse(wasException);
}
Also used : NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo) Test(org.junit.Test)

Example 8 with NodeInfo

use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.

the class NodeInfoTest method testGetId.

/**
 * Tests the getId method.
 */
@Test
public void testGetId() {
    boolean wasException = false;
    try {
        NodeInfo nodeInfo = new NodeInfo(TEST_ID, TEST_NAME, TEST_ENDPOIT);
        Assert.assertEquals(nodeInfo.getId(), TEST_ID);
    } catch (Exception e) {
        wasException = true;
    }
    Assert.assertFalse(wasException);
}
Also used : NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo) Test(org.junit.Test)

Example 9 with NodeInfo

use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.

the class HealthMonitorService method getDiagnostics.

/**
 * Get results of diagtool shell script for all virtual machines in a ViPR
 * controller appliance. Also gives test details when verbose option
 * is set.
 *
 * @brief Get diagtool script results
 * @param nodeIds node ids for which diagnostic results are collected.
 * @param nodeNames node names for which diagnostic results are collected.
 * @param verbose when set to "1"  will run command with -v option.
 * @prereq none
 * @return Returns diagnostic test results.
 */
@GET
@Path("/diagnostics")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public DiagnosticsRestRep getDiagnostics(@QueryParam("node_id") List<String> nodeIds, @QueryParam("verbose") String verbose, @QueryParam("node_name") List<String> nodeNames) {
    _log.info("Initiating diagnostics test for nodes");
    nodeIds = _coordinatorClientExt.combineNodeNamesWithNodeIds(nodeNames, nodeIds);
    boolean isVerbose = ("1".equals(verbose)) ? true : false;
    DiagRequestParams diagRequestParams = new DiagRequestParams(isVerbose);
    DiagnosticsRestRep diagnosticsRestRep = new DiagnosticsRestRep();
    List<NodeInfo> nodeInfoList = ClusterNodesUtil.getClusterNodeInfo(nodeIds);
    Map<String, NodeDiagnostics> nodesData = NodeDataCollector.getDataFromNodes(nodeInfoList, INTERNAL_NODE_DIAGNOSTICS_URI, Action.POST, diagRequestParams, NodeDiagnostics.class, null);
    String allocationResult = _checker.getNodeResourceAllocationCheckResult();
    DiagTest allocationTest = new DiagTest("Resource allocation", allocationResult, new ArrayList<TestParam>());
    for (Map.Entry<String, NodeDiagnostics> entry : nodesData.entrySet()) {
        List<DiagTest> diagTests = entry.getValue().getDiagTests();
        diagTests.add(allocationTest);
        entry.getValue().setDiagTests(diagTests);
    }
    diagnosticsRestRep.getNodeDiagnosticsList().addAll(nodesData.values());
    return diagnosticsRestRep;
}
Also used : TestParam(com.emc.vipr.model.sys.healthmonitor.TestParam) DiagRequestParams(com.emc.vipr.model.sys.healthmonitor.DiagRequestParams) DiagTest(com.emc.vipr.model.sys.healthmonitor.DiagTest) NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo) DiagnosticsRestRep(com.emc.vipr.model.sys.healthmonitor.DiagnosticsRestRep) NodeDiagnostics(com.emc.vipr.model.sys.healthmonitor.NodeDiagnostics) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 10 with NodeInfo

use of com.emc.storageos.systemservices.impl.resource.util.NodeInfo in project coprhd-controller by CoprHD.

the class HealthMonitorService method getHealth.

/**
 * Gets health of node and its services.
 * <p/>
 * Node health status: Good - when node is reachable and all its services are GOOD Unavailable - when node is not reachable Degraded -
 * when node is reachable and any of its service is Unavailable/Degraded Node/syssvc Unavailable - when node is down or syssvc is not
 * Unavailable on the node
 * <p/>
 * Service health status: Good - when a service is up and running Unavailable - when a service is not running but is registered in
 * coordinator Restarted - when service is restarting
 *
 * @brief Show service health of all virtual machines
 * @param nodeIds node ids for which health stats are collected.
 * @param nodeNames node names for which health stats are collected.
 * @prereq none
 * @return Health response.
 */
@GET
@Path("/health")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.SECURITY_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HealthRestRep getHealth(@QueryParam("node_id") List<String> nodeIds, @QueryParam("node_name") List<String> nodeNames) {
    HealthRestRep healthRestRep = new HealthRestRep();
    List<NodeHealth> nodehealthList = healthRestRep.getNodeHealthList();
    nodeIds = _coordinatorClientExt.combineNodeNamesWithNodeIds(nodeNames, nodeIds);
    // Collecting data from all nodes
    List<NodeInfo> nodeInfoList = ClusterNodesUtil.getClusterNodeInfo(nodeIds);
    Map<String, NodeHealth> nodesData = NodeDataCollector.getDataFromNodes(nodeInfoList, INTERNAL_NODE_HEALTH_URI, Action.GET, null, NodeHealth.class, null);
    nodehealthList.addAll(nodesData.values());
    String thisNodeId = _coordinatorClientExt.getMyNodeId();
    if (thisNodeId.equals("standalone")) {
        return healthRestRep;
    }
    Map<String, DualInetAddress> ipLookupTable = _coordinatorClientExt.getCoordinatorClient().getInetAddessLookupMap().getControllerNodeIPLookupMap();
    // get all nodes if the input param is empty
    if (nodeIds == null || nodeIds.isEmpty()) {
        int clusterNodeCount = _coordinatorClientExt.getNodeCount();
        nodeIds = new ArrayList<>();
        for (int i = 1; i <= clusterNodeCount; i++) {
            String nodeId = "vipr" + i;
            nodeIds.add(nodeId);
        }
    }
    // Adding health for nodes that are not returned
    for (String nodeId : nodeIds) {
        DualInetAddress ip = ipLookupTable.get(nodeId);
        if (!nodesData.containsKey(nodeId)) {
            String nodeName = _coordinatorClientExt.getPropertyInfo().getProperty("node_" + nodeId.replace("vipr", "") + "_name");
            nodehealthList.add(new NodeHealth(nodeId, nodeName, ip.toString(), Status.NODE_OR_SYSSVC_UNAVAILABLE.toString()));
        }
    }
    return healthRestRep;
}
Also used : NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo) HealthRestRep(com.emc.vipr.model.sys.healthmonitor.HealthRestRep) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

NodeInfo (com.emc.storageos.systemservices.impl.resource.util.NodeInfo)15 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)4 SysClientFactory (com.emc.storageos.systemservices.impl.client.SysClientFactory)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 DiagRequestParams (com.emc.vipr.model.sys.healthmonitor.DiagRequestParams)2 LogLevelRequest (com.emc.vipr.model.sys.logging.LogLevelRequest)2 LogRequest (com.emc.vipr.model.sys.logging.LogRequest)2 InputStream (java.io.InputStream)2 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)1 BackupException (com.emc.storageos.management.backup.exceptions.BackupException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 LogNetworkStreamMerger (com.emc.storageos.systemservices.impl.logsvc.merger.LogNetworkStreamMerger)1 LogNetworkReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader)1 DiagTest (com.emc.vipr.model.sys.healthmonitor.DiagTest)1 DiagnosticsRestRep (com.emc.vipr.model.sys.healthmonitor.DiagnosticsRestRep)1 HealthRestRep (com.emc.vipr.model.sys.healthmonitor.HealthRestRep)1 NodeDiagnostics (com.emc.vipr.model.sys.healthmonitor.NodeDiagnostics)1