Search in sources :

Example 11 with ApplicationAdminService

use of org.onosproject.app.ApplicationAdminService 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 12 with ApplicationAdminService

use of org.onosproject.app.ApplicationAdminService in project onos by opennetworkinglab.

the class ApplicationsWebResource method activateApp.

/**
 * Activate application.
 * Activates the specified application.
 *
 * @param name application name
 * @return 200 OK; 404; 401
 */
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("{name}/active")
public Response activateApp(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = nullIsNotFound(service.getId(name), APP_NOT_FOUND + ": " + name);
    service.activate(appId);
    return response(service, appId);
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 13 with ApplicationAdminService

use of org.onosproject.app.ApplicationAdminService in project onos by opennetworkinglab.

the class ApplicationsWebResource method uninstallApp.

/**
 * Uninstall application.
 * Uninstalls the specified application deactivating it first if necessary.
 *
 * @param name application name
 * @return 204 NO CONTENT
 */
@DELETE
@Path("{name}")
public Response uninstallApp(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = service.getId(name);
    if (appId != null) {
        service.uninstall(appId);
    }
    return Response.noContent().build();
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 14 with ApplicationAdminService

use of org.onosproject.app.ApplicationAdminService in project onos by opennetworkinglab.

the class ApplicationsWebResource method getAppBits.

/**
 * Get application OAR/JAR file.
 * Returns the OAR/JAR file used to install the specified application.
 *
 * @param name application name
 * @return 200 OK; 404; 401
 */
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Path("{name}/bits")
public Response getAppBits(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = nullIsNotFound(service.getId(name), APP_ID_NOT_FOUND + ": " + name);
    InputStream bits = service.getApplicationArchive(appId);
    return ok(bits).build();
}
Also used : InputStream(java.io.InputStream) ApplicationId(org.onosproject.core.ApplicationId) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ApplicationAdminService (org.onosproject.app.ApplicationAdminService)14 ApplicationId (org.onosproject.core.ApplicationId)11 Path (javax.ws.rs.Path)8 GET (javax.ws.rs.GET)6 Produces (javax.ws.rs.Produces)6 Application (org.onosproject.core.Application)6 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 URL (java.net.URL)3 POST (javax.ws.rs.POST)3 Consumes (javax.ws.rs.Consumes)2 DELETE (javax.ws.rs.DELETE)2 YangLiveCompilerService (org.onosproject.yang.YangLiveCompilerService)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ByteStreams (com.google.common.io.ByteStreams)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)1