Search in sources :

Example 6 with ObjectType

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()));
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) TeLspCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCase) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) TunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId) BigInteger(java.math.BigInteger) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) BigInteger(java.math.BigInteger) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) ImmutableLeafNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 7 with ObjectType

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);
    }
}
Also used : TeLspCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCase) AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.te.lsp._case.AddressFamily) Ipv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.te.lsp._case.address.family.Ipv4Case)

Example 8 with ObjectType

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);
}
Also used : ObjectType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType) NlriTypeCaseSerializer(org.opendaylight.protocol.bgp.linkstate.spi.NlriTypeCaseSerializer) ByteBuf(io.netty.buffer.ByteBuf)

Example 9 with ObjectType

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());
    }
}
Also used : ObjectType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType) NodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.NodeCase) PrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.PrefixCase) LinkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.LinkCase)

Example 10 with ObjectType

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());
    }
}
Also used : ObjectType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType) NodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.NodeCase) PrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.PrefixCase) LinkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.LinkCase)

Aggregations

ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)6 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)6 ByteBuf (io.netty.buffer.ByteBuf)4 BigInteger (java.math.BigInteger)4 Test (org.junit.Test)4 ObjectType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.ObjectType)4 LinkCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.LinkCase)4 NodeCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.NodeCase)4 PrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.PrefixCase)4 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)4 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)4 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)4 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)4 ImmutableLeafNodeBuilder (org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder)4 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 DomainIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier)3 TeLspCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCaseBuilder)3 LocalNodeDescriptors (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.LocalNodeDescriptors)3 RemoteNodeDescriptors (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.RemoteNodeDescriptors)3 IsisNodeCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.IsisNodeCaseBuilder)3