use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method testTELspNlri.
@Test
public void testTELspNlri() throws BGPParsingException {
setUp(this.teLspNlri);
// test BA form
assertNull(this.dest.getDistinguisher());
assertEquals(ProtocolId.RsvpTe, this.dest.getProtocolId());
assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
final TeLspCase teCase = (TeLspCase) this.dest.getObjectType();
assertEquals(new LspId(1L), teCase.getLspId());
assertEquals(new TunnelId(1), teCase.getTunnelId());
assertEquals(new Ipv4Address("1.2.3.4"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelSenderAddress());
assertEquals(new Ipv4Address("4.3.2.1"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelEndpointAddress());
// test BI form
final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
protocolId.withNodeIdentifier(LinkstateNlriParser.PROTOCOL_ID_NID);
protocolId.withValue("rsvp-te");
linkstateBI.addChild(protocolId.build());
final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
identifier.withValue(BigInteger.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
final ImmutableLeafNodeBuilder<Long> lspId = new ImmutableLeafNodeBuilder<>();
lspId.withNodeIdentifier(AbstractTeLspNlriCodec.LSP_ID);
lspId.withValue(1L);
final ImmutableLeafNodeBuilder<Integer> tunnelId = new ImmutableLeafNodeBuilder<>();
tunnelId.withNodeIdentifier(AbstractTeLspNlriCodec.TUNNEL_ID);
tunnelId.withValue(1);
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> addressFamily = Builders.choiceBuilder();
addressFamily.withNodeIdentifier(AbstractTeLspNlriCodec.ADDRESS_FAMILY);
final ImmutableLeafNodeBuilder<String> ipv4TunnelSenderAddress = new ImmutableLeafNodeBuilder<>();
ipv4TunnelSenderAddress.withNodeIdentifier(AbstractTeLspNlriCodec.IPV4_TUNNEL_SENDER_ADDRESS);
ipv4TunnelSenderAddress.withValue("1.2.3.4");
final ImmutableLeafNodeBuilder<String> ipv4TunnelEndPointAddress = new ImmutableLeafNodeBuilder<>();
ipv4TunnelEndPointAddress.withNodeIdentifier(AbstractTeLspNlriCodec.IPV4_TUNNEL_ENDPOINT_ADDRESS);
ipv4TunnelEndPointAddress.withValue("4.3.2.1");
addressFamily.addChild(ipv4TunnelSenderAddress.build());
addressFamily.addChild(ipv4TunnelEndPointAddress.build());
objectType.addChild(lspId.build());
objectType.addChild(tunnelId.build());
objectType.addChild(addressFamily.build());
linkstateBI.addChild(objectType.build());
assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType in project bgpcep by opendaylight.
the class AbstractTeLspNlriCodec method serializeObjectType.
@Override
protected final void serializeObjectType(final ObjectType objectType, final ByteBuf buffer) {
Preconditions.checkArgument(objectType instanceof TeLspCase);
final TeLspCase teLSP = (TeLspCase) objectType;
final AddressFamily addressFamily = teLSP.getAddressFamily();
if (addressFamily instanceof Ipv4Case) {
serializeIpv4Case(teLSP, (Ipv4Case) addressFamily, buffer);
} else {
serializeIpv6Case(teLSP, (Ipv6Case) addressFamily, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType in project bgpcep by opendaylight.
the class SimpleNlriTypeRegistry method serializeNlriType.
public void serializeNlriType(final CLinkstateDestination nlri, final ByteBuf byteAggregator) {
if (nlri == null) {
return;
}
requireNonNull(byteAggregator);
final ObjectType objectType = nlri.getObjectType();
final NlriTypeCaseSerializer serializer = this.nlriRegistry.getSerializer((Class<? extends ObjectType>) objectType.getImplementedInterface());
if (serializer == null) {
LOG.warn("Linkstate NLRI serializer for Type: {} was not found.", objectType.getImplementedInterface());
return;
}
final ByteBuf nlriType = Unpooled.buffer();
serializer.serializeTypeNlri(nlri, nlriType);
TlvUtil.writeTLV(serializer.getNlriType(), nlriType, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method removeObject.
@Override
protected void removeObject(final ReadWriteTransaction trans, final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
if (value == null) {
LOG.error("Empty before-data received in delete data change notification for instance id {}", id);
return;
}
final UriBuilder base = new UriBuilder(value);
final ObjectType t = value.getObjectType();
if (t instanceof LinkCase) {
removeLink(trans, base, (LinkCase) t);
} else if (t instanceof NodeCase) {
removeNode(trans, base, (NodeCase) t);
} else if (t instanceof PrefixCase) {
removePrefix(trans, base, (PrefixCase) t);
} else {
LOG.debug(UNHANDLED_OBJECT_CLASS, t.getImplementedInterface());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createObject.
@Override
protected void createObject(final ReadWriteTransaction trans, final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
final UriBuilder base = new UriBuilder(value);
final ObjectType t = value.getObjectType();
Preconditions.checkArgument(t != null, "Route %s value %s has null object type", id, value);
if (t instanceof LinkCase) {
createLink(trans, base, value, (LinkCase) t, value.getAttributes());
} else if (t instanceof NodeCase) {
createNode(trans, base, value, (NodeCase) t, value.getAttributes());
} else if (t instanceof PrefixCase) {
createPrefix(trans, base, value, (PrefixCase) t, value.getAttributes());
} else {
LOG.debug(UNHANDLED_OBJECT_CLASS, t.getImplementedInterface());
}
}
Aggregations