use of com.emc.vipr.model.sys.healthmonitor.NodeDiagnostics in project coprhd-controller by CoprHD.
the class DiagnosticsExecTest method testNodeDiagnostics.
@Test
public void testNodeDiagnostics() {
HealthMonitorService healthMonitorService = new HealthMonitorService();
DiagnosticsRestRep resp = healthMonitorService.getDiagnostics(null, "1", null);
Assert.assertNotNull(resp);
Assert.assertNotNull(resp.getNodeDiagnosticsList());
Set<String> testNames = new HashSet<String>();
for (NodeDiagnostics diag : resp.getNodeDiagnosticsList()) {
Assert.assertTrue(diag.getNodeId() != null && !diag.getNodeId().isEmpty());
Assert.assertTrue(diag.getIp() != null && !diag.getIp().isEmpty());
Assert.assertNotNull(diag.getDiagTests());
for (DiagTest test : diag.getDiagTests()) {
testNames.add(test.getName());
Assert.assertTrue(test.getStatus() != null && !test.getStatus().isEmpty());
if (test.getTestParams() != null) {
for (TestParam param : test.getTestParams()) {
Assert.assertTrue(param.getKey() != null && !param.getKey().isEmpty());
Assert.assertTrue(param.getValue() != null && !param.getValue().isEmpty());
}
}
}
Assert.assertTrue(testNames.containsAll(DIAG_TESTS));
}
}
use of com.emc.vipr.model.sys.healthmonitor.NodeDiagnostics 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;
}
Aggregations