On 08/24/2016 01:21 PM, Sela, Guy wrote:
> The only way it is working for me now, is the following (Some of it is
> pseudo-code):
> "
> PRODUCER CODE:
> I have a
> org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node
> in my hands (Got it from a DCN).
> This is the code I need to run in order to do what I'm trying:
> TopologyBuilder topologyBuilder = new TopologyBuilder();
> topologyBuilder.setKey(new TopologyKey(new TopologyId(new Uri("ovsdb:1"))));
> topologyBuilder.setNode(Collections.singletonList(node));
> NetworkTopologyBuilder ntBuilder = new NetworkTopologyBuilder();
> ntBuilder.setTopology(Collections.singletonList(topologyBuilder.build()));
> InstanceIdentifier path = InstanceIdentifier.create(NetworkTopology.class);
> String json = TTPUtils.jsonStringFromDataObject(path, ntBuilder.build(),
> true);
> Serialize the json...
>
> CONSUMER CODE:
> NormalizedNode normalizedNode =
> TTPUtils.normalizedNodeFromJsonString(jsonInput);
> DataObject obj = BindingNormalizedNodeCodecRegistry.
> fromNormalizedNode(YangInstanceIdentifier.of(BindingReflections.findQName(NetworkTopology.class)),
> normalizedNode);
> NetworkTopology nt = (NetworkTopology)obj;
> Node node = nt.getTopology().get(0).getNode().get(0);
> return node;
> "
>
> Is this what you guys meant by working with NormalizedNodes or is there a
> better way?Yes, pretty much. Since you mentioned getting the data from DCN -- you could use DOMDataBroker's DOMDataTreeChangeService extension to get the data in NormalizedNode format, skipping one conversion (and talking to JSON codec directly). Bye, Robert
signature.asc
Description: OpenPGP digital signature
_______________________________________________ controller-dev mailing list [email protected] https://lists.opendaylight.org/mailman/listinfo/controller-dev
