daily pastebin goal
65%
SHARE
TWEET

odl-mdsal-examples

a guest Oct 2nd, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
  2. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
  3. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
  4. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
  5. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
  6.  
  7. public static final InstanceIdentifier<Nodes>    NODES_IID    =
  8.                            InstanceIdentifier.builder(Nodes.class).build();
  9. public static final InstanceIdentifier<Topology> TOPOLOGY_IID =
  10.                            InstanceIdentifier.builder(NetworkTopology.class)
  11.                            .child(Topology.class, new TopologyKey(new TopologyId("flow:1")))
  12.                            .build();
  13.  
  14. public static InstanceIdentifier<Node> nodeIId(NodeId nodeId) {
  15.     return NODES_IID.child(Node.class, new NodeKey(nodeId));
  16. }
  17.  
  18. public static InstanceIdentifier<Node> nodeIId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId nodeId) {
  19.     return NODES_IID.child(Node.class, new NodeKey(new NodeId(nodeId.getValue())));
  20. }
  21.  
  22. public static NodeRef nodeRef(NodeId nodeId) {
  23.     return new NodeRef(nodeIId(nodeId));
  24. }
  25.  
  26. public static InstanceIdentifier<NodeConnector> nodeConnectorIId(NodeId nodeId,
  27.                                                                  NodeConnectorId ncId) {
  28.     return NODES_IID.child(Node.class, new NodeKey(nodeId))
  29.                               .child(NodeConnector.class, new NodeConnectorKey(ncId));
  30. }
  31.  
  32. public static NodeConnectorRef nodeConnectorRef(NodeId nodeId, NodeConnectorId ncId) {
  33.     return new NodeConnectorRef(nodeConnectorIId(nodeId, ncId));
  34. }
  35.  
  36. public static Optional<Node> node(NodeId nodeId, DataBroker dataBroker) {
  37.     try {
  38.         return dataBroker.newReadOnlyTransaction()
  39.                   .read(LogicalDatastoreType.OPERATIONAL,
  40.                            nodeIId(nodeId)).get();
  41.     } catch (InterruptedException | ExecutionException e) {
  42.         return Optional.absent();
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top