Enabling port statistics discovery in NETCONF device provider.

Change-Id: I17e6b0832d60ca64db2bc7de1c3184e5c125fdf2
diff --git a/core/api/src/main/java/org/onosproject/net/device/PortStatisticsDiscovery.java b/core/api/src/main/java/org/onosproject/net/device/PortStatisticsDiscovery.java
new file mode 100644
index 0000000..86238f6
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/device/PortStatisticsDiscovery.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.device;
+
+import java.util.Collection;
+
+/**
+ * Handler behaviour capable of collecting and updating port statistics.
+ */
+public interface PortStatisticsDiscovery extends DeviceDescriptionDiscovery {
+
+    /**
+     * Returns a list of port statistics descriptions appropriately annotated
+     * to support downstream model extension via projections of their parent
+     * device.
+     *
+     * @return annotated port statistics
+     */
+    Collection<PortStatistics> discoverPortStatistics();
+}
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index da988dc..1720e2e 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -49,6 +49,7 @@
 import org.onosproject.net.device.DeviceProviderRegistry;
 import org.onosproject.net.device.DeviceProviderService;
 import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortStatisticsDiscovery;
 import org.onosproject.net.key.DeviceKey;
 import org.onosproject.net.key.DeviceKeyAdminService;
 import org.onosproject.net.key.DeviceKeyId;
@@ -479,6 +480,17 @@
         } else {
             log.warn("No portGetter behaviour for device {}", deviceId);
         }
+
+        // Port statistics discovery
+        if (device.is(PortStatisticsDiscovery.class)) {
+            PortStatisticsDiscovery d =
+                    device.as(PortStatisticsDiscovery.class);
+            providerService.updatePortStatistics(deviceId,
+                                                 d.discoverPortStatistics());
+        } else {
+            log.warn("No port statistics getter behaviour for device {}",
+                     deviceId);
+        }
     }
 
     /**