Search in sources :

Example 26 with ApplicationId

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

the class ImrWebResource method getJsonNodesIntentStats.

/**
 * Build the Json Nodes from the intent stats retrieved from {@link IntentMonitorAndRerouteService}.
 *
 * @param mapKeyToStats Intent statistics
 * @return {@link ArrayNode} built from the statistics
 */
private ArrayNode getJsonNodesIntentStats(Map<ApplicationId, Map<Key, List<FlowEntry>>> mapKeyToStats) {
    final ArrayNode rootArrayNode = mapper.createArrayNode();
    mapKeyToStats.forEach((appId, mapIntentKeyStats) -> {
        ObjectNode appObjNode = codec(ApplicationId.class).encode(appId, this);
        ArrayNode intentArrayNode = appObjNode.putArray("intents");
        mapIntentKeyStats.forEach((intentKey, lstStats) -> {
            ObjectNode intentKeyObjNode = mapper.createObjectNode();
            ArrayNode statsArrayNode = intentKeyObjNode.putArray(intentKey.toString());
            lstStats.forEach(stat -> {
                statsArrayNode.add(codec(FlowEntry.class).encode(stat, this));
            });
            intentArrayNode.add(intentKeyObjNode);
        });
        rootArrayNode.add(appObjNode);
    });
    return rootArrayNode;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId)

Example 27 with ApplicationId

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

the class IntentMonitorAndRerouteManager method applyPath.

@Override
public boolean applyPath(Route route) {
    checkNotNull(route, "Route to apply must be not null");
    checkNotNull(route.appId(), "Application id must be not null");
    checkNotNull(route.key(), "Intent key to apply must be not null");
    checkNotNull(route.paths(), "New path must be not null");
    checkArgument(route.paths().size() >= 1);
    ApplicationId appId = route.appId();
    Key key = route.key();
    // check if the app and the intent key are monitored
    if (!monitoredIntents.containsKey(appId)) {
        return false;
    }
    if (!monitoredIntents.get(appId).containsKey(key)) {
        return false;
    }
    // TODO: now we manage only the unsplittable routing
    Path currentPath = route.paths().stream().max(Comparator.comparing(Path::weight)).get();
    // in this case remove them from the list
    if (currentPath.path().get(0) instanceof HostId) {
        currentPath.path().remove(0);
    }
    if (currentPath.path().get(currentPath.path().size() - 1) instanceof HostId) {
        currentPath.path().remove(currentPath.path().size() - 1);
    }
    List<Link> links = createPathFromDeviceList(currentPath.path());
    // Generate the new Link collection intent, if not possible it will return the old intent
    ConnectivityIntent intent = generateLinkCollectionIntent(links, key, appId);
    storeMonitoredIntent(intent);
    intentService.submit(intent);
    return true;
}
Also used : Path(org.onosproject.imr.data.Path) ApplicationId(org.onosproject.core.ApplicationId) HostId(org.onosproject.net.HostId) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Key(org.onosproject.net.intent.Key) Link(org.onosproject.net.Link)

Example 28 with ApplicationId

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

the class DistributedK8sIpamStore method activate.

@Activate
protected void activate() {
    ApplicationId appId = coreService.registerApplication(APP_ID);
    allocatedStore = storageService.<String, K8sIpam>consistentMapBuilder().withSerializer(Serializer.using(SERIALIZER_K8S_IPAM)).withName("k8s-ipam-allocated-store").withApplicationId(appId).build();
    availableStore = storageService.<String, K8sIpam>consistentMapBuilder().withSerializer(Serializer.using(SERIALIZER_K8S_IPAM)).withName("k8s-ipam-available-store").withApplicationId(appId).build();
    log.info("Started");
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate)

Example 29 with ApplicationId

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

the class OpticalIntentsWebResource method deleteIntent.

/**
 * Delete the specified optical intent.
 *
 * @param appId application identifier
 * @param keyString   intent key
 * @return 204 NO CONTENT
 */
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("{appId}/{key}")
public Response deleteIntent(@PathParam("appId") String appId, @PathParam("key") String keyString) {
    final ApplicationId app = get(CoreService.class).getAppId(appId);
    nullIsNotFound(app, "Application Id not found");
    IntentService intentService = get(IntentService.class);
    Intent intent = intentService.getIntent(Key.of(keyString, app));
    if (intent == null) {
        intent = intentService.getIntent(Key.of(Long.decode(keyString), app));
    }
    nullIsNotFound(intent, "Intent Id is not found");
    if ((intent instanceof OpticalConnectivityIntent) || (intent instanceof OpticalCircuitIntent)) {
        intentService.withdraw(intent);
    } else {
        throw new IllegalArgumentException("Specified intent is not of type OpticalConnectivityIntent");
    }
    return Response.noContent().build();
}
Also used : IntentService(org.onosproject.net.intent.IntentService) CoreService(org.onosproject.core.CoreService) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) OpticalIntentUtility.createExplicitOpticalIntent(org.onosproject.net.optical.util.OpticalIntentUtility.createExplicitOpticalIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ApplicationId(org.onosproject.core.ApplicationId) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Path(javax.ws.rs.Path) DefaultPath(org.onosproject.net.DefaultPath) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes)

Example 30 with ApplicationId

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

the class PortLoadBalancerListCommand method doExecute.

@Override
public void doExecute() {
    PortLoadBalancerService service = get(PortLoadBalancerService.class);
    // Get port load balancers and reservations
    Map<PortLoadBalancerId, PortLoadBalancer> portLoadBalancerStore = service.getPortLoadBalancers();
    Map<PortLoadBalancerId, ApplicationId> portLoadBalancerResStore = service.getReservations();
    // Print id -> ports, mode, reservation
    portLoadBalancerStore.forEach((portLoadBalancerId, portLoadBalancer) -> print("%s -> %s, %s, %s", portLoadBalancerId, portLoadBalancer.ports(), portLoadBalancer.mode(), portLoadBalancerResStore.get(portLoadBalancerId) == null ? AVAILABLE : portLoadBalancerResStore.get(portLoadBalancerId).name()));
}
Also used : PortLoadBalancerService(org.onosproject.portloadbalancer.api.PortLoadBalancerService) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) ApplicationId(org.onosproject.core.ApplicationId) PortLoadBalancer(org.onosproject.portloadbalancer.api.PortLoadBalancer)

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