Search in sources :

Example 1 with PolicyService

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

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

the class TrafficMatchListCommand method doExecute.

@Override
protected void doExecute() {
    PolicyService policyService = AbstractShellCommand.get(PolicyService.class);
    policyService.trafficMatches().forEach(this::printTrafficMatch);
}
Also used : PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService)

Example 3 with PolicyService

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

the class PolicyWebResource method deletePolicy.

/**
 * Delete a Policy by policyId.
 *
 * @param policyId Policy identifier
 * @return 204 NO CONTENT
 */
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("{policyId}")
public Response deletePolicy(@PathParam("policyId") String policyId) {
    PolicyService policyService = get(PolicyService.class);
    policyService.removePolicy(PolicyId.of(policyId));
    return Response.noContent().build();
}
Also used : PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 4 with PolicyService

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

the class PolicyWebResource method deleteTrafficMatch.

/**
 * Delete a Traffic Match by trafficMatchId.
 *
 * @param trafficMatchId Traffic Match identifier
 * @return 204 NO CONTENT
 */
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("trafficmatch/{trafficMatchId}")
public Response deleteTrafficMatch(@PathParam("trafficMatchId") String trafficMatchId) {
    PolicyService policyService = get(PolicyService.class);
    policyService.removeTrafficMatch(TrafficMatchId.of(trafficMatchId));
    return Response.noContent().build();
}
Also used : PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 5 with PolicyService

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

the class PolicyWebResource method createDropPolicy.

/**
 * Create a new Drop Policy.
 *
 * @return 200 OK and policyId
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("drop")
public Response createDropPolicy() {
    PolicyService policyService = get(PolicyService.class);
    ObjectNode root = mapper().createObjectNode();
    DropPolicy dropPolicy = new DropPolicy();
    policyService.addOrUpdatePolicy(dropPolicy);
    root.put(POLICY_ID, dropPolicy.policyId().toString());
    return Response.ok(root).build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) DropPolicy(org.onosproject.segmentrouting.policy.api.DropPolicy) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

PolicyService (org.onosproject.segmentrouting.policy.api.PolicyService)15 Produces (javax.ws.rs.Produces)9 Path (javax.ws.rs.Path)8 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)7 DropPolicy (org.onosproject.segmentrouting.policy.api.DropPolicy)5 RedirectPolicy (org.onosproject.segmentrouting.policy.api.RedirectPolicy)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 GET (javax.ws.rs.GET)4 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Policy (org.onosproject.segmentrouting.policy.api.Policy)3 PolicyType (org.onosproject.segmentrouting.policy.api.Policy.PolicyType)3 PolicyData (org.onosproject.segmentrouting.policy.api.PolicyData)3 TrafficMatch (org.onosproject.segmentrouting.policy.api.TrafficMatch)3 IOException (java.io.IOException)2 DELETE (javax.ws.rs.DELETE)2 PolicyId (org.onosproject.segmentrouting.policy.api.PolicyId)2 DeviceId (org.onosproject.net.DeviceId)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1