Search in sources :

Example 1 with EvpnChoice

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.

the class SimpleEvpnNlriRegistryTest method registryTest.

@Test
public void registryTest() {
    final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE, Unpooled.wrappedBuffer(ROUDE_DISTIN));
    assertArrayEquals(EthADRParserTest.RESULT, ByteArray.getAllBytes(buff));
    final EvpnChoice resultModel = SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(createEthADRModel());
    assertEquals(ETHERNET_AD_ROUTE_CASE, resultModel);
    final NlriType type = NlriType.forValue(buff.readUnsignedByte());
    // length + RD
    buff.skipBytes(VALUE_SIZE);
    assertEquals(ETHERNET_AD_ROUTE_CASE, SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, buff));
}
Also used : EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice) NlriType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NlriType) ByteBuf(io.netty.buffer.ByteBuf) EthADRParserTest(org.opendaylight.protocol.bgp.evpn.impl.nlri.EthADRParserTest) Test(org.junit.Test)

Example 2 with EvpnChoice

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.

the class EvpnNlriParser method extractDestination.

private static EvpnDestination extractDestination(final DataContainerNode<? extends PathArgument> evpnChoice, final ExtractionInterface extract) {
    final EvpnRegistry reg = SimpleEvpnNlriRegistry.getInstance();
    final ChoiceNode cont = (ChoiceNode) evpnChoice.getChild(EVPN_CHOICE_NID).get();
    final EvpnChoice evpnValue = extract.check(reg, cont);
    if (evpnValue == null) {
        LOG.warn("Unrecognized Nlri {}", cont);
        return null;
    }
    return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(evpnChoice)).setEvpnChoice(evpnValue).build();
}
Also used : EvpnRegistry(org.opendaylight.protocol.bgp.evpn.spi.EvpnRegistry) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice) EvpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestinationBuilder)

Example 3 with EvpnChoice

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.

the class EthSegRParserTest method parser2Test.

@Test
public void parser2Test() {
    final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IPV6).build()).build();
    assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
    final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2));
    assertEquals(expected, result);
    final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
    choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID);
    final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createValueBuilder(IPV6_MODEL, ORI_NID).build()).build();
    final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC);
    assertEquals(expected, modelResult);
    final EvpnChoice keyResult = this.parser.createRouteKey(arbitraryC);
    assertEquals(expected, keyResult);
}
Also used : EsRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EsRouteCase) EsRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.es.route.EsRouteBuilder) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) EsRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EsRouteCaseBuilder) LanParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest) Test(org.junit.Test)

Example 4 with EvpnChoice

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.

the class EthADRParser method serializeEvpnModel.

@Override
public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
    final EthernetADRouteBuilder builder = serializeKeyModel(evpn);
    builder.setMplsLabel(extractMplsLabel(evpn, MPLS_NID));
    return new EthernetADRouteCaseBuilder().setEthernetADRoute(builder.build()).build();
}
Also used : EthernetADRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EthernetADRouteCaseBuilder) EthernetADRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.ethernet.a.d.route.EthernetADRouteBuilder)

Example 5 with EvpnChoice

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.

the class EvpnNlriParser method extractDestination.

private static EvpnDestination extractDestination(final DataContainerNode route, final ExtractionInterface extract) {
    final EvpnRegistry reg = SimpleEvpnNlriRegistry.getInstance();
    final ChoiceNode cont = (ChoiceNode) route.findChildByArg(EVPN_CHOICE_NID).get();
    final EvpnChoice evpnValue = extract.check(reg, cont);
    if (evpnValue == null) {
        LOG.warn("Unrecognized Nlri {}", cont);
        return null;
    }
    return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(route)).setPathId(PathIdUtil.buildPathId(route, PATH_ID_NID)).setEvpnChoice(evpnValue).build();
}
Also used : EvpnRegistry(org.opendaylight.protocol.bgp.evpn.spi.EvpnRegistry) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice) EvpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestinationBuilder)

Aggregations

Test (org.junit.Test)8 EvpnChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice)8 ByteBuf (io.netty.buffer.ByteBuf)7 LanParserTest (org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest)5 NlriModelUtil.extractMplsLabel (org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractMplsLabel)4 MplsLabelUtil.byteBufForMplsLabel (org.opendaylight.protocol.util.MplsLabelUtil.byteBufForMplsLabel)4 EsRouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.es.route.EsRouteBuilder)4 Esi (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi)4 EsRouteCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EsRouteCaseBuilder)4 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)4 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)3 EthernetTagId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.ethernet.tag.id.EthernetTagId)3 EthernetTagIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.ethernet.tag.id.EthernetTagIdBuilder)3 EsRouteCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EsRouteCase)3 MacIpAdvRouteCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCase)3 MacIpAdvRouteCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCaseBuilder)3 MacIpAdvRouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder)3 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)3 EvpnRegistry (org.opendaylight.protocol.bgp.evpn.spi.EvpnRegistry)2