Search in sources :

Example 56 with ApplicationId

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

the class ApplicationsWebResource method deactivateApp.

/**
 * De-activate application.
 * De-activates the specified application.
 *
 * @param name application name
 * @return 204 NO CONTENT
 */
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("{name}/active")
public Response deactivateApp(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = service.getId(name);
    if (appId != null) {
        service.deactivate(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) Produces(javax.ws.rs.Produces)

Example 57 with ApplicationId

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

the class ApplicationsWebResource method getApp.

/**
 * Get application details.
 * Returns details of the specified application.
 *
 * @param name application name
 * @return 200 OK; 404; 401
 * @onos.rsModel Application
 */
@GET
@Path("{name}")
public Response getApp(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = nullIsNotFound(service.getId(name), APP_NOT_FOUND + ":" + name);
    return response(service, appId);
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 58 with ApplicationId

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

the class ApplicationsWebResource method getAppIds.

/**
 * Gets a collection of application ids.
 * Returns array of all registered application ids.
 *
 * @return 200 OK; 404; 401
 * @onos.rsModel ApplicationIds
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("ids")
public Response getAppIds() {
    CoreService service = get(CoreService.class);
    Set<ApplicationId> appIds = service.getAppIds();
    return ok(encodeArray(ApplicationId.class, "applicationIds", appIds)).build();
}
Also used : CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 59 with ApplicationId

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

the class TopologyViewMessageHandler method findIntentByPayload.

private Intent findIntentByPayload(ObjectNode payload) {
    Intent intent;
    Key key;
    int appId = Integer.parseInt(string(payload, APP_ID));
    String appName = string(payload, APP_NAME);
    ApplicationId applicId = new DefaultApplicationId(appId, appName);
    String stringKey = string(payload, KEY);
    try {
        // FIXME: If apps use different string key, but they contains
        // same numeric value (e.g. "020", "0x10", "16", "#10")
        // and one intent using long key (e.g. 16L)
        // this function might return wrong intent.
        long longKey = Long.decode(stringKey);
        key = Key.of(longKey, applicId);
        intent = services.intent().getIntent(key);
        if (intent == null) {
            // Intent might using string key, not long key
            key = Key.of(stringKey, applicId);
            intent = services.intent().getIntent(key);
        }
    } catch (NumberFormatException ex) {
        // string key
        key = Key.of(stringKey, applicId);
        intent = services.intent().getIntent(key);
    }
    log.debug("Attempting to select intent by key={}", key);
    return intent;
}
Also used : HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectPoint.fromString(org.onosproject.net.ConnectPoint.fromString) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) Key(org.onosproject.net.intent.Key) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 60 with ApplicationId

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

the class ApplicationResource method download.

/**
 * 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}/download")
public Response download(@PathParam("name") String name) {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    ApplicationId appId = service.getId(name);
    InputStream bits = service.getApplicationArchive(appId);
    String fileName = appId.name() + ".oar";
    return Response.ok(bits).header("Content-Disposition", "attachment; filename=\"" + fileName + "\"").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

ApplicationId (org.onosproject.core.ApplicationId)138 CoreService (org.onosproject.core.CoreService)36 Activate (org.osgi.service.component.annotations.Activate)36 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)25 Path (javax.ws.rs.Path)21 Produces (javax.ws.rs.Produces)16 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)15 GET (javax.ws.rs.GET)14 Test (org.junit.Test)13 ApplicationAdminService (org.onosproject.app.ApplicationAdminService)11 FlowRuleService (org.onosproject.net.flow.FlowRuleService)11 TrafficSelector (org.onosproject.net.flow.TrafficSelector)11 Intent (org.onosproject.net.intent.Intent)11 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 InputStream (java.io.InputStream)9 DeviceId (org.onosproject.net.DeviceId)9 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 IntentService (org.onosproject.net.intent.IntentService)9 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8