Search in sources :

Example 1 with IntentService

use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.

the class IntentKeyImrCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    // Fetch our service and feed it's offerings to the string completer
    IntentService service = AbstractShellCommand.get(IntentService.class);
    SortedSet<String> strings = delegate.getStrings();
    service.getIntents().forEach(intent -> {
        if (intent instanceof LinkCollectionIntent || intent instanceof PointToPointIntent) {
            strings.add(intent.key().toString());
        }
    });
    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
Also used : IntentService(org.onosproject.net.intent.IntentService) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent)

Example 2 with IntentService

use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.

the class StopMonitorCommand method doExecute.

@Override
protected void doExecute() {
    imrService = get(IntentMonitorAndRerouteService.class);
    intentService = get(IntentService.class);
    if (appId != null && appName != null) {
        if (key != null) {
            /*
                Intent key might be a StringKey or a LongKey, but in any case is
                provided via CLI as a string. To solve only ambiguity we check if
                "--longkey" CLI parameter has been set.
                 */
            if (treatAsLongKey) {
                try {
                    Key intentKeyLong = Key.of(Integer.decode(key), new DefaultApplicationId(appId, appName));
                    if (imrService.stopMonitorIntent(intentKeyLong)) {
                        print("Stopped monitoring of intent with LongKey %s", intentKeyLong);
                        return;
                    }
                } catch (NumberFormatException nfe) {
                    print("\"%s\" is not a valid LongKey", key);
                    return;
                }
            } else {
                Key intentKeyString = Key.of(key, new DefaultApplicationId(appId, appName));
                if (imrService.stopMonitorIntent(intentKeyString)) {
                    print("Stopped monitoring of intent with StringKey %s", intentKeyString);
                    return;
                }
            }
            // No intent found in IMR
            print("No monitored intent with key %s found", key);
        } else {
            intentService.getIntents().forEach(i -> {
                if (i.appId().equals(new DefaultApplicationId(appId, appName))) {
                    imrService.stopMonitorIntent(i.key());
                    print("Stopped monitoring of intent with key %s", i.key());
                }
            });
        }
    }
}
Also used : IntentService(org.onosproject.net.intent.IntentService) IntentMonitorAndRerouteService(org.onosproject.imr.IntentMonitorAndRerouteService) Key(org.onosproject.net.intent.Key) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 3 with IntentService

use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.

the class ApplicationNameImrCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    // Fetch our service and feed it's offerings to the string completer
    IntentService service = AbstractShellCommand.get(IntentService.class);
    SortedSet<String> strings = delegate.getStrings();
    service.getIntents().forEach(intent -> strings.add(intent.appId().name()));
    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
Also used : IntentService(org.onosproject.net.intent.IntentService) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter)

Example 4 with IntentService

use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.

the class AddOpticalIntentCommand method doExecute.

@Override
protected void doExecute() {
    IntentService service = get(IntentService.class);
    DeviceService deviceService = get(DeviceService.class);
    ConnectPoint ingress = createConnectPoint(ingressString);
    ConnectPoint egress = createConnectPoint(egressString);
    Intent intent = createOpticalIntent(ingress, egress, deviceService, key(), appId(), bidirectional, createOchSignal(), null);
    service.submit(intent);
    print("Optical intent submitted:\n%s", intent.toString());
}
Also used : IntentService(org.onosproject.net.intent.IntentService) DeviceService(org.onosproject.net.device.DeviceService) OpticalIntentUtility.createOpticalIntent(org.onosproject.net.optical.util.OpticalIntentUtility.createOpticalIntent) Intent(org.onosproject.net.intent.Intent) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 5 with IntentService

use of org.onosproject.net.intent.IntentService 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)

Aggregations

IntentService (org.onosproject.net.intent.IntentService)36 Intent (org.onosproject.net.intent.Intent)19 ApplicationId (org.onosproject.core.ApplicationId)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 CoreService (org.onosproject.core.CoreService)7 Key (org.onosproject.net.intent.Key)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)6 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)5 Link (org.onosproject.net.Link)5 TrafficSelector (org.onosproject.net.flow.TrafficSelector)5 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)5 Constraint (org.onosproject.net.intent.Constraint)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 Consumes (javax.ws.rs.Consumes)3