Search in sources :

Example 1 with DefaultL2TunnelPolicy

use of org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy 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;
    }
}
Also used : SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) L2TunnelHandler(org.onosproject.segmentrouting.pwaas.L2TunnelHandler) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription)

Example 2 with DefaultL2TunnelPolicy

use of org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy in project trellis-control by opennetworkinglab.

the class PseudowireCodec method decode.

@Override
public DefaultL2TunnelDescription decode(ObjectNode json, CodecContext context) {
    Integer id = parsePwId(json.path(PW_ID).asText());
    ConnectPoint cP1, cP2;
    cP1 = ConnectPoint.deviceConnectPoint(json.path(CP1).asText());
    cP2 = ConnectPoint.deviceConnectPoint(json.path(CP2).asText());
    VlanId cP1InnerVlan, cP1OuterVlan, cP2InnerVlan, cP2OuterVlan, sdTag;
    cP1InnerVlan = parseVlan(json.path(CP1_INNER_TAG).asText());
    cP1OuterVlan = parseVlan(json.path(CP1_OUTER_TAG).asText());
    cP2InnerVlan = parseVlan(json.path(CP2_INNER_TAG).asText());
    cP2OuterVlan = parseVlan(json.path(CP2_OUTER_TAG).asText());
    sdTag = parseVlan(json.path(SERVICE_DELIM_TAG).asText());
    L2Mode mode = parseMode(json.path(MODE).asText());
    MplsLabel pwLabel = parsePWLabel(json.path(PW_LABEL).asText());
    DefaultL2Tunnel l2Tunnel = new DefaultL2Tunnel(mode, sdTag, id, pwLabel);
    DefaultL2TunnelPolicy l2Policy = new DefaultL2TunnelPolicy(id, cP1, cP1InnerVlan, cP1OuterVlan, cP2, cP2InnerVlan, cP2OuterVlan);
    return new DefaultL2TunnelDescription(l2Tunnel, l2Policy);
}
Also used : DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) MplsLabel(org.onlab.packet.MplsLabel) L2Mode(org.onosproject.segmentrouting.pwaas.L2Mode) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) VlanId(org.onlab.packet.VlanId)

Aggregations

DefaultL2Tunnel (org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel)2 DefaultL2TunnelDescription (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription)2 DefaultL2TunnelPolicy (org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy)2 MplsLabel (org.onlab.packet.MplsLabel)1 VlanId (org.onlab.packet.VlanId)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 SegmentRoutingService (org.onosproject.segmentrouting.SegmentRoutingService)1 L2Mode (org.onosproject.segmentrouting.pwaas.L2Mode)1 L2Tunnel (org.onosproject.segmentrouting.pwaas.L2Tunnel)1 L2TunnelDescription (org.onosproject.segmentrouting.pwaas.L2TunnelDescription)1 L2TunnelHandler (org.onosproject.segmentrouting.pwaas.L2TunnelHandler)1 L2TunnelPolicy (org.onosproject.segmentrouting.pwaas.L2TunnelPolicy)1