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