Carmelo Cascone
Committed by Jonathan Hart

Added methods to Bmv2ThriftClient to dump the device JSON config

Change-Id: I8ad334d3030f2754f9361731e4c53d446efcb663
...@@ -97,4 +97,20 @@ public interface Bmv2Client { ...@@ -97,4 +97,20 @@ public interface Bmv2Client {
97 * @throws Bmv2RuntimeException if any error occurs 97 * @throws Bmv2RuntimeException if any error occurs
98 */ 98 */
99 void resetState() throws Bmv2RuntimeException; 99 void resetState() throws Bmv2RuntimeException;
100 +
101 + /**
102 + * Returns the JSON-formatted model configuration currently used to process packets.
103 + *
104 + * @return a JSON-formatted string value
105 + * @throws Bmv2RuntimeException if any error occurs
106 + */
107 + String dumpJsonConfig() throws Bmv2RuntimeException;
108 +
109 + /**
110 + * Returns the md5 hash of the JSON-formatted model configuration currently used to process packets.
111 + *
112 + * @return a string value
113 + * @throws Bmv2RuntimeException if any error occurs
114 + */
115 + String getJsonConfigMd5() throws Bmv2RuntimeException;
100 } 116 }
......
...@@ -420,6 +420,36 @@ public final class Bmv2ThriftClient implements Bmv2Client { ...@@ -420,6 +420,36 @@ public final class Bmv2ThriftClient implements Bmv2Client {
420 } 420 }
421 } 421 }
422 422
423 + @Override
424 + public String dumpJsonConfig() throws Bmv2RuntimeException {
425 +
426 + LOG.debug("Dumping device config... > deviceId={}", deviceId);
427 +
428 + try {
429 + String config = standardClient.bm_get_config();
430 + LOG.debug("Device config dumped! > deviceId={}, configLength={}", deviceId, config.length());
431 + return config;
432 + } catch (TException e) {
433 + LOG.debug("Exception while dumping device config: {} > deviceId={}", e, deviceId);
434 + throw new Bmv2RuntimeException(e.getMessage(), e);
435 + }
436 + }
437 +
438 + @Override
439 + public String getJsonConfigMd5() throws Bmv2RuntimeException {
440 +
441 + LOG.debug("Getting device config md5... > deviceId={}", deviceId);
442 +
443 + try {
444 + String md5 = standardClient.bm_get_config_md5();
445 + LOG.debug("Device config md5 received! > deviceId={}, configMd5={}", deviceId, md5);
446 + return md5;
447 + } catch (TException e) {
448 + LOG.debug("Exception while getting device config md5: {} > deviceId={}", e, deviceId);
449 + throw new Bmv2RuntimeException(e.getMessage(), e);
450 + }
451 + }
452 +
423 /** 453 /**
424 * Transport/client cache loader. 454 * Transport/client cache loader.
425 */ 455 */
......