Added methods to Bmv2ThriftClient to dump the device JSON config
Change-Id: I8ad334d3030f2754f9361731e4c53d446efcb663
diff --git a/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Client.java b/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Client.java
index 80d9c10..324e3e4 100644
--- a/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Client.java
+++ b/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Client.java
@@ -97,4 +97,20 @@
* @throws Bmv2RuntimeException if any error occurs
*/
void resetState() throws Bmv2RuntimeException;
+
+ /**
+ * Returns the JSON-formatted model configuration currently used to process packets.
+ *
+ * @return a JSON-formatted string value
+ * @throws Bmv2RuntimeException if any error occurs
+ */
+ String dumpJsonConfig() throws Bmv2RuntimeException;
+
+ /**
+ * Returns the md5 hash of the JSON-formatted model configuration currently used to process packets.
+ *
+ * @return a string value
+ * @throws Bmv2RuntimeException if any error occurs
+ */
+ String getJsonConfigMd5() throws Bmv2RuntimeException;
}
diff --git a/protocols/bmv2/src/main/java/org/onosproject/bmv2/ctl/Bmv2ThriftClient.java b/protocols/bmv2/src/main/java/org/onosproject/bmv2/ctl/Bmv2ThriftClient.java
index f0e68f7..d866c55 100644
--- a/protocols/bmv2/src/main/java/org/onosproject/bmv2/ctl/Bmv2ThriftClient.java
+++ b/protocols/bmv2/src/main/java/org/onosproject/bmv2/ctl/Bmv2ThriftClient.java
@@ -420,6 +420,36 @@
}
}
+ @Override
+ public String dumpJsonConfig() throws Bmv2RuntimeException {
+
+ LOG.debug("Dumping device config... > deviceId={}", deviceId);
+
+ try {
+ String config = standardClient.bm_get_config();
+ LOG.debug("Device config dumped! > deviceId={}, configLength={}", deviceId, config.length());
+ return config;
+ } catch (TException e) {
+ LOG.debug("Exception while dumping device config: {} > deviceId={}", e, deviceId);
+ throw new Bmv2RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public String getJsonConfigMd5() throws Bmv2RuntimeException {
+
+ LOG.debug("Getting device config md5... > deviceId={}", deviceId);
+
+ try {
+ String md5 = standardClient.bm_get_config_md5();
+ LOG.debug("Device config md5 received! > deviceId={}, configMd5={}", deviceId, md5);
+ return md5;
+ } catch (TException e) {
+ LOG.debug("Exception while getting device config md5: {} > deviceId={}", e, deviceId);
+ throw new Bmv2RuntimeException(e.getMessage(), e);
+ }
+ }
+
/**
* Transport/client cache loader.
*/