1 package org.opendaylight.openflowplugin.learningswitch;
3 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
4 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
5 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 public class InstanceIdentifierUtils {
19 private InstanceIdentifierUtils() {
20 //hiding constructor for util class
24 * Creates an Instance Identifier (path) for node with specified id
29 public static final InstanceIdentifier<Node> createNodePath(final NodeId nodeId) {
30 return InstanceIdentifier.builder(Nodes.class)
31 .child(Node.class, new NodeKey(nodeId))
36 * Shorten's node child path to node path.
38 * @param nodeChild child of node, from which we want node path.
41 public static final InstanceIdentifier<Node> getNodePath(final InstanceIdentifier<?> nodeChild) {
42 return nodeChild.firstIdentifierOf(Node.class);
47 * Creates a table path by appending table specific location to node path
53 public static final InstanceIdentifier<Table> createTablePath(final InstanceIdentifier<Node> nodePath,final TableKey tableKey) {
54 return nodePath.augmentation(FlowCapableNode.class).child(Table.class, tableKey);
58 * Creates a path for particular flow, by appending flow-specific information
63 * @return path to flow
65 public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> tablePath, final FlowKey flowKey) {
66 return tablePath.child(Flow.class, flowKey);
70 * Extract table id from table path.
75 public static Short getTableId(final InstanceIdentifier<Table> tablePath) {
76 return tablePath.firstKeyOf(Table.class, TableKey.class).getId();
80 * Extracts NodeConnectorKey from node connector path.
83 public static NodeConnectorKey getNodeConnectorKey(final InstanceIdentifier<?> nodeConnectorPath) {
84 return nodeConnectorPath.firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
89 public static final InstanceIdentifier<NodeConnector> createNodeConnectorPath(final InstanceIdentifier<Node> nodeKey,final NodeConnectorKey nodeConnectorKey) {
90 return nodeKey.child(NodeConnector.class,nodeConnectorKey);