use of org.onosproject.segmentrouting.pwaas.L2TunnelPolicy in project trellis-control by opennetworkinglab.
the class PseudowireAddCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
L2Tunnel tun;
L2TunnelPolicy policy;
try {
tun = new DefaultL2Tunnel(parseMode(mode), parseVlan(sDTag), parsePwId(pwId), parsePWLabel(pwLabel));
} catch (IllegalArgumentException e) {
log.error("Exception while parsing L2Tunnel : \n\t %s", e.getMessage());
print("Exception while parsing L2Tunnel : \n\t %s", e.getMessage());
return;
}
try {
policy = new DefaultL2TunnelPolicy(parsePwId(pwId), ConnectPoint.deviceConnectPoint(cP1), parseVlan(cP1InnerVlan), parseVlan(cP1OuterVlan), ConnectPoint.deviceConnectPoint(cP2), parseVlan(cP2InnerVlan), parseVlan(cP2OuterVlan));
} catch (IllegalArgumentException e) {
log.error("Exception while parsing L2TunnelPolicy : \n\t %s", e.getMessage());
print("Exception while parsing L2TunnelPolicy : \n\t %s", e.getMessage());
return;
}
L2TunnelDescription pw = new DefaultL2TunnelDescription(tun, policy);
L2TunnelHandler.Result res = srService.addPseudowire(pw);
log.info("Deploying pseudowire {} via the command line.", pw);
switch(res) {
case WRONG_PARAMETERS:
print("Pseudowire could not be added , error in the parameters : \n\t%s", res.getSpecificError());
break;
case CONFIGURATION_ERROR:
print("Pseudowire could not be added, configuration error : \n\t%s", res.getSpecificError());
break;
case PATH_NOT_FOUND:
print("Pseudowire path not found : \n\t%s", res.getSpecificError());
break;
case INTERNAL_ERROR:
print("Pseudowire could not be added, internal error : \n\t%s", res.getSpecificError());
break;
case SUCCESS:
break;
default:
break;
}
}
use of org.onosproject.segmentrouting.pwaas.L2TunnelPolicy in project trellis-control by opennetworkinglab.
the class PseudowireWebResource method getPseudowire.
/**
* Get all pseudowires.
* Returns an array of pseudowires.
*
* @return status of OK
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPseudowire() {
SegmentRoutingService srService = get(SegmentRoutingService.class);
log.debug("Fetching pseudowires form rest api!");
List<L2TunnelPolicy> policies = srService.getL2Policies();
List<L2Tunnel> tunnels = srService.getL2Tunnels();
List<DefaultL2TunnelDescription> pseudowires = tunnels.stream().map(l2Tunnel -> {
L2TunnelPolicy policy = null;
for (L2TunnelPolicy l2Policy : policies) {
if (l2Policy.tunnelId() == l2Tunnel.tunnelId()) {
policy = l2Policy;
break;
}
}
// return a copy
return new DefaultL2TunnelDescription(l2Tunnel, policy);
}).collect(Collectors.toList());
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("pseudowires", new PseudowireCodec().encode(pseudowires, this));
return ok(result.toString()).build();
}
Aggregations