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