Search in sources :

Example 16 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationsWebResource method getApps.

/**
 * Get all installed applications.
 * Returns array of all installed applications.
 *
 * @return 200 OK
 * @onos.rsModel Applications
 */
@GET
public Response getApps() {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    Set<Application> apps = service.getApplications();
    return ok(encodeArray(Application.class, "applications", apps)).build();
}
Also used : Application(org.onosproject.core.Application) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) GET(javax.ws.rs.GET)

Example 17 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationResource method getIcon.

@Path("{name}/icon")
@GET
@Produces("image/png")
public Response getIcon(@PathParam("name") String name) throws IOException {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = service.getId(name);
    Application app = service.getApplication(appId);
    return Response.ok(app.icon()).build();
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) Application(org.onosproject.core.Application) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationsWebResource method health.

/**
 * Get application health.
 *
 * @param name application name
 * @return 200 OK with app health in the body; 404 if app is not found
 */
@GET
@Path("{name}/health")
public Response health(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = service.getId(name);
    nullIsNotFound(appId, APP_ID_NOT_FOUND + ": " + name);
    Application app = service.getApplication(appId);
    nullIsNotFound(app, APP_NOT_FOUND + ": " + appId);
    ComponentsMonitorService componentsMonitorService = get(ComponentsMonitorService.class);
    boolean ready = componentsMonitorService.isFullyStarted(app.features());
    return Response.ok(mapper().createObjectNode().put("message", ready ? APP_READY : APP_PENDING)).build();
}
Also used : ComponentsMonitorService(org.onosproject.cluster.ComponentsMonitorService) ApplicationId(org.onosproject.core.ApplicationId) Application(org.onosproject.core.Application) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 19 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationsListCommand method doExecute.

@Override
protected void doExecute() {
    ApplicationService service = get(ApplicationService.class);
    List<Application> apps = newArrayList(service.getApplications());
    if (sortByName) {
        apps.sort(Comparator.comparing(app -> app.id().name()));
    } else {
        Collections.sort(apps, Comparators.APP_COMPARATOR);
    }
    if (outputJson()) {
        print("%s", json(service, apps));
    } else {
        for (Application app : apps) {
            boolean isActive = service.getState(app.id()) == ACTIVE;
            if (activeOnly && isActive || !activeOnly) {
                if (shortOnly) {
                    String shortDescription = app.title().equals(app.id().name()) ? app.description().replaceAll("[\\r\\n]", " ").replaceAll(" +", " ") : app.title();
                    print(SHORT_FMT, isActive ? "*" : " ", app.id().id(), app.id().name(), app.version(), shortDescription);
                } else {
                    print(FMT, isActive ? "*" : " ", app.id().id(), app.id().name(), app.version(), app.origin(), app.category(), app.description(), app.features(), app.featuresRepo().map(URI::toString).orElse(""), app.requiredApps(), app.permissions(), app.url());
                }
            }
        }
    }
}
Also used : Comparators(org.onosproject.utils.Comparators) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ApplicationService(org.onosproject.app.ApplicationService) Command(org.apache.karaf.shell.api.action.Command) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ACTIVE(org.onosproject.app.ApplicationState.ACTIVE) Service(org.apache.karaf.shell.api.action.lifecycle.Service) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) Comparator(java.util.Comparator) Option(org.apache.karaf.shell.api.action.Option) Collections(java.util.Collections) Application(org.onosproject.core.Application) Application(org.onosproject.core.Application) URI(java.net.URI) ApplicationService(org.onosproject.app.ApplicationService)

Example 20 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationsListCommand method json.

private JsonNode json(ApplicationService service, List<Application> apps) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    for (Application app : apps) {
        boolean isActive = service.getState(app.id()) == ACTIVE;
        if (activeOnly && isActive || !activeOnly) {
            result.add(jsonForEntity(app, Application.class));
        }
    }
    return result;
}
Also used : ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Application(org.onosproject.core.Application) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Application (org.onosproject.core.Application)32 DefaultApplication (org.onosproject.core.DefaultApplication)12 Test (org.junit.Test)8 List (java.util.List)6 ApplicationAdminService (org.onosproject.app.ApplicationAdminService)6 ApplicationEvent (org.onosproject.app.ApplicationEvent)6 ApplicationId (org.onosproject.core.ApplicationId)6 IOException (java.io.IOException)4 Lists (com.google.common.collect.Lists)3 InputStream (java.io.InputStream)3 Collectors (java.util.stream.Collectors)3 Service (org.apache.karaf.shell.api.action.lifecycle.Service)3 ApplicationService (org.onosproject.app.ApplicationService)3 ApplicationState (org.onosproject.app.ApplicationState)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 Charsets (com.google.common.base.Charsets)2 MoreObjects (com.google.common.base.MoreObjects)2 Preconditions (com.google.common.base.Preconditions)2 Throwables (com.google.common.base.Throwables)2