Search in sources :

Example 11 with WorkflowException

use of org.onosproject.workflow.api.WorkflowException in project onos by opennetworkinglab.

the class WorkFlowTestCommand method invoke.

/**
 * Invokes workflow.
 *
 * @param workflowId    workflow id
 * @param workplaceName workplace name
 */
private void invoke(String workflowId, String workplaceName) {
    WorkflowService service = get(WorkflowService.class);
    ObjectNode dataModel = JsonNodeFactory.instance.objectNode();
    dataModel.put("count", 0);
    try {
        DefaultWorkflowDescription wfDesc = DefaultWorkflowDescription.builder().workplaceName(workplaceName).id(workflowId).data(dataModel).build();
        service.invokeWorkflow(wfDesc);
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException) DefaultWorkflowDescription(org.onosproject.workflow.api.DefaultWorkflowDescription)

Example 12 with WorkflowException

use of org.onosproject.workflow.api.WorkflowException in project onos by opennetworkinglab.

the class WorkflowStatusCommand method invoke.

private void invoke() {
    try {
        WorkflowStore workflowStore = get(WorkflowStore.class);
        WorkplaceStore workplaceStore = get(WorkplaceStore.class);
        System.out.printf("%-25s %-45s %-10s%n", "DEVICEIP", " WORKFLOW NAME", "WORKFLOW STATE");
        for (WorkflowContext context : workplaceStore.getContexts()) {
            for (Workflow workflow : workflowStore.getAll()) {
                if (context.workflowId().equals(workflow.id())) {
                    JsonDataModelTree tree = (JsonDataModelTree) context.data();
                    JsonNode mgmtIp = tree.nodeAt("/mgmtIp");
                    System.out.printf("%-25s %-45s %-10s%n", mgmtIp, context.name(), context.state().toString());
                }
            }
        }
    } catch (WorkflowException e) {
        e.printStackTrace();
    }
}
Also used : WorkflowStore(org.onosproject.workflow.api.WorkflowStore) WorkplaceStore(org.onosproject.workflow.api.WorkplaceStore) WorkflowContext(org.onosproject.workflow.api.WorkflowContext) WorkflowException(org.onosproject.workflow.api.WorkflowException) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) Workflow(org.onosproject.workflow.api.Workflow) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 13 with WorkflowException

use of org.onosproject.workflow.api.WorkflowException in project onos by opennetworkinglab.

the class WorkFlowEventMapCommand method doExecute.

@Override
protected void doExecute() {
    if (Objects.isNull(cmd)) {
        error("invalid cmd parameter");
        return;
    }
    ContextEventMapStore store = get(ContextEventMapStore.class);
    try {
        switch(cmd) {
            case PRINT:
                JsonNode tree = store.asJsonTree();
                ObjectMapper mapper = new ObjectMapper();
                try {
                    print(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tree));
                } catch (JsonProcessingException e) {
                    error("Exception: " + e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
                }
                break;
            default:
                print("Unsupported cmd: " + cmd);
        }
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : ContextEventMapStore(org.onosproject.workflow.api.ContextEventMapStore) WorkflowException(org.onosproject.workflow.api.WorkflowException) JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with WorkflowException

use of org.onosproject.workflow.api.WorkflowException in project onos by opennetworkinglab.

the class WorkplaceStoreCommand method addEmptyWorkplace.

/**
 * Adds empty workplace.
 * @param name workplace name
 */
private void addEmptyWorkplace(String name) {
    WorkflowService service = get(WorkflowService.class);
    try {
        DefaultWorkplaceDescription wpDesc = DefaultWorkplaceDescription.builder().name(name).build();
        service.createWorkplace(wpDesc);
    } catch (WorkflowException e) {
        error(e.getMessage() + ", trace: " + Arrays.asList(e.getStackTrace()));
    }
}
Also used : DefaultWorkplaceDescription(org.onosproject.workflow.api.DefaultWorkplaceDescription) WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException)

Example 15 with WorkflowException

use of org.onosproject.workflow.api.WorkflowException in project onos by opennetworkinglab.

the class WorkFlowCommand method invoke.

/**
 * Invokes workflow.
 * @param workflowId workflow id
 * @param workplaceName workplace name
 */
private void invoke(String workflowId, String workplaceName) {
    WorkflowService service = get(WorkflowService.class);
    try {
        DefaultWorkflowDescription wfDesc = DefaultWorkflowDescription.builder().workplaceName(workplaceName).id(workflowId).data(JsonNodeFactory.instance.objectNode()).build();
        service.invokeWorkflow(wfDesc);
    } catch (WorkflowException e) {
        error("Exception: ", e);
    }
}
Also used : WorkflowService(org.onosproject.workflow.api.WorkflowService) WorkflowException(org.onosproject.workflow.api.WorkflowException) DefaultWorkflowDescription(org.onosproject.workflow.api.DefaultWorkflowDescription)

Aggregations

WorkflowException (org.onosproject.workflow.api.WorkflowException)24 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 Workflow (org.onosproject.workflow.api.Workflow)9 WorkflowContext (org.onosproject.workflow.api.WorkflowContext)7 Worklet (org.onosproject.workflow.api.Worklet)7 ProgramCounter (org.onosproject.workflow.api.ProgramCounter)5 SystemWorkflowContext (org.onosproject.workflow.api.SystemWorkflowContext)5 WorkflowService (org.onosproject.workflow.api.WorkflowService)5 StorageException (org.onosproject.store.service.StorageException)4 NumericNode (com.fasterxml.jackson.databind.node.NumericNode)3 TextNode (com.fasterxml.jackson.databind.node.TextNode)3 ArrayList (java.util.ArrayList)3 IpAddress (org.onlab.packet.IpAddress)3 TpPort (org.onlab.packet.TpPort)3 WorkletDescription (org.onosproject.workflow.api.WorkletDescription)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 MissingNode (com.fasterxml.jackson.databind.node.MissingNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Annotation (java.lang.annotation.Annotation)2 Field (java.lang.reflect.Field)2