public static OutputResult readFile(String path) throws IOException { OutputResult or = new OutputResult(); BufferedReader br = new BufferedReader( (new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); String line; while ((line = br.readLine()) != null) { or.add(line); } return or; }
@Override public ChassisStatusRespond sendTo(IPMIClient client) { OutputResult or; ChassisStatusRespond csr = new ChassisStatusRespond(); or = command.exeCmd(buildCommand(client)); if (or.isNotEmpty()) { for (String line : or) { Matcher matcher = errorP.matcher(line); if (matcher.find()) { csr.setSuccess(false); break; } matcher = selfTestP.matcher(line); if (matcher.find()) { csr.setSelftest(matcher.group(1)); continue; } matcher = chassisStatusP.matcher(line); if (matcher.find()) { csr.setPowerRestorePolicy(matcher.group(3)); csr.setChassisStatusOk(matcher.group(2).matches("on")); continue; } matcher = powerStateP.matcher(line); if (matcher.find()) { csr.setPowerOn(matcher.group(2).contains("working")); continue; } matcher = endP.matcher(line); if (matcher.find()) { csr.setSuccess(true); break; } matcher = versionP.matcher(line); if (matcher.find()) { csr.setVersion(matcher.group(1)); } } } else { csr.setSuccess(false); } return csr; }