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