Search in sources :

Example 1 with TrafficMatchId

use of org.onosproject.segmentrouting.policy.api.TrafficMatchId in project trellis-control by opennetworkinglab.

the class TrafficMatchAddCommand method doExecute.

@Override
protected void doExecute() {
    TrafficSelector trafficSelector = parseArguments();
    if (trafficSelector.equals(DefaultTrafficSelector.emptySelector())) {
        print("Empty traffic selector is not allowed");
        return;
    }
    TrafficMatchPriority trafficMatchPriority;
    try {
        trafficMatchPriority = new TrafficMatchPriority(priority);
    } catch (IllegalArgumentException ex) {
        print(ex.getMessage());
        return;
    }
    PolicyService policyService = AbstractShellCommand.get(PolicyService.class);
    TrafficMatchId trafficMatchId = policyService.addOrUpdateTrafficMatch(new TrafficMatch(trafficSelector, PolicyId.of(policyId), trafficMatchPriority));
    print("Traffic match %s has been submitted", trafficMatchId);
}
Also used : TrafficMatch(org.onosproject.segmentrouting.policy.api.TrafficMatch) PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficMatchPriority(org.onosproject.segmentrouting.policy.api.TrafficMatchPriority) TrafficMatchId(org.onosproject.segmentrouting.policy.api.TrafficMatchId)

Example 2 with TrafficMatchId

use of org.onosproject.segmentrouting.policy.api.TrafficMatchId in project trellis-control by opennetworkinglab.

the class PolicyManager method activate.

@Activate
public void activate() {
    appId = coreService.registerApplication(APP_NAME);
    codecService.registerCodec(DropPolicy.class, new DropPolicyCodec());
    codecService.registerCodec(RedirectPolicy.class, new RedirectPolicyCodec());
    codecService.registerCodec(TrafficMatch.class, new TrafficMatchCodec());
    cfgService.addListener(cfgListener);
    policies = storageService.<PolicyId, PolicyRequest>consistentMapBuilder().withName(POLICY_STORE).withSerializer(serializer).build();
    policies.addListener(mapPolListener);
    policiesMap = policies.asJavaMap();
    trafficMatches = storageService.<TrafficMatchId, TrafficMatchRequest>consistentMapBuilder().withName(TRAFFIC_MATCH_STORE).withSerializer(serializer).build();
    trafficMatches.addListener(mapTMatchListener);
    trafficMatchesMap = trafficMatches.asJavaMap();
    operations = storageService.<String, Operation>consistentMapBuilder().withName(OPS_STORE).withSerializer(serializer).build();
    operations.addListener(mapOpsListener);
    opsMap = operations.asJavaMap();
    policyLeaderCache = Maps.newConcurrentMap();
    workers = new PredictableExecutor(DEFAULT_THREADS, groupedThreads("sr-policy", "worker-%d", log));
    eventExecutor = Executors.newSingleThreadExecutor();
    log.info("Started");
}
Also used : PredictableExecutor(org.onlab.util.PredictableExecutor) TrafficMatchId(org.onosproject.segmentrouting.policy.api.TrafficMatchId) PolicyId(org.onosproject.segmentrouting.policy.api.PolicyId) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

TrafficMatchId (org.onosproject.segmentrouting.policy.api.TrafficMatchId)2 PredictableExecutor (org.onlab.util.PredictableExecutor)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 PolicyId (org.onosproject.segmentrouting.policy.api.PolicyId)1 PolicyService (org.onosproject.segmentrouting.policy.api.PolicyService)1 TrafficMatch (org.onosproject.segmentrouting.policy.api.TrafficMatch)1 TrafficMatchPriority (org.onosproject.segmentrouting.policy.api.TrafficMatchPriority)1 Activate (org.osgi.service.component.annotations.Activate)1