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 {
* @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;
}
......
......@@ -420,6 +420,36 @@ public final class Bmv2ThriftClient implements Bmv2Client {
}
}
@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.
*/
......