You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/04/24 02:20:44 UTC
[02/45] ambari git commit: AMBARI-20696: Skip calling stack selector,
conf selector tools for Nifi, Streamline,
Registry custom services in HDP cluster (Madhuvanthi Radhakrishnan via
jluniya)
AMBARI-20696: Skip calling stack selector, conf selector tools for Nifi, Streamline, Registry custom services in HDP cluster (Madhuvanthi Radhakrishnan via jluniya)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/91d43869
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/91d43869
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/91d43869
Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 91d438697c902a2284e7e9c78e14995cead910e8
Parents: 998e764
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Wed Apr 19 09:06:33 2017 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Wed Apr 19 09:06:33 2017 -0700
----------------------------------------------------------------------
.../libraries/functions/version_select_util.py | 40 ++++++++++++++++++++
1 file changed, 40 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/91d43869/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
index ff00a1f..79dc874 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
@@ -78,6 +78,46 @@ def get_component_version(stack_name, component_name):
return version
+def get_component_version_with_stack_selector(stack_selector_path, component_name):
+ """
+ For specific cases where we deal with HDP add on services from a management pack, the version
+ needs to be determined by using the specific stack selector itself.
+ :param stack_selector_path: /usr/bin/hdf-select
+ Comes from the service which calls for this function.
+ :param component_name: Component name as a string necessary to get the version
+ :return: Returns a string if found, e.g., 2.2.1.0-2175, otherwise, returns None
+ This function can be called by custom services, hence should not be removed
+ """
+ version = None
+ out = None
+ code = -1
+ if not stack_selector_path:
+ Logger.error("Stack selector path not provided")
+ elif not os.path.exists(stack_selector_path):
+ Logger.error("Stack selector path does not exist")
+ elif not component_name:
+ Logger.error("Component name not provided")
+ else:
+ tmpfile = tempfile.NamedTemporaryFile()
+
+ get_stack_comp_version_cmd = ""
+ try:
+ # This is necessary because Ubuntu returns "stdin: is not a tty", see AMBARI-8088
+ with open(tmpfile.name, 'r') as file:
+ get_stack_comp_version_cmd = '{0} status {1} > {2}' .format(stack_selector_path, component_name, tmpfile.name)
+ code, stdoutdata = shell.call(get_stack_comp_version_cmd, quiet=True)
+ out = file.read()
+
+ if code != 0 or out is None:
+ raise Exception("Code is nonzero or output is empty")
+
+ Logger.debug("Command: %s\nOutput: %s" % (get_stack_comp_version_cmd, str(out)))
+ matches = re.findall(r"([\d\.]+\-\d+)", out)
+ version = matches[0] if matches and len(matches) > 0 else None
+ except Exception, e:
+ Logger.error("Could not determine stack version for component %s by calling '%s'. Return Code: %s, Output: %s." %
+ (component_name, get_stack_comp_version_cmd, str(code), str(out)))
+ return version
def get_versions_from_stack_root(stack_root):
"""