ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-15674: Remove hdp specific logic from custom_actions scripts (jluniya)
Date Mon, 04 Apr 2016 20:48:26 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 62e406a61 -> 492954e42


AMBARI-15674: Remove hdp specific logic from custom_actions scripts (jluniya)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/492954e4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/492954e4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/492954e4

Branch: refs/heads/trunk
Commit: 492954e42e631604fc02c7086d6036568b2a7fd7
Parents: 62e406a
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Mon Apr 4 13:48:34 2016 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Mon Apr 4 13:48:34 2016 -0700

----------------------------------------------------------------------
 .../custom_actions/scripts/install_packages.py  | 34 +++++++---------
 .../custom_actions/scripts/ru_set_all.py        | 42 +++++++++-----------
 2 files changed, 33 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/492954e4/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
index 2e5cffc..c01dbb3 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
@@ -36,11 +36,13 @@ from resource_management.libraries.functions.packages_analyzer import
allInstall
 from resource_management.libraries.functions import conf_select
 from resource_management.libraries.functions import stack_tools
 from resource_management.libraries.functions.stack_select import get_stack_versions
-from resource_management.libraries.functions.version import compare_versions, format_stack_version
+from resource_management.libraries.functions.version import format_stack_version
 from resource_management.libraries.functions.repo_version_history \
   import read_actual_version_from_history_file, write_actual_version_to_history_file, REPO_VERSION_HISTORY_FILE
 from resource_management.libraries.script.script import Script
 from resource_management.core.resources.system import Execute
+from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions import StackFeature
 
 from resource_management.core.logger import Logger
 
@@ -54,8 +56,6 @@ class InstallPackages(Script):
   """
 
   UBUNTU_REPO_COMPONENTS_POSTFIX = ["main"]
-  REPO_FILE_NAME_PREFIX = 'HDP-'
-  STACK_TO_ROOT_FOLDER = {"HDP": "/usr/hdp"}
 
   def actionexecute(self, env):
     num_errors = 0
@@ -91,16 +91,12 @@ class InstallPackages(Script):
       self.current_stack_version_formatted = format_stack_version(current_stack_version_unformatted)
 
 
-    stack_name = None
-    self.stack_root_folder = None
-    if stack_id and "-" in stack_id:
-      stack_split = stack_id.split("-")
-      if len(stack_split) == 2:
-        stack_name = stack_split[0].upper()
-        if stack_name in self.STACK_TO_ROOT_FOLDER:
-          self.stack_root_folder = self.STACK_TO_ROOT_FOLDER[stack_name]
+    self.stack_name = Script.get_stack_name()
+    if self.stack_name is None:
+      raise Fail("Cannot determine the stack name")
+    self.stack_root_folder = Script.get_stack_root()
     if self.stack_root_folder is None:
-      raise Fail("Cannot determine the stack's root directory by parsing the stack_id property,
{0}".format(str(stack_id)))
+      raise Fail("Cannot determine the stack's root directory")
     if self.repository_version is None:
       raise Fail("Cannot determine the repository version to install")
 
@@ -188,21 +184,19 @@ class InstallPackages(Script):
       Logger.info("Unrecognized stack id {0}, cannot create config links".format(stack_id))
       return
 
-    if args[0] != "HDP":
-      Logger.info("Unrecognized stack name {0}, cannot create config links".format(args[0]))
-
-    if compare_versions(format_stack_version(args[1]), "2.3.0.0") < 0:
-      Logger.info("Configuration symlinks are not needed for {0}, only HDP-2.3+".format(stack_version))
+    target_stack_version = args[1]
+    if not (target_stack_version and check_stack_feature(StackFeature.CONFIG_VERSIONING,
target_stack_version)):
+      Logger.info("Configuration symlinks are not needed for {0}".format(stack_version))
       return
 
     for package_name, directories in conf_select.get_package_dirs().iteritems():
       # if already on HDP 2.3, then we should skip making conf.backup folders
-      if self.current_stack_version_formatted and compare_versions(self.current_stack_version_formatted,
'2.3') >= 0:
+      if self.current_stack_version_formatted and check_stack_feature(StackFeature.CONFIG_VERSIONING,
self.current_stack_version_formatted):
         conf_selector_name = stack_tools.get_stack_tool_name(stack_tools.CONF_SELECTOR_NAME)
         Logger.info("The current cluster stack of {0} does not require backing up configurations;
"
                     "only {1} versioned config directories will be created.".format(stack_version,
conf_selector_name))
         # only link configs for all known packages
-        conf_select.select("HDP", package_name, stack_version, ignore_errors = True)
+        conf_select.select(self.stack_name, package_name, stack_version, ignore_errors =
True)
       else:
         # link configs and create conf.backup folders for all known packages
         # this will also call conf-select select
@@ -413,7 +407,7 @@ class InstallPackages(Script):
       repo['mirrorsList'] = url_info['mirrorsList']
 
     ubuntu_components = [url_info['name']] + self.UBUNTU_REPO_COMPONENTS_POSTFIX
-    file_name = self.REPO_FILE_NAME_PREFIX + self.repository_version
+    file_name = self.stack_name + "-" + self.repository_version
 
     Repository(repo['repoName'],
       action = "create",

http://git-wip-us.apache.org/repos/asf/ambari/blob/492954e4/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py b/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
index bcb08c4..d70e87f 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
@@ -28,12 +28,13 @@ from resource_management.libraries.functions import conf_select
 from resource_management.libraries.functions import stack_tools
 from resource_management.libraries.functions.constants import Direction
 from resource_management.libraries.functions.default import default
-from resource_management.libraries.functions.version import compare_versions
 from resource_management.libraries.functions.version import format_stack_version
 from resource_management.core import shell
 from resource_management.core.exceptions import Fail
 from resource_management.core.logger import Logger
 from resource_management.core.resources.system import Execute, Link, Directory
+from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions import StackFeature
 
 class UpgradeSetAll(Script):
   """
