Search in sources :

Example 6 with ExecutionLog

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());
}
Also used : ExecutionLog(com.emc.storageos.db.client.model.uimodels.ExecutionLog) Date(java.util.Date) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 7 with ExecutionLog

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());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) ExecutionLog(com.emc.storageos.db.client.model.uimodels.ExecutionLog) ModelClient(com.emc.sa.model.dao.ModelClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Date(java.util.Date) Test(org.junit.Test) BaseModelTest(com.emc.sa.model.BaseModelTest)

Example 8 with ExecutionLog

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();
}
Also used : ExecutionLog(com.emc.storageos.db.client.model.uimodels.ExecutionLog) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 9 with ExecutionLog

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());
        }
    }
}
Also used : ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) ExecutionLog(com.emc.storageos.db.client.model.uimodels.ExecutionLog) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) ExecutionTaskLog(com.emc.storageos.db.client.model.uimodels.ExecutionTaskLog)

Aggregations

ExecutionLog (com.emc.storageos.db.client.model.uimodels.ExecutionLog)9 Date (java.util.Date)4 ExecutionState (com.emc.storageos.db.client.model.uimodels.ExecutionState)3 BaseModelTest (com.emc.sa.model.BaseModelTest)2 ExecutionTaskLog (com.emc.storageos.db.client.model.uimodels.ExecutionTaskLog)2 Order (com.emc.storageos.db.client.model.uimodels.Order)2 Test (org.junit.Test)2 ModelClient (com.emc.sa.model.dao.ModelClient)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 OrderLogList (com.emc.vipr.model.catalog.OrderLogList)1 OrderLogRestRep (com.emc.vipr.model.catalog.OrderLogRestRep)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1