Search in sources :

Example 6 with PolicyService

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

the class TrafficMatchRemoveCommand method doExecute.

@Override
protected void doExecute() {
    PolicyService policyService = AbstractShellCommand.get(PolicyService.class);
    trafficMatchId = trafficMatchId.replace("\\", "");
    if (policyService.removeTrafficMatch(TrafficMatchId.of(trafficMatchId))) {
        print("Removing traffic match %s", trafficMatchId);
    } else {
        print("Unable to remove traffic match %s", trafficMatchId);
    }
}
Also used : PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService)

Example 7 with PolicyService

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

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

the class PolicyListCommand method doExecute.

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

Example 9 with PolicyService

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

Example 10 with PolicyService

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

the class PolicyWebResource method getTrafficMatches.

/**
 * Get all Traffic Matches.
 *
 * @return 200 OK will a collection of Traffic Matches
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("trafficmatch")
public Response getTrafficMatches() {
    PolicyService policyService = get(PolicyService.class);
    ObjectNode root = mapper().createObjectNode();
    ArrayNode trafficMatchArr = root.putArray(TRAFFIC_MATCH);
    for (TrafficMatchData trafficMatchData : policyService.trafficMatches()) {
        TrafficMatch trafficMatch = trafficMatchData.trafficMatch();
        trafficMatchArr.add(codec(TrafficMatch.class).encode(trafficMatch, this));
    }
    return Response.ok(root).build();
}
Also used : TrafficMatchData(org.onosproject.segmentrouting.policy.api.TrafficMatchData) TrafficMatch(org.onosproject.segmentrouting.policy.api.TrafficMatch) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

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