Search in sources :

Example 21 with ApplicationId

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

the class DistributedApplicationStore method activateExistingApplications.

/**
 * Activates applications that should be activated according to the distributed store.
 */
private void activateExistingApplications() {
    log.info("Going to activate existing applications");
    getApplicationNames().forEach(appName -> {
        // Only update the application version if the application has already been installed.
        ApplicationId appId = getId(appName);
        if (appId != null) {
            ApplicationDescription appDesc = getApplicationDescription(appName);
            InternalApplicationHolder appHolder = Versioned.valueOrNull(apps.get(appId));
            if (appHolder != null && appHolder.state == ACTIVATED) {
                log.debug("App name and version from local system : {}, {}", appDesc.name(), appDesc.version());
                log.debug("App name and version from app store : {}, {}", appHolder.app.id(), appHolder.app().version());
            }
            // If the application has already been activated, set the local state to active.
            if (appHolder != null && appDesc.version().equals(appHolder.app().version()) && appHolder.state == ACTIVATED) {
                log.info("Going to activate app : {}", appHolder.app.id());
                setActive(appName);
                updateTime(appName);
            }
        }
    });
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) ApplicationDescription(org.onosproject.app.ApplicationDescription)

Example 22 with ApplicationId

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

the class MeterRequestProtoTranslator method translate.

/**
 * Translates gRPC MeterRequest to {@link MeterRequest}.
 *
 * @param meterRequest gRPC message
 * @return {@link MeterRequest}
 */
public static MeterRequest translate(MeterRequestProtoOuterClass.MeterRequestProto meterRequest) {
    DeviceId deviceid = DeviceId.deviceId(meterRequest.getDeviceId());
    ApplicationId appId = ApplicationIdProtoTranslator.translate(meterRequest.getApplicationId());
    Meter.Unit unit = MeterEnumsProtoTranslator.translate(meterRequest.getUnit()).get();
    boolean burst = meterRequest.getIsBurst();
    Collection<Band> bands = BandProtoTranslator.translate(meterRequest.getBandsList());
    MeterRequest.Type type = (MeterRequest.Type) translate(meterRequest.getType()).get();
    if (type == MeterRequest.Type.ADD) {
        return DefaultMeterRequest.builder().forDevice(deviceid).fromApp(appId).withUnit(unit).withBands(bands).add();
    } else {
        return DefaultMeterRequest.builder().forDevice(deviceid).fromApp(appId).withUnit(unit).withBands(bands).remove();
    }
}
Also used : Meter(org.onosproject.net.meter.Meter) DeviceId(org.onosproject.net.DeviceId) Band(org.onosproject.net.meter.Band) MeterRequest(org.onosproject.net.meter.MeterRequest) DefaultMeterRequest(org.onosproject.net.meter.DefaultMeterRequest) ApplicationId(org.onosproject.core.ApplicationId)

Example 23 with ApplicationId

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

the class DistributedApplicationIdStore method registerApplication.

@Override
public ApplicationId registerApplication(String name) {
    ApplicationId exisitingAppId = registeredIds.asJavaMap().get(name);
    if (exisitingAppId == null) {
        ApplicationId newAppId = new DefaultApplicationId((int) appIdCounter.incrementAndGet(), name);
        exisitingAppId = registeredIds.asJavaMap().putIfAbsent(name, newAppId);
        return exisitingAppId == null ? newAppId : exisitingAppId;
    } else {
        return exisitingAppId;
    }
}
Also used : DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 24 with ApplicationId

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

the class MockCoreService method registerApplication.

@Override
public ApplicationId registerApplication(String name) {
    // Check if the app already exists
    ApplicationId appId = getAppId(name);
    if (appId == null) {
        appId = new DefaultApplicationId(nextAppId, name);
        nextAppId += 1;
        appIds.add(appId);
    }
    return appId;
}
Also used : DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 25 with ApplicationId

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

the class ImrWebResource method getMonitoredIntents.

/**
 * Get the list of monitored intents of a specific application.
 * Shows for each intent key the related end points (as inElements and OutElements).
 *
 * @onos.rsModel monitoredIntentsGet
 * @param id Application ID
 * @param name Application Name
 * @return 200 OK
 */
@GET
@Path("monitoredIntents/{id}/{name}")
@Produces(MediaType.APPLICATION_JSON)
public Response getMonitoredIntents(@PathParam("id") short id, @PathParam("name") String name) {
    imrService = get(IntentMonitorAndRerouteService.class);
    ApplicationId appId = new DefaultApplicationId(id, name);
    ArrayNode jsonMonitoredIntents = getJsonMonitoredIntents(imrService.getMonitoredIntents(appId));
    ObjectNode result = mapper.createObjectNode();
    result.putArray(ROOT_FIELD_MONITORED_INTENTS).addAll(jsonMonitoredIntents);
    return ok(result).build();
}
Also used : IntentMonitorAndRerouteService(org.onosproject.imr.IntentMonitorAndRerouteService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) 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