aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/honeycomb/HcPersistence.py
diff options
context:
space:
mode:
authorselias <samelias@cisco.com>2017-03-07 15:42:02 +0100
committerTibor Frank <tifrank@cisco.com>2017-03-21 12:00:46 +0000
commit4f4eaa1d52f3bdbe3caecdc1d6a024c369a2834a (patch)
tree44d1d559b187dbdf10eae12acc4da19affa1a5f4 /resources/libraries/python/honeycomb/HcPersistence.py
parent8003aa2c3d1a0d4c1dbf3b6286d841a47b5fbb4c (diff)
CSIT-536 HC Test: support testing with ODL client
Reuses existing restconf test cases to test Honeycomb's netconf interface. When seding the requests to ODL's Honeycomb mountpoint, ODL translates these requests to netconf RPCs. Add new tag "honeycomb_odl" that excludes incompatible test cases. Change-Id: Ie293449da0129b02db85e30aa4f3266928d7d9f6 Signed-off-by: selias <samelias@cisco.com>
Diffstat (limited to 'resources/libraries/python/honeycomb/HcPersistence.py')
-rw-r--r--resources/libraries/python/honeycomb/HcPersistence.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/resources/libraries/python/honeycomb/HcPersistence.py b/resources/libraries/python/honeycomb/HcPersistence.py
index c76a276098..83d756f9d3 100644
--- a/resources/libraries/python/honeycomb/HcPersistence.py
+++ b/resources/libraries/python/honeycomb/HcPersistence.py
@@ -102,3 +102,43 @@ class HcPersistence(object):
for command in commands:
(_, stdout, _) = ssh.exec_command_sudo(command)
logger.info(stdout)
+
+
+ @staticmethod
+ def configure_persistence(node, state):
+ """Enable or disable Honeycomb configuration data persistence.
+
+ :param node: Honeycomb node.
+ :param state: Enable or Disable.
+ :type node: dict
+ :type state: str
+ :raises ValueError: If the state argument is incorrect.
+ :raises HoneycombError: If the operation fails.
+ """
+
+ state = state.lower()
+ if state == "enable":
+ state = "true"
+ elif state == "disable":
+ state = "false"
+ else:
+ raise ValueError("Unexpected value of state argument:"
+ " {0} provided. Must be enable or disable."
+ .format(state))
+
+ for setting in ("persist-config", "persist-context"):
+ # find the setting, replace entire line with 'setting: state'
+ find = '\\"{setting}\\":'.format(setting=setting)
+ replace = '\\"{setting}\\": \\"{state}\\",'.format(
+ setting=setting, state=state)
+
+ argument = '"/{0}/c\\ {1}"'.format(find, replace)
+ path = "{0}/config/honeycomb.json".format(Const.REMOTE_HC_DIR)
+ command = "sed -i {0} {1}".format(argument, path)
+
+ ssh = SSH()
+ ssh.connect(node)
+ (ret_code, _, stderr) = ssh.exec_command_sudo(command)
+ if ret_code != 0:
+ raise HoneycombError("Failed to modify configuration on "
+ "node {0}, {1}".format(node, stderr))