Search in sources :

Example 1 with TrafficMatchPriority

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);
}
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 TrafficMatchPriority

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);
}
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 3 with 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);
}
Also used : TrafficMatch(org.onosproject.segmentrouting.policy.api.TrafficMatch) MockCodecContext(org.onosproject.codec.impl.MockCodecContext) TrafficMatchPriority(org.onosproject.segmentrouting.policy.api.TrafficMatchPriority) Before(org.junit.Before)

Aggregations

TrafficMatch (org.onosproject.segmentrouting.policy.api.TrafficMatch)3 TrafficMatchPriority (org.onosproject.segmentrouting.policy.api.TrafficMatchPriority)3 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Before (org.junit.Before)1 MockCodecContext (org.onosproject.codec.impl.MockCodecContext)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 PolicyId (org.onosproject.segmentrouting.policy.api.PolicyId)1 PolicyService (org.onosproject.segmentrouting.policy.api.PolicyService)1 TrafficMatchId (org.onosproject.segmentrouting.policy.api.TrafficMatchId)1