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);
}
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");
}
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);
}
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);
}
Aggregations