use of com.emc.vipr.model.sys.healthmonitor.DiagRequestParams 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