use of com.emc.storageos.db.client.model.uimodels.ExecutionLog in project coprhd-controller by CoprHD.
the class ExecutionLogTest method testPersistObject.
@Test
public void testPersistObject() throws Exception {
_logger.info("Starting persist ExecutionLog test");
ExecutionLog model = new ExecutionLog();
model.setId(URIUtil.createId(ExecutionLog.class));
model.setLabel("foo");
Date d = new Date();
model.setDate(d);
model.setLevel(LogLevel.WARN.name());
model.setMessage("my message");
model.setStackTrace("my stack trace");
model.setPhase(ExecutionPhase.ROLLBACK.name());
save(model);
model = findById(model.getId());
Assert.assertNotNull(model);
Assert.assertEquals("foo", model.getLabel());
Assert.assertEquals(d, model.getDate());
Assert.assertEquals(LogLevel.WARN.name(), model.getLevel());
Assert.assertEquals("my message", model.getMessage());
Assert.assertEquals("my stack trace", model.getStackTrace());
Assert.assertEquals(ExecutionPhase.ROLLBACK.name(), model.getPhase());
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionLog in project coprhd-controller by CoprHD.
the class OrderTest method testSaveOrderAndExecutionState.
@Test
public void testSaveOrderAndExecutionState() throws Exception {
_logger.info("Starting save Order and Execution State test");
ModelClient modelClient = getModelClient();
Order model = new Order();
model.setLabel("foo");
URI catalogServiceId = new URI("urn:CatalogService:1");
model.setCatalogServiceId(catalogServiceId);
Date d = new Date();
model.setDateCompleted(d);
model.setMessage("my message");
model.setOrderStatus(OrderStatus.CANCELLED.name());
model.setSubmittedByUserId("urn:User:1");
model.setSummary("my summary");
ExecutionState executionState = new ExecutionState();
executionState.setExecutionStatus(ExecutionStatus.NONE.name());
executionState.setStartDate(d);
executionState.setCurrentTask("my task");
modelClient.save(executionState);
model.setExecutionStateId(executionState.getId());
ExecutionLog executionLog1 = new ExecutionLog();
executionLog1.setLevel(LogLevel.DEBUG.name());
executionLog1.setMessage("my message 1");
modelClient.save(executionLog1);
executionState.addExecutionLog(executionLog1);
ExecutionLog executionLog2 = new ExecutionLog();
executionLog2.setLevel(LogLevel.ERROR.name());
executionLog2.setMessage("my message 2");
modelClient.save(executionLog2);
executionState.addExecutionLog(executionLog2);
modelClient.save(executionState);
save(model);
Order order = findById(model.getId());
Assert.assertNotNull(order);
Assert.assertEquals("foo", order.getLabel());
Assert.assertEquals(catalogServiceId, order.getCatalogServiceId());
Assert.assertEquals(d, order.getDateCompleted());
Assert.assertEquals(executionState.getId(), order.getExecutionStateId());
Assert.assertEquals("my message", order.getMessage());
Assert.assertEquals(OrderStatus.CANCELLED.name(), order.getOrderStatus());
Assert.assertEquals("urn:User:1", order.getSubmittedByUserId());
Assert.assertEquals("my summary", order.getSummary());
ExecutionState exeState = modelClient.executionStates().findById(order.getExecutionStateId());
Assert.assertNotNull(exeState);
Assert.assertEquals(ExecutionStatus.NONE.name(), exeState.getExecutionStatus());
Assert.assertEquals(d, exeState.getStartDate());
Assert.assertEquals(2, exeState.getLogIds().size());
List<ExecutionLog> logs = modelClient.executionLogs().findByIds(exeState.getLogIds());
Assert.assertNotNull(logs);
Assert.assertEquals(2, logs.size());
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionLog in project coprhd-controller by CoprHD.
the class ComputeUtils method getContextErrors.
public static String getContextErrors(ModelClient client) {
String sep = System.lineSeparator();
StringBuffer errBuff = new StringBuffer();
StringSet logIds = ExecutionUtils.currentContext().getExecutionState().getLogIds();
for (ExecutionLog l : client.executionLogs().findByIds(logIds)) {
if (l.getLevel().equals(LogLevel.ERROR.name())) {
errBuff.append(sep + sep + l.getMessage());
}
}
return errBuff.toString();
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionLog in project coprhd-controller by CoprHD.
the class OrderService method dumpOrder.
private void dumpOrder(PrintStream out, Order order) {
out.print(order.toString());
out.println("Parameters");
out.println("----------");
List<OrderParameter> parameters = orderManager.getOrderParameters(order.getId());
for (OrderParameter parameter : parameters) {
out.print(parameter.toString());
}
out.println("Execution State");
out.println("---------------");
ExecutionState state = orderManager.getOrderExecutionState(order.getExecutionStateId());
if (state != null) {
out.print(state.toString());
}
out.println("Logs");
out.println("----");
out.println(" Execution Logs");
if (state != null) {
List<ExecutionLog> elogs = orderManager.getOrderExecutionLogs(order);
for (ExecutionLog elog : elogs) {
out.print(elog.toString());
}
}
out.println(" Execution Task Logs");
if (state != null) {
List<ExecutionTaskLog> tlogs = orderManager.getOrderExecutionTaskLogs(order);
for (ExecutionTaskLog tlog : tlogs) {
out.print(tlog.toString());
}
}
}
Aggregations