diff options
author | Alejandro Fernandez <afernandez@hortonworks.com> | 2017-03-28 17:32:02 -0700 |
---|---|---|
committer | Alejandro Fernandez <afernandez@hortonworks.com> | 2017-03-28 17:32:02 -0700 |
commit | 02d7aafe9ea8a2332888fedd2b40cfdf8f97722a (patch) | |
tree | 508193fd96a90f0b7b39850f0f1585666200031c /ambari-common | |
parent | d67d8a08fe6f1a2b8fb8b58d383ac23e5bf21a94 (diff) |
AMBARI-20565. Ambari Agent Alert to detect when 'hdp-select versions' reports an error (alejandro)
Diffstat (limited to 'ambari-common')
-rw-r--r-- | ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py b/ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py index 34c311d3dc..265e7df9a0 100644 --- a/ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py +++ b/ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py @@ -286,11 +286,25 @@ def _get_upgrade_stack(): return None +def unsafe_get_stack_versions(): + """ + Gets list of stack versions installed on the host. + By default a call to <stack-selector-tool> versions is made to get the list of installed stack versions. + DO NOT use a fall-back since this function is called by alerts in order to find potential errors. + :return: Returns a tuple of (exit code, output, list of installed stack versions). + """ + stack_selector_path = stack_tools.get_stack_tool_path(stack_tools.STACK_SELECTOR_NAME) + code, out = call((STACK_SELECT_PREFIX, stack_selector_path, 'versions')) + versions = [] + if 0 == code: + for line in out.splitlines(): + versions.append(line.rstrip('\n')) + return (code, out, versions) def get_stack_versions(stack_root): """ Gets list of stack versions installed on the host. - Be default a call to <stack-selector-tool> versions is made to get the list of installed stack versions. + By default a call to <stack-selector-tool> versions is made to get the list of installed stack versions. As a fallback list of installed versions is collected from stack version directories in stack install root. :param stack_root: Stack install root :return: Returns list of installed stack versions. |