Fixed implementation of getNodeConnectorProps and getNodeProps 08/4008/2
authorEd Warnicke <eaw@cisco.com>
Fri, 3 Jan 2014 06:32:21 +0000 (22:32 -0800)
committerEd Warnicke <eaw@cisco.com>
Mon, 6 Jan 2014 12:40:55 +0000 (04:40 -0800)
Change-Id: If05e04129cf002ead7f07eafba66d07c1d66c4c5
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend

index 746d32ff1665a1ee638c5396d2b3f07b1ba28fe9..56ca1b609cf2c6eeb6d5dfe669b660319d4d792d 100644 (file)
@@ -64,6 +64,9 @@ import org.slf4j.LoggerFactory
 
 import static extension org.opendaylight.controller.sal.common.util.Arguments.*
 import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
 
 import static extension org.opendaylight.controller.sal.common.util.Arguments.*
 import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
+import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
+import java.util.concurrent.ConcurrentHashMap
+import java.util.Map
 
 class InventoryAndReadAdapter implements IPluginInReadService,
                                                                                         IPluginInInventoryService,
 
 class InventoryAndReadAdapter implements IPluginInReadService,
                                                                                         IPluginInInventoryService,
@@ -360,15 +363,64 @@ class InventoryAndReadAdapter implements IPluginInReadService,
     }
 
     override getNodeProps() {
     }
 
     override getNodeProps() {
-
-        // FIXME: Read from MD-SAL inventory service
-        return null;
+        val props = new ConcurrentHashMap<Node, Map<String, org.opendaylight.controller.sal.core.Property>>()
+        
+        val nodes = readAllMDNodes()
+        for (node : nodes.node ) {
+            val fcn = node.getAugmentation(FlowCapableNode)
+            if(fcn != null) {
+                val perNodeProps = fcn.toADNodeProperties(node.id)
+                val perNodePropMap = new ConcurrentHashMap<String, org.opendaylight.controller.sal.core.Property>
+                if(perNodeProps != null ) {
+                    for(perNodeProp : perNodeProps) {
+                        perNodePropMap.put(perNodeProp.name,perNodeProp)
+                    }
+                }
+                props.put(new Node(MD_SAL_TYPE, node.id.toADNodeId),perNodePropMap)
+            }
+        }
+        return props;
+    }
+    
+    private def readAllMDNodes() {
+        val nodesRef = InstanceIdentifier.builder(Nodes)
+            .toInstance
+        val reader = TypeSafeDataReader.forReader(dataService)
+        return reader.readOperationalData(nodesRef)
+    }
+    
+    private def readAllMDNodeConnectors(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node) {
+        val nodeRef = InstanceIdentifier.builder(Nodes)
+            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node,new NodeKey(node.id))
+            .toInstance
+        val reader = TypeSafeDataReader.forReader(dataService)
+        return reader.readOperationalData(nodeRef).nodeConnector
     }
 
     override getNodeConnectorProps(Boolean refresh) {
     }
 
     override getNodeConnectorProps(Boolean refresh) {
-
-        // FIXME: Read from MD-SAL Invcentory Service
-        return null;
+        // Note, because the MD-SAL has a unified data store, we can ignore the Boolean refresh, as we have no secondary 
+        // data store to refresh from
+        val props = new ConcurrentHashMap<org.opendaylight.controller.sal.core.NodeConnector, Map<String, org.opendaylight.controller.sal.core.Property>>()
+        val nodes = readAllMDNodes()
+        for (node : nodes.node) {
+            val ncs = node.readAllMDNodeConnectors
+            if(ncs != null) {
+                for( nc : ncs ) {
+                    val fcnc = nc.getAugmentation(FlowCapableNodeConnector)
+                    if(fcnc != null) {
+                        val ncps = fcnc.toADNodeConnectorProperties
+                        val ncpsm = new ConcurrentHashMap<String, org.opendaylight.controller.sal.core.Property>
+                        if(ncps != null) {
+                            for(p : ncps) {
+                                ncpsm.put(p.name,p)
+                            }
+                        }  
+                        props.put(nc.id.toADNodeConnector(node.id),ncpsm)
+                    }
+                }
+            }
+        }
+        return props
     }
 
     private def FlowCapableNode readFlowCapableNode(NodeRef ref) {
     }
 
     private def FlowCapableNode readFlowCapableNode(NodeRef ref) {
index f77cfcd67d52ec419df2ce2021995945ac74799c..4ad91c26779dcdfdb451200636c958ca3d4ae027 100644 (file)
@@ -46,22 +46,28 @@ import org.opendaylight.controller.sal.core.Capabilities
 import org.opendaylight.controller.sal.core.MacAddress
 import java.util.Date
 import org.opendaylight.controller.sal.core.TimeStamp
 import org.opendaylight.controller.sal.core.MacAddress
 import java.util.Date
 import org.opendaylight.controller.sal.core.TimeStamp
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode
 
 public class NodeMapping {
 
     public static val MD_SAL_TYPE = "MD_SAL";
     private static val NODE_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 public class NodeMapping {
 
     public static val MD_SAL_TYPE = "MD_SAL";
     private static val NODE_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-    private static val NODECONNECTOR_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-
+    private static val NODECONNECTOR_CLASS = org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.
+        NodeConnector;
 
     private new() {
         throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
     }
 
     public static def toADNode(InstanceIdentifier<?> node) throws ConstructionException {
 
     private new() {
         throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
     }
 
     public static def toADNode(InstanceIdentifier<?> node) throws ConstructionException {
-        return new Node(MD_SAL_TYPE, node.toNodeId.toADNodeId);
+        return node.toNodeId.toADNode
     }
     }
-    
+
+    public static def toADNode(NodeId id) {
+        return new Node(MD_SAL_TYPE, id.toADNodeId);
+    }
+
     public static def toNodeId(InstanceIdentifier<?> node) {
         checkNotNull(node);
         checkNotNull(node.getPath());
     public static def toNodeId(InstanceIdentifier<?> node) {
         checkNotNull(node);
         checkNotNull(node.getPath());
@@ -71,55 +77,60 @@ public class NodeMapping {
         val nodeKey = item.getKey().checkInstanceOf(NodeKey);
         return nodeKey.id
     }
         val nodeKey = item.getKey().checkInstanceOf(NodeKey);
         return nodeKey.id
     }
-    
+
     public static def toADNodeId(NodeId nodeId) {
         checkNotNull(nodeId);
         return nodeId.value
     }
 
     public static def toADNodeId(NodeId nodeId) {
         checkNotNull(nodeId);
         return nodeId.value
     }
 
-
     public static def toADNodeConnector(NodeConnectorRef source) throws ConstructionException {
         checkNotNull(source);
         val InstanceIdentifier<?> path = checkNotNull(source.getValue());
     public static def toADNodeConnector(NodeConnectorRef source) throws ConstructionException {
         checkNotNull(source);
         val InstanceIdentifier<?> path = checkNotNull(source.getValue());
-        val node = path.toADNode();
         checkArgument(path.path.size() >= 3);
         val arg = path.getPath().get(2);
         val item = arg.checkInstanceOf(IdentifiableItem);
         val connectorKey = item.getKey().checkInstanceOf(NodeConnectorKey);
         checkArgument(path.path.size() >= 3);
         val arg = path.getPath().get(2);
         val item = arg.checkInstanceOf(IdentifiableItem);
         val connectorKey = item.getKey().checkInstanceOf(NodeConnectorKey);
-        return new NodeConnector(connectorKey.id.toNodeConnectorType(path.toNodeId), connectorKey.id.toADNodeConnectorId(path.toNodeId), node);
+        return connectorKey.id.toADNodeConnector(path.toNodeId)
     }
     
     }
     
-    public static def toNodeConnectorType(NodeConnectorId ncId,NodeId nodeId) {
+    public static def toADNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId ncid,
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId nid) {
+            return new NodeConnector(ncid.toNodeConnectorType(nid),
+            ncid.toADNodeConnectorId(nid), nid.toADNode);
+     }
+
+    public static def toNodeConnectorType(NodeConnectorId ncId, NodeId nodeId) {
         if (ncId.equals(nodeId.toLocalNodeConnectorId)) {
             return NodeConnector.NodeConnectorIDType.SWSTACK
         } else if (ncId.equals(nodeId.toNormalNodeConnectorId)) {
             return NodeConnector.NodeConnectorIDType.HWPATH
         if (ncId.equals(nodeId.toLocalNodeConnectorId)) {
             return NodeConnector.NodeConnectorIDType.SWSTACK
         } else if (ncId.equals(nodeId.toNormalNodeConnectorId)) {
             return NodeConnector.NodeConnectorIDType.HWPATH
-        } else if (ncId.equals(nodeId.toControllerNodeConnectorId)){
+        } else if (ncId.equals(nodeId.toControllerNodeConnectorId)) {
             return NodeConnector.NodeConnectorIDType.CONTROLLER
         }
         return MD_SAL_TYPE
     }
             return NodeConnector.NodeConnectorIDType.CONTROLLER
         }
         return MD_SAL_TYPE
     }
-    
-    public static def toADNodeConnectorId(NodeConnectorId nodeConnectorId,NodeId nodeId) {
-        if(nodeConnectorId.equals(nodeId.toLocalNodeConnectorId) ||
-            nodeConnectorId.equals(nodeId.toNormalNodeConnectorId) || 
-            nodeConnectorId.equals(nodeId.toControllerNodeConnectorId)
-        ) {
+
+    public static def toADNodeConnectorId(NodeConnectorId nodeConnectorId, NodeId nodeId) {
+        if (nodeConnectorId.equals(nodeId.toLocalNodeConnectorId) ||
+            nodeConnectorId.equals(nodeId.toNormalNodeConnectorId) ||
+            nodeConnectorId.equals(nodeId.toControllerNodeConnectorId)) {
             return NodeConnector.SPECIALNODECONNECTORID
         }
         return nodeConnectorId.value
     }
             return NodeConnector.SPECIALNODECONNECTORID
         }
         return nodeConnectorId.value
     }
-    
-    public static def  toControllerNodeConnectorId(NodeId node) {
+
+    public static def toControllerNodeConnectorId(NodeId node) {
         return new NodeConnectorId(node.value + ":" + 4294967293L)
     }
         return new NodeConnectorId(node.value + ":" + 4294967293L)
     }
-    public static def  toLocalNodeConnectorId(NodeId node) {
+
+    public static def toLocalNodeConnectorId(NodeId node) {
         return new NodeConnectorId(node.value + ":" + 4294967294L)
     }
         return new NodeConnectorId(node.value + ":" + 4294967294L)
     }
-    public static def  toNormalNodeConnectorId(NodeId node) {
+
+    public static def toNormalNodeConnectorId(NodeId node) {
         return new NodeConnectorId(node.value + ":" + 4294967290L)
     }
         return new NodeConnectorId(node.value + ":" + 4294967290L)
     }
-    
+
     public static def toNodeRef(Node node) {
         checkArgument(MD_SAL_TYPE.equals(node.getType()));
         var nodeId = node.ID.checkInstanceOf(String)
     public static def toNodeRef(Node node) {
         checkArgument(MD_SAL_TYPE.equals(node.getType()));
         var nodeId = node.ID.checkInstanceOf(String)
@@ -127,21 +138,21 @@ public class NodeMapping {
         val nodePath = InstanceIdentifier.builder().node(Nodes).child(NODE_CLASS, nodeKey).toInstance();
         return new NodeRef(nodePath);
     }
         val nodePath = InstanceIdentifier.builder().node(Nodes).child(NODE_CLASS, nodeKey).toInstance();
         return new NodeRef(nodePath);
     }
-    
+
     public static def toNodeConnectorRef(NodeConnector nodeConnector) {
         val node = nodeConnector.node.toNodeRef();
         val nodePath = node.getValue() as InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
         var NodeConnectorId nodeConnectorId
     public static def toNodeConnectorRef(NodeConnector nodeConnector) {
         val node = nodeConnector.node.toNodeRef();
         val nodePath = node.getValue() as InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
         var NodeConnectorId nodeConnectorId
-        if(nodeConnector.ID.equals(NodeConnector.SPECIALNODECONNECTORID)){
-            if(nodeConnector.type.equals(NodeConnector.NodeConnectorIDType.SWSTACK)) {
+        if (nodeConnector.ID.equals(NodeConnector.SPECIALNODECONNECTORID)) {
+            if (nodeConnector.type.equals(NodeConnector.NodeConnectorIDType.SWSTACK)) {
                 nodeConnectorId = nodePath.toNodeId.toLocalNodeConnectorId
             } else if (nodeConnector.type.equals(NodeConnector.NodeConnectorIDType.HWPATH)) {
                 nodeConnectorId = nodePath.toNodeId.toNormalNodeConnectorId
             } else if (nodeConnector.type.equals(NodeConnector.NodeConnectorIDType.CONTROLLER)) {
                 nodeConnectorId = nodePath.toNodeId.toControllerNodeConnectorId
                 nodeConnectorId = nodePath.toNodeId.toLocalNodeConnectorId
             } else if (nodeConnector.type.equals(NodeConnector.NodeConnectorIDType.HWPATH)) {
                 nodeConnectorId = nodePath.toNodeId.toNormalNodeConnectorId
             } else if (nodeConnector.type.equals(NodeConnector.NodeConnectorIDType.CONTROLLER)) {
                 nodeConnectorId = nodePath.toNodeId.toControllerNodeConnectorId
-            }            
+            }
         } else {
         } else {
-            nodeConnectorId = new NodeConnectorId(nodeConnector.ID.checkInstanceOf(String))       
+            nodeConnectorId = new NodeConnectorId(nodeConnector.ID.checkInstanceOf(String))
         }
         val connectorKey = new NodeConnectorKey(nodeConnectorId);
         val path = InstanceIdentifier.builder(nodePath).child(NODECONNECTOR_CLASS, connectorKey).toInstance();
         }
         val connectorKey = new NodeConnectorKey(nodeConnectorId);
         val path = InstanceIdentifier.builder(nodePath).child(NODECONNECTOR_CLASS, connectorKey).toInstance();
@@ -151,152 +162,167 @@ public class NodeMapping {
     public static def toADNode(NodeRef node) throws ConstructionException {
         return toADNode(node.getValue());
     }
     public static def toADNode(NodeRef node) throws ConstructionException {
         return toADNode(node.getValue());
     }
-    
+
     public static def toADNodeConnectorProperties(NodeConnectorUpdated nc) {
     public static def toADNodeConnectorProperties(NodeConnectorUpdated nc) {
-        val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
         val fcncu = nc.getAugmentation(FlowCapableNodeConnectorUpdated)
         val fcncu = nc.getAugmentation(FlowCapableNodeConnectorUpdated)
-        if(fcncu != null) {
-            if(fcncu.currentFeature != null && fcncu.currentFeature.toAdBandwidth != null) {
+        if (fcncu != null) {
+            return fcncu.toADNodeConnectorProperties
+        }
+        return new HashSet<org.opendaylight.controller.sal.core.Property>();
+    }
+
+    public static def toADNodeConnectorProperties(FlowNodeConnector fcncu) {
+        val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
+        if (fcncu != null) {
+            if (fcncu.currentFeature != null && fcncu.currentFeature.toAdBandwidth != null) {
                 props.add(fcncu.currentFeature.toAdBandwidth)
             }
                 props.add(fcncu.currentFeature.toAdBandwidth)
             }
-            if(fcncu.advertisedFeatures != null && fcncu.advertisedFeatures.toAdAdvertizedBandwidth != null) {
+            if (fcncu.advertisedFeatures != null && fcncu.advertisedFeatures.toAdAdvertizedBandwidth != null) {
                 props.add(fcncu.advertisedFeatures.toAdAdvertizedBandwidth)
             }
                 props.add(fcncu.advertisedFeatures.toAdAdvertizedBandwidth)
             }
-            if(fcncu.supported != null && fcncu.supported.toAdSupportedBandwidth != null) {
+            if (fcncu.supported != null && fcncu.supported.toAdSupportedBandwidth != null) {
                 props.add(fcncu.supported.toAdSupportedBandwidth)
             }
                 props.add(fcncu.supported.toAdSupportedBandwidth)
             }
-            if(fcncu.peerFeatures != null && fcncu.peerFeatures.toAdPeerBandwidth != null) {
+            if (fcncu.peerFeatures != null && fcncu.peerFeatures.toAdPeerBandwidth != null) {
                 props.add(fcncu.peerFeatures.toAdPeerBandwidth)
             }
                 props.add(fcncu.peerFeatures.toAdPeerBandwidth)
             }
-            if(fcncu.name != null && fcncu.name.toAdName != null) {
+            if (fcncu.name != null && fcncu.name.toAdName != null) {
                 props.add(fcncu.name.toAdName)
             }
                 props.add(fcncu.name.toAdName)
             }
-            if(fcncu.configuration != null && fcncu.configuration.toAdConfig != null) {
+            if (fcncu.configuration != null && fcncu.configuration.toAdConfig != null) {
                 props.add(fcncu.configuration.toAdConfig)
             }
                 props.add(fcncu.configuration.toAdConfig)
             }
-            if(fcncu.state != null && fcncu.state.toAdState != null) {
+            if (fcncu.state != null && fcncu.state.toAdState != null) {
                 props.add(fcncu.state.toAdState)
             }
         }
         return props
     }
                 props.add(fcncu.state.toAdState)
             }
         }
         return props
     }
-    
+
     public static def toAdName(String name) {
         return new Name(name)
     public static def toAdName(String name) {
         return new Name(name)
-    } 
-    
+    }
+
     public static def toAdConfig(PortConfig pc) {
         var Config config;
     public static def toAdConfig(PortConfig pc) {
         var Config config;
-        if(pc.PORTDOWN){
+        if (pc.PORTDOWN) {
             config = new Config(Config.ADMIN_DOWN)
         } else {
             config = new Config(Config.ADMIN_UP)
         }
         return config
     }
             config = new Config(Config.ADMIN_DOWN)
         } else {
             config = new Config(Config.ADMIN_UP)
         }
         return config
     }
-    
+
     public static def toAdState(State s) {
         var org.opendaylight.controller.sal.core.State state
     public static def toAdState(State s) {
         var org.opendaylight.controller.sal.core.State state
-        if(s.linkDown) {
+        if (s.linkDown) {
             state = new org.opendaylight.controller.sal.core.State(org.opendaylight.controller.sal.core.State.EDGE_DOWN)
         } else {
             state = new org.opendaylight.controller.sal.core.State(org.opendaylight.controller.sal.core.State.EDGE_UP)
         }
         return state
     }
             state = new org.opendaylight.controller.sal.core.State(org.opendaylight.controller.sal.core.State.EDGE_DOWN)
         } else {
             state = new org.opendaylight.controller.sal.core.State(org.opendaylight.controller.sal.core.State.EDGE_UP)
         }
         return state
     }
-    
+
     public static def toAdBandwidth(PortFeatures pf) {
         var Bandwidth bw = null
     public static def toAdBandwidth(PortFeatures pf) {
         var Bandwidth bw = null
-        if (pf.is_10mbHd || pf.is_10mbFd ) {
-            bw= new Bandwidth(Bandwidth.BW10Mbps)
-        } else if (pf.is_100mbHd || pf.is_100mbFd ) {
-            bw= new Bandwidth(Bandwidth.BW100Mbps)
-        } else if (pf.is_1gbHd || pf.is_1gbFd ) {
-            bw= new Bandwidth(Bandwidth.BW1Gbps)
-        } else if (pf.is_1gbFd ) {
-            bw= new Bandwidth(Bandwidth.BW10Gbps)
-        } else if ( pf.is_10gbFd ) {
-            bw= new Bandwidth(Bandwidth.BW10Gbps)
-        } else if ( pf.is_40gbFd ) {
-            bw= new Bandwidth(Bandwidth.BW40Gbps)
-        } else if ( pf.is_100gbFd ) {
-            bw= new Bandwidth(Bandwidth.BW100Gbps)
-        } else if ( pf.is_1tbFd ) {
-            bw= new Bandwidth(Bandwidth.BW1Tbps)
-        } 
+        if (pf.is_10mbHd || pf.is_10mbFd) {
+            bw = new Bandwidth(Bandwidth.BW10Mbps)
+        } else if (pf.is_100mbHd || pf.is_100mbFd) {
+            bw = new Bandwidth(Bandwidth.BW100Mbps)
+        } else if (pf.is_1gbHd || pf.is_1gbFd) {
+            bw = new Bandwidth(Bandwidth.BW1Gbps)
+        } else if (pf.is_1gbFd) {
+            bw = new Bandwidth(Bandwidth.BW10Gbps)
+        } else if (pf.is_10gbFd) {
+            bw = new Bandwidth(Bandwidth.BW10Gbps)
+        } else if (pf.is_40gbFd) {
+            bw = new Bandwidth(Bandwidth.BW40Gbps)
+        } else if (pf.is_100gbFd) {
+            bw = new Bandwidth(Bandwidth.BW100Gbps)
+        } else if (pf.is_1tbFd) {
+            bw = new Bandwidth(Bandwidth.BW1Tbps)
+        }
         return bw;
     }
         return bw;
     }
-    
+
     public static def toAdAdvertizedBandwidth(PortFeatures pf) {
         var AdvertisedBandwidth abw
         val bw = pf.toAdBandwidth
     public static def toAdAdvertizedBandwidth(PortFeatures pf) {
         var AdvertisedBandwidth abw
         val bw = pf.toAdBandwidth
-        if(bw != null) {
+        if (bw != null) {
             abw = new AdvertisedBandwidth(bw.value)
         }
         return abw
     }
             abw = new AdvertisedBandwidth(bw.value)
         }
         return abw
     }
-    
+
     public static def toAdSupportedBandwidth(PortFeatures pf) {
         var SupportedBandwidth sbw
         val bw = pf.toAdBandwidth
     public static def toAdSupportedBandwidth(PortFeatures pf) {
         var SupportedBandwidth sbw
         val bw = pf.toAdBandwidth
-        if(bw != null ) {
+        if (bw != null) {
             sbw = new SupportedBandwidth(bw.value)
         }
         return sbw
     }
             sbw = new SupportedBandwidth(bw.value)
         }
         return sbw
     }
-    
+
     public static def toAdPeerBandwidth(PortFeatures pf) {
         var PeerBandwidth pbw
         val bw = pf.toAdBandwidth
     public static def toAdPeerBandwidth(PortFeatures pf) {
         var PeerBandwidth pbw
         val bw = pf.toAdBandwidth
-        if(bw != null) {
+        if (bw != null) {
             pbw = new PeerBandwidth(bw.value)
         }
         return pbw
     }
             pbw = new PeerBandwidth(bw.value)
         }
         return pbw
     }
-    
+
     public static def toADNodeProperties(NodeUpdated nu) {
     public static def toADNodeProperties(NodeUpdated nu) {
+        val fcnu = nu.getAugmentation(FlowCapableNodeUpdated)
+        if (fcnu != null) {
+            return fcnu.toADNodeProperties(nu.id)
+        }
+        return new HashSet<org.opendaylight.controller.sal.core.Property>();
+
+    }
+
+    public static def toADNodeProperties(FlowNode fcnu, NodeId id) {
         val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
         val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
-        val fcnu = nu.getAugmentation(FlowCapableNodeUpdated) 
-        if(fcnu != null) {
-             props.add(toADTimestamp)
-             // props.add(fcnu.supportedActions.toADActions) - TODO
-             if(nu.id != null) {
-                props.add(nu.id.toADMacAddress)
-             }
-             if(fcnu.switchFeatures != null) {
-                 if(fcnu.switchFeatures.maxTables != null) {
-                    props.add(fcnu.switchFeatures.maxTables.toADTables) 
-                 }
-                 if(fcnu.switchFeatures.capabilities != null) {
+        if (fcnu != null) {
+            props.add(toADTimestamp)
+
+            // props.add(fcnu.supportedActions.toADActions) - TODO
+            if (id != null) {
+                props.add(id.toADMacAddress)
+            }
+            if (fcnu.switchFeatures != null) {
+                if (fcnu.switchFeatures.maxTables != null) {
+                    props.add(fcnu.switchFeatures.maxTables.toADTables)
+                }
+                if (fcnu.switchFeatures.capabilities != null) {
                     props.add(fcnu.switchFeatures.capabilities.toADCapabiliities)
                     props.add(fcnu.switchFeatures.capabilities.toADCapabiliities)
-                 } 
-                 if(fcnu.switchFeatures.maxBuffers != null) {
+                }
+                if (fcnu.switchFeatures.maxBuffers != null) {
                     props.add(fcnu.switchFeatures.maxBuffers.toADBuffers)
                     props.add(fcnu.switchFeatures.maxBuffers.toADBuffers)
-                 }   
-             }
-        } 
-        return props;   
-        
+                }
+            }
+        }
+        return props;
     }
     }
-    
+
     public static def toADTimestamp() {
         val date = new Date();
     public static def toADTimestamp() {
         val date = new Date();
-        val timestamp = new TimeStamp(date.time,"connectedSince")
+        val timestamp = new TimeStamp(date.time, "connectedSince")
         return timestamp;
     }
         return timestamp;
     }
-    
+
     public static def toADMacAddress(NodeId id) {
     public static def toADMacAddress(NodeId id) {
-        return new MacAddress(Long.parseLong(id.value.replaceAll("openflow:","")).longValue.bytesFromDpid)
+        return new MacAddress(Long.parseLong(id.value.replaceAll("openflow:", "")).longValue.bytesFromDpid)
     }
     }
-    
+
     public static def toADTables(Short tables) {
         return new Tables(tables.byteValue)
     }
     public static def toADTables(Short tables) {
         return new Tables(tables.byteValue)
     }
-    
+
     public static def toADCapabiliities(List<Class<? extends FeatureCapability>> capabilities) {
         var int b
     public static def toADCapabiliities(List<Class<? extends FeatureCapability>> capabilities) {
         var int b
-        for(capability : capabilities) {
-            if(capability.equals(FlowFeatureCapabilityFlowStats)) {
+        for (capability : capabilities) {
+            if (capability.equals(FlowFeatureCapabilityFlowStats)) {
                 b = Capabilities.CapabilitiesType.FLOW_STATS_CAPABILITY.value.bitwiseOr(b)
             } else if (capability.equals(FlowFeatureCapabilityTableStats)) {
                 b = Capabilities.CapabilitiesType.TABLE_STATS_CAPABILITY.value.bitwiseOr(b)
                 b = Capabilities.CapabilitiesType.FLOW_STATS_CAPABILITY.value.bitwiseOr(b)
             } else if (capability.equals(FlowFeatureCapabilityTableStats)) {
                 b = Capabilities.CapabilitiesType.TABLE_STATS_CAPABILITY.value.bitwiseOr(b)
@@ -314,9 +340,9 @@ public class NodeMapping {
         }
         return new Capabilities(b)
     }
         }
         return new Capabilities(b)
     }
-    
+
     public static def toADBuffers(Long buffers) {
         return new Buffers(buffers.intValue)
     }
     public static def toADBuffers(Long buffers) {
         return new Buffers(buffers.intValue)
     }
-    
+
 }
 }