use of org.onosproject.segmentrouting.policy.api.TrafficMatchPriority 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);
}
use of org.onosproject.segmentrouting.policy.api.TrafficMatchPriority 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.TrafficMatchPriority in project trellis-control by opennetworkinglab.
the class TrafficMatchCodecTest method setUp.
@Before
public void setUp() throws Exception {
context = new MockCodecContext();
codec = new TrafficMatchCodec();
trafficSelector = DefaultTrafficSelector.builder().matchIPProtocol((byte) 0x06).matchIPSrc(Ip4Address.valueOf("10.0.0.1").toIpPrefix()).matchIPDst(Ip4Address.valueOf("10.0.0.2").toIpPrefix()).matchTcpSrc(TpPort.tpPort(80)).matchTcpDst(TpPort.tpPort(81)).build();
policyId = PolicyId.of("DROP");
TrafficMatchPriority trafficMatchPriority = new TrafficMatchPriority(60000);
trafficMatch = new TrafficMatch(trafficSelector, policyId, trafficMatchPriority);
}
Aggregations