Interfacemgr: Refactoring and minor fixes
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / IfmUtil.java
diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java
new file mode 100644 (file)
index 0000000..af51d74
--- /dev/null
@@ -0,0 +1,20 @@
+package org.opendaylight.vpnservice.interfacemgr;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+public class IfmUtil { 
+
+    static String getDpnFromNodeConnectorId(NodeConnectorId portId) {
+        /*
+         * NodeConnectorId is of form 'openflow:dpnid:portnum'
+         */
+        String[] split = portId.getValue().split(IfmConstants.OF_URI_SEPARATOR);
+        return split[1];
+    }
+
+
+    static NodeId buildDpnNodeId(long dpnId) {
+        return new NodeId(IfmConstants.OF_URI_PREFIX + dpnId);
+    }
+}