@@ -55,19 +56,17 @@ class UpgradeSetAll(Script):
       cmd = ('/usr/bin/yum', 'clean', 'all')
       code, out = shell.call(cmd, sudo=True)
 
-    min_ver = format_stack_version("2.2")
     real_ver = format_stack_version(version)
-    if stack_name == "HDP":
-      if compare_versions(real_ver, min_ver) >= 0:
-        stack_selector_path = stack_tools.get_stack_tool_path(stack_tools.STACK_SELECTOR_NAME)
-        cmd = ('ambari-python-wrap', stack_selector_path, 'set', 'all', version)
-        code, out = shell.call(cmd, sudo=True)
+    if real_ver and check_stack_feature(StackFeature.ROLLING_UPGRADE, real_ver):
+      stack_selector_path = stack_tools.get_stack_tool_path(stack_tools.STACK_SELECTOR_NAME)
+      cmd = ('ambari-python-wrap', stack_selector_path, 'set', 'all', version)
+      code, out = shell.call(cmd, sudo=True)
 
-      if compare_versions(real_ver, format_stack_version("2.3")) >= 0:
-        # backup the old and symlink /etc/[component]/conf to <stack-root>/current/[component]
-        for k, v in conf_select.get_package_dirs().iteritems():
-          for dir_def in v:
-            link_config(dir_def['conf_dir'], dir_def['current_dir'])
+    if real_ver and check_stack_feature(StackFeature.CONFIG_VERSIONING, real_ver):
+      # backup the old and symlink /etc/[component]/conf to <stack-root>/current/[component]
+      for k, v in conf_select.get_package_dirs().iteritems():
+        for dir_def in v:
+          link_config(dir_def['conf_dir'], dir_def['current_dir'])
 
 
   def unlink_all_configs(self, env):
@@ -85,30 +84,27 @@ class UpgradeSetAll(Script):
       Logger.warning("Unlinking configurations should only be performed on a downgrade.")
       return
 
-    # HDP only
-    if stack_name != "HDP":
-      Logger.warning("Unlinking configurations should only be performed on the HDP stack.")
-      return
-
     if downgrade_to_version is None or downgrade_from_version is None:
       Logger.warning("Both 'commandParams/version' and 'commandParams/downgrade_from_version'
must be specified to unlink configs on downgrade.")
       return
 
-    Logger.info("Unlinking all configs when downgrading from HDP 2.3 to 2.2")
+    Logger.info("Unlinking all configs when downgrading from {0} {1} to {2}".format(
+        stack_name, downgrade_from_version, downgrade_to_version))
 
     # normalize the versions
-    stack_23 = format_stack_version("2.3")
     downgrade_to_version = format_stack_version(downgrade_to_version)
     downgrade_from_version = format_stack_version(downgrade_from_version)
 
     # downgrade-to-version must be 2.2 (less than 2.3)
-    if compare_versions(downgrade_to_version, stack_23) >= 0:
-      Logger.warning("Unlinking configurations should only be performed when downgrading
to HDP 2.2")
+    if downgrade_to_version and check_stack_feature(StackFeature.CONFIG_VERSIONING, downgrade_to_version):
+      Logger.warning("Unlinking configurations should not be performed when downgrading {0}
{1} to {2}".format(
+          stack_name, downgrade_from_version, downgrade_to_version))
       return
 
     # downgrade-from-version must be 2.3+
-    if compare_versions(downgrade_from_version, stack_23) < 0:
-      Logger.warning("Unlinking configurations should only be performed when downgrading
from HDP 2.3 or later")
+    if not( downgrade_from_version and check_stack_feature(StackFeature.CONFIG_VERSIONING,
downgrade_from_version) ):
+      Logger.warning("Unlinking configurations should not be performed when downgrading {0}
{1} to {2}".format(
+          stack_name, downgrade_from_version, downgrade_to_version))
       return
 
     # iterate through all directory conf mappings and undo the symlinks


Mime
View raw message