Make the netconf notification stream customisable
Change-Id: I0e51861b7f8cb4961a47e88f64a493106e2c7a8a
diff --git a/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisDeviceDescription.java b/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisDeviceDescription.java
index 21519ef..ad77648 100644
--- a/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisDeviceDescription.java
+++ b/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisDeviceDescription.java
@@ -45,9 +45,10 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.Device.Type.FIBER_SWITCH;
-import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.netconfGet;
import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.configAt;
import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.configsAt;
+import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.netconfGet;
+import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.subscribe;
import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.xmlOpen;
import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.xmlClose;
import static org.onosproject.drivers.polatis.netconf.PolatisNetconfUtility.xmlEmpty;
@@ -102,6 +103,7 @@
new ChassisId());
}
String reply = netconfGet(handler(), getProductInformationFilter());
+ subscribe(handler());
HierarchicalConfiguration cfg = configAt(reply, KEY_DATA_PRODINF);
return new DefaultDeviceDescription(dev.id().uri(), FIBER_SWITCH,
cfg.getString(KEY_MANUFACTURER), cfg.getString(KEY_HWVERSION),
diff --git a/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java b/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java
index 1516912..ee1fe39 100644
--- a/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java
+++ b/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java
@@ -220,6 +220,23 @@
}
/**
+ * Subscribes for notifications.
+ *
+ * @param handler parent driver handler
+ * @return true on success, false otherwise
+ */
+ public static boolean subscribe(DriverHandler handler) {
+ NetconfSession session = getNetconfSession(handler);
+ try {
+ session.startSubscription();
+ } catch (NetconfException e) {
+ log.error("Failed to subscribe for notifications.");
+ return false;
+ }
+ return true;
+ }
+
+ /**
* Returns the NETCONF session of the device.
*
* @return session