Search in sources :

Example 1 with ServiceNotFoundException

use of org.onlab.osgi.ServiceNotFoundException in project onos by opennetworkinglab.

the class FlowObjectivePendingNextCommand method doExecute.

@Override
protected void doExecute() {
    try {
        FlowObjectiveService service = get(FlowObjectiveService.class);
        printNexts(service.getPendingFlowObjectives());
    } catch (ServiceNotFoundException e) {
        print(FORMAT_MAPPING, "FlowObjectiveService unavailable");
    }
}
Also used : ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService)

Example 2 with ServiceNotFoundException

use of org.onlab.osgi.ServiceNotFoundException in project onos by opennetworkinglab.

the class FlowObjectiveNextListCommand method doExecute.

@Override
protected void doExecute() {
    try {
        FlowObjectiveService service = get(FlowObjectiveService.class);
        printNexts(service.getNextMappings());
    } catch (ServiceNotFoundException e) {
        print(FORMAT_MAPPING, "FlowObjectiveService unavailable");
    }
}
Also used : ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService)

Example 3 with ServiceNotFoundException

use of org.onlab.osgi.ServiceNotFoundException in project onos by opennetworkinglab.

the class FlowObjectiveQueueClearCommand method doExecute.

@Override
protected void doExecute() {
    if (please == null || !please.equals(CONFIRM_PHRASE)) {
        print("WARNING: System may enter an unpredictable state if the flow obj queues are force emptied." + "Enter confirmation phrase to continue.");
        return;
    }
    try {
        FlowObjectiveService service = get(FlowObjectiveService.class);
        service.clearQueue();
    } catch (ServiceNotFoundException e) {
        print("FlowObjectiveService unavailable");
    }
}
Also used : ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService)

Example 4 with ServiceNotFoundException

use of org.onlab.osgi.ServiceNotFoundException in project onos by opennetworkinglab.

the class MainIndexResource method getMainIndex.

@GET
@Produces(MediaType.TEXT_HTML)
@Path("/index.html")
public Response getMainIndex() throws IOException {
    ClassLoader classLoader = getClass().getClassLoader();
    UiExtensionService service;
    UiTokenService tokens;
    try {
        service = get(UiExtensionService.class);
        tokens = get(UiTokenService.class);
    } catch (ServiceNotFoundException e) {
        return Response.ok(classLoader.getResourceAsStream(NOT_READY)).build();
    }
    InputStream indexTemplate = classLoader.getResourceAsStream(INDEX);
    String index = new String(toByteArray(indexTemplate));
    int p0s = split(index, 0, INJECT_USER_START) - INJECT_USER_START.length();
    int p0e = split(index, p0s, INJECT_USER_END);
    int p1s = split(index, p0e, INJECT_JS_START) - INJECT_JS_START.length();
    int p1e = split(index, p1s, INJECT_JS_END);
    int p2s = split(index, p1e, INJECT_CSS_START) - INJECT_CSS_START.length();
    int p2e = split(index, p2s, INJECT_CSS_END);
    int p3s = split(index, p2e, null);
    // FIXME: use global opaque auth token to allow secure failover
    // for now, just use the user principal name...
    String userName = ctx.getUserPrincipal().getName();
    // get a session token to use for UI-web-socket authentication
    UiSessionToken token = tokens.issueToken(userName);
    String auth = "var onosUser='" + userName + "',\n" + "    onosAuth='" + token + "';\n";
    StreamEnumeration streams = new StreamEnumeration(of(stream(index, 0, p0s), new ByteArrayInputStream(SCRIPT_START), stream(auth, 0, auth.length()), userPreferences(userName), userConsoleLog(userName), new ByteArrayInputStream(SCRIPT_END), stream(index, p0e, p1s), includeJs(service), stream(index, p1e, p2s), includeCss(service), stream(index, p2e, p3s)));
    return Response.ok(new SequenceInputStream(streams)).build();
}
Also used : SequenceInputStream(java.io.SequenceInputStream) UiTokenService(org.onosproject.ui.UiTokenService) ByteArrayInputStream(java.io.ByteArrayInputStream) ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException) SequenceInputStream(java.io.SequenceInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UiExtensionService(org.onosproject.ui.UiExtensionService) UiSessionToken(org.onosproject.ui.UiSessionToken) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with ServiceNotFoundException

use of org.onlab.osgi.ServiceNotFoundException in project onos by opennetworkinglab.

the class MainIndexResource method getMainIndex.

@GET
@Produces(MediaType.TEXT_HTML)
@Path("/index.html")
public Response getMainIndex() throws IOException {
    ClassLoader classLoader = getClass().getClassLoader();
    UiExtensionService service;
    UiTokenService tokens;
    try {
        service = get(UiExtensionService.class);
        tokens = get(UiTokenService.class);
    } catch (ServiceNotFoundException e) {
        return Response.ok(classLoader.getResourceAsStream(NOT_READY)).build();
    }
    InputStream indexTemplate = classLoader.getResourceAsStream(INDEX);
    String index = new String(toByteArray(indexTemplate));
    int p0s = split(index, 0, INJECT_USER_START) - INJECT_USER_START.length();
    int p0e = split(index, p0s, INJECT_USER_END);
    int p3s = split(index, p0e, null);
    // FIXME: use global opaque auth token to allow secure failover
    // for now, just use the user principal name...
    String userName = ctx.getUserPrincipal().getName();
    // get a session token to use for UI-web-socket authentication
    UiSessionToken token = tokens.issueToken(userName);
    String auth = "var onosUser='" + userName + "',\n" + "    onosAuth='" + token + "';\n";
    StreamEnumeration streams = new StreamEnumeration(of(stream(index, 0, p0s), new ByteArrayInputStream(SCRIPT_START), stream(auth, 0, auth.length()), userPreferences(userName), userConsoleLog(userName), new ByteArrayInputStream(SCRIPT_END), stream(index, p0e, p3s)));
    return Response.ok(new SequenceInputStream(streams)).build();
}
Also used : SequenceInputStream(java.io.SequenceInputStream) UiTokenService(org.onosproject.ui.UiTokenService) ByteArrayInputStream(java.io.ByteArrayInputStream) ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException) SequenceInputStream(java.io.SequenceInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UiExtensionService(org.onosproject.ui.UiExtensionService) UiSessionToken(org.onosproject.ui.UiSessionToken) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ServiceNotFoundException (org.onlab.osgi.ServiceNotFoundException)6 FlowObjectiveService (org.onosproject.net.flowobjective.FlowObjectiveService)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 SequenceInputStream (java.io.SequenceInputStream)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 UiExtensionService (org.onosproject.ui.UiExtensionService)2 UiSessionToken (org.onosproject.ui.UiSessionToken)2 UiTokenService (org.onosproject.ui.UiTokenService)2 FilteringObjQueueKey (org.onosproject.net.flowobjective.FilteringObjQueueKey)1 ForwardingObjQueueKey (org.onosproject.net.flowobjective.ForwardingObjQueueKey)1 NextObjQueueKey (org.onosproject.net.flowobjective.NextObjQueueKey)1 Objective (org.onosproject.net.flowobjective.Objective)1