Search in sources :

Example 31 with ContainerNode

use of org.opendaylight.yangtools.yang.data.api.schema.ContainerNode in project bgpcep by opendaylight.

the class MacParserTest method parserTest.

@Test
public void parserTest() {
    final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
    final MacAutoGeneratedCase macAuto = new MacAutoGeneratedCaseBuilder().setMacAutoGenerated(new MacAutoGeneratedBuilder().setLocalDiscriminator(UINT24_LD).setSystemMacAddress(MAC).build()).build();
    this.parser.serializeEsi(macAuto, buff);
    assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
    final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
    assertEquals(macAuto, acResult);
    final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, SYSTEM_MAC_NID).build()).addChild(createValueBuilder(UINT24_LD_MODEL, LD_NID).build()).build();
    final Esi acmResult = this.parser.serializeEsi(cont);
    assertEquals(macAuto, acmResult);
}
Also used : MacAutoGeneratedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.esi.MacAutoGeneratedCaseBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) Esi(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.Esi) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) ByteBuf(io.netty.buffer.ByteBuf) MacAutoGeneratedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.esi.MacAutoGeneratedCase) MacAutoGeneratedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.esi.mac.auto.generated._case.MacAutoGeneratedBuilder) Test(org.junit.Test)

Example 32 with ContainerNode

use of org.opendaylight.yangtools.yang.data.api.schema.ContainerNode in project bgpcep by opendaylight.

the class SimpleEsiTypeRegistry method parseEsiModel.

@Override
public Esi parseEsiModel(final ChoiceNode esiChoice) {
    Preconditions.checkArgument(esiChoice != null && !esiChoice.getValue().isEmpty(), "ESI is mandatory. Can't be null or empty.");
    final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(esiChoice.getValue());
    final EsiSerializer serializer = this.modelHandlers.get(cont.getIdentifier());
    if (serializer != null) {
        return serializer.serializeEsi(cont);
    }
    LOG.warn("Unrecognized ESI {}", esiChoice);
    return null;
}
Also used : EsiSerializer(org.opendaylight.protocol.bgp.evpn.spi.EsiSerializer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)

Example 33 with ContainerNode

use of org.opendaylight.yangtools.yang.data.api.schema.ContainerNode in project bgpcep by opendaylight.

the class SimpleEvpnNlriRegistry method getEvpnCase.

private EvpnChoice getEvpnCase(final ChoiceNode evpnChoice, final SerializerInterface serializerInterface) {
    Preconditions.checkArgument(evpnChoice != null && !evpnChoice.getValue().isEmpty(), "Evpn case is mandatory. Can't be null or empty.");
    final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(evpnChoice.getValue());
    final EvpnSerializer serializer = this.modelHandlers.get(cont.getIdentifier());
    if (serializer == null) {
        return null;
    }
    return serializerInterface.check(serializer, cont);
}
Also used : EvpnSerializer(org.opendaylight.protocol.bgp.evpn.spi.EvpnSerializer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)

Example 34 with ContainerNode

use of org.opendaylight.yangtools.yang.data.api.schema.ContainerNode in project bgpcep by opendaylight.

the class ProtocolsConfigFileProcessor method loadConfiguration.

@Override
public synchronized void loadConfiguration(final NormalizedNode<?, ?> dto) {
    final ContainerNode protocolsContainer = (ContainerNode) dto;
    final MapNode protocolList = (MapNode) protocolsContainer.getChild(protocolYIId.getLastPathArgument()).get();
    final Collection<MapEntryNode> protocolsCollection = protocolList.getValue();
    final WriteTransaction wtx = this.dataBroker.newWriteOnlyTransaction();
    for (final MapEntryNode protocolEntry : protocolsCollection) {
        final Map.Entry<InstanceIdentifier<?>, DataObject> bi = this.bindingSerializer.fromNormalizedNode(this.protocolYIId, protocolEntry);
        if (bi != null) {
            final Protocol protocol = (Protocol) bi.getValue();
            processProtocol(protocol, wtx);
        }
    }
    try {
        wtx.submit().get();
    } catch (final ExecutionException | InterruptedException e) {
        LOG.warn("Failed to create Protocol", e);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Protocol(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map)

Example 35 with ContainerNode

use of org.opendaylight.yangtools.yang.data.api.schema.ContainerNode in project bgpcep by opendaylight.

the class NetworkTopologyConfigFileProcessor method loadConfiguration.

@Override
public synchronized void loadConfiguration(final NormalizedNode<?, ?> dto) {
    final ContainerNode networkTopologyContainer = (ContainerNode) dto;
    final MapNode topologyList = (MapNode) networkTopologyContainer.getChild(this.topologyYii.getLastPathArgument()).get();
    final Collection<MapEntryNode> networkTopology = topologyList.getValue();
    if (networkTopology.isEmpty()) {
        return;
    }
    final WriteTransaction wtx = this.dataBroker.newWriteOnlyTransaction();
    for (final MapEntryNode topologyEntry : networkTopology) {
        final Map.Entry<InstanceIdentifier<?>, DataObject> bi = this.bindingSerializer.fromNormalizedNode(this.topologyYii, topologyEntry);
        if (bi != null) {
            processTopology((Topology) bi.getValue(), wtx);
        }
    }
    try {
        wtx.submit().get();
    } catch (final ExecutionException | InterruptedException e) {
        LOG.warn("Failed to create Network Topologies", e);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map)

Aggregations

ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)81 Test (org.junit.Test)46 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)32 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)28 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)18 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)12 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)12 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)9 DefaultDOMRpcResult (org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult)8 ByteBuf (io.netty.buffer.ByteBuf)7 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)7 Map (java.util.Map)6 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)6 Collection (java.util.Collection)4 ExecutionException (java.util.concurrent.ExecutionException)4 ConcurrentDOMDataBroker (org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker)4 MergeModification (org.opendaylight.controller.cluster.datastore.modification.MergeModification)4 WriteModification (org.opendaylight.controller.cluster.datastore.modification.WriteModification)4 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)4 DOMRpcException (org.opendaylight.controller.md.sal.dom.api.DOMRpcException)4