Search in sources :

Example 1 with PolicyId

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

the class TrafficMatchCodec method decode.

@Override
public TrafficMatch decode(ObjectNode json, CodecContext context) {
    final JsonCodec<TrafficSelector> selectorCodec = context.codec(TrafficSelector.class);
    ObjectNode selectorJson = nullIsIllegal(get(json, TRAFFIC_SELECTOR), TRAFFIC_SELECTOR + MISSING_MEMBER_MESSAGE);
    TrafficSelector trafficSelector = selectorCodec.decode(selectorJson, context);
    PolicyId policyId = PolicyId.of(nullIsIllegal(json.get(POLICY_ID), POLICY_ID + MISSING_MEMBER_MESSAGE).asText());
    int priority = nullIsIllegal(json.get(TRAFFIC_MATCH_PRIORITY), TRAFFIC_MATCH_PRIORITY + MISSING_MEMBER_MESSAGE).asInt();
    TrafficMatchPriority trafficMatchPriority;
    try {
        trafficMatchPriority = new TrafficMatchPriority(priority);
    } catch (IllegalArgumentException ex) {
        throw ex;
    }
    return new TrafficMatch(trafficSelector, policyId, trafficMatchPriority);
}
Also used : TrafficMatch(org.onosproject.segmentrouting.policy.api.TrafficMatch) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TrafficSelector(org.onosproject.net.flow.TrafficSelector) TrafficMatchPriority(org.onosproject.segmentrouting.policy.api.TrafficMatchPriority) PolicyId(org.onosproject.segmentrouting.policy.api.PolicyId)

Example 2 with PolicyId

use of org.onosproject.segmentrouting.policy.api.PolicyId 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)

Example 3 with PolicyId

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

the class PolicyDropAddCommand method doExecute.

@Override
protected void doExecute() {
    PolicyService policyService = AbstractShellCommand.get(PolicyService.class);
    PolicyId policyId = policyService.addOrUpdatePolicy(new DropPolicy());
    print("Policy %s has been submitted", policyId);
}
Also used : PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) DropPolicy(org.onosproject.segmentrouting.policy.api.DropPolicy) PolicyId(org.onosproject.segmentrouting.policy.api.PolicyId)

Example 4 with PolicyId

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

the class PolicyRedirectAddCommand method doExecute.

@Override
protected void doExecute() {
    Set<DeviceId> spinesToEnforce = spinesToEnforce();
    if (spinesToEnforce.isEmpty()) {
        print("Unable to submit redirect policy");
        return;
    }
    PolicyService policyService = AbstractShellCommand.get(PolicyService.class);
    PolicyId policyId = policyService.addOrUpdatePolicy(new RedirectPolicy(spinesToEnforce));
    print("Policy %s has been submitted", policyId);
}
Also used : RedirectPolicy(org.onosproject.segmentrouting.policy.api.RedirectPolicy) DeviceId(org.onosproject.net.DeviceId) PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) PolicyId(org.onosproject.segmentrouting.policy.api.PolicyId)

Aggregations

PolicyId (org.onosproject.segmentrouting.policy.api.PolicyId)4 PolicyService (org.onosproject.segmentrouting.policy.api.PolicyService)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 PredictableExecutor (org.onlab.util.PredictableExecutor)1 DeviceId (org.onosproject.net.DeviceId)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 DropPolicy (org.onosproject.segmentrouting.policy.api.DropPolicy)1 RedirectPolicy (org.onosproject.segmentrouting.policy.api.RedirectPolicy)1 TrafficMatch (org.onosproject.segmentrouting.policy.api.TrafficMatch)1 TrafficMatchId (org.onosproject.segmentrouting.policy.api.TrafficMatchId)1 TrafficMatchPriority (org.onosproject.segmentrouting.policy.api.TrafficMatchPriority)1 Activate (org.osgi.service.component.annotations.Activate)1