You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ha...@apache.org on 2018/05/02 06:41:50 UTC

[ambari] branch trunk updated (a9ed081 -> 737dfc7)

This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git.


    from a9ed081  fix UT and issues from review
     new 1b9055b  Revert "fix UT and issues from review"
     new caab480  Revert "AMBARI-23717 Stack installation command didn't fail properly when installed package didn't present in repository (dgrinenko)"
     new 737dfc7  Revert "initial"

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ambari_commons/repo_manager/apt_manager.py     | 15 ++-------
 .../ambari_commons/repo_manager/generic_manager.py |  6 ----
 .../ambari_commons/repo_manager/yum_manager.py     | 13 +-------
 .../ambari_commons/repo_manager/zypper_manager.py  | 17 ++--------
 .../resource_management/libraries/script/script.py | 33 ++++++-------------
 .../python/custom_actions/TestInstallPackages.py   | 37 +++++++++++-----------
 6 files changed, 33 insertions(+), 88 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
hapylestat@apache.org.

[ambari] 02/03: Revert "AMBARI-23717 Stack installation command didn't fail properly when installed package didn't present in repository (dgrinenko)"

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit caab48040855fa3db8dc2a02a1896b9617266b4f
Author: Dmytro Grinenko <ha...@gmail.com>
AuthorDate: Wed May 2 09:38:54 2018 +0300

    Revert "AMBARI-23717 Stack installation command didn't fail properly when installed package didn't present in repository (dgrinenko)"
    
    This reverts commit 010e4a77ddd640201f01a3f5335acf2ca32e9367.
---
 .../ambari_commons/repo_manager/apt_manager.py     | 16 +++--------
 .../ambari_commons/repo_manager/generic_manager.py |  6 -----
 .../ambari_commons/repo_manager/yum_manager.py     | 14 +++-------
 .../ambari_commons/repo_manager/zypper_manager.py  | 14 ++--------
 .../resource_management/libraries/script/script.py | 31 +++++++---------------
 5 files changed, 18 insertions(+), 63 deletions(-)

diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
index fdee179..76d31f1 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
@@ -215,16 +215,12 @@ class AptManager(GenericManager):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
     from resource_management.core import sudo
 
     apt_sources_list_tmp_dir = None
 
-    if not name:
-      raise ValueError("Installation command were executed with no package name passed")
-    elif context.is_upgrade or context.use_repos or not self._check_existence(name):
+    if context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
       copied_sources_files = []
       is_tmp_dir_created = False
@@ -268,8 +264,6 @@ class AptManager(GenericManager):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
     context.is_upgrade = True
     return self.install_package(name, context)
@@ -282,12 +276,8 @@ class AptManager(GenericManager):
     :type name str
     :type context ambari_commons.shell.RepoCallContext
     :type ignore_dependencies bool
-
-    :raise ValueError if name is empty
     """
-    if not name:
-      raise ValueError("Installation command were executed with no package name passed")
-    elif self._check_existence(name):
+    if self._check_existence(name):
       cmd = self.properties.remove_cmd[context.log_output] + [name]
       Logger.info("Removing package {0} ('{1}')".format(name, shell.string_cmd_from_args_list(cmd)))
       shell.repository_manager_executor(cmd, self.properties, context)
@@ -314,6 +304,8 @@ class AptManager(GenericManager):
     apt-get in inconsistant state (locked, used, having invalid repo). Once packages are installed
     we should not rely on that.
     """
+    if not name:
+      raise ValueError("Package name can't be empty")
 
     r = shell.subprocess_executor(self.properties.check_cmd % name)
     return not bool(r.code)
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/generic_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/generic_manager.py
index 3b6056c..d4e1e08 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/generic_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/generic_manager.py
@@ -69,8 +69,6 @@ class GenericManager(object):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
     raise NotImplementedError()
 
@@ -81,8 +79,6 @@ class GenericManager(object):
     :type name str
     :type context ambari_commons.shell.RepoCallContext
     :type ignore_dependencies bool
-
-    :raise ValueError if name is empty
     """
     raise NotImplementedError()
 
@@ -92,8 +88,6 @@ class GenericManager(object):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
     raise NotImplementedError()
 
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
index 0f056ba..6a2b629 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
@@ -202,13 +202,9 @@ class YumManager(GenericManager):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
 
-    if not name:
-      raise ValueError("Installation command were executed with no package name passed")
-    elif context.is_upgrade or context.use_repos or not self._check_existence(name):
+    if context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
       if context.use_repos:
         enable_repo_option = '--enablerepo=' + ",".join(sorted(context.use_repos.keys()))
@@ -226,8 +222,6 @@ class YumManager(GenericManager):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
     context.is_upgrade = True
     return self.install_package(name, context)
@@ -239,11 +233,7 @@ class YumManager(GenericManager):
     :type name str
     :type context ambari_commons.shell.RepoCallContext
     :type ignore_dependencies bool
-
-    :raise ValueError if name is empty
     """
-    if not name:
-      raise ValueError("Remove command were executed with no package name passed")
     if self._check_existence(name):
       if ignore_dependencies:
         cmd = self.properties.remove_without_dependencies_cmd + [name]
@@ -273,6 +263,8 @@ class YumManager(GenericManager):
     yum in inconsistant state (locked, used, having invalid repo). Once packages are installed
     we should not rely on that.
     """
+    if not name:
+      raise ValueError("Package name can't be empty")
 
     if os.geteuid() == 0:
       return self.yum_check_package_available(name)
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
index 592e7c8..9f6f09a 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
@@ -178,12 +178,8 @@ class ZypperManager(GenericManager):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
-    if not name:
-      raise ValueError("Installation command were executed with no package name passed")
-    elif context.is_upgrade or context.use_repos or not self._check_existence(name):
+    if context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
 
       if context.use_repos:
@@ -210,8 +206,6 @@ class ZypperManager(GenericManager):
 
     :type name str
     :type context ambari_commons.shell.RepoCallContext
-
-    :raise ValueError if name is empty
     """
     context.is_upgrade = True
     return self.install_package(name, context)
@@ -223,12 +217,8 @@ class ZypperManager(GenericManager):
     :type name str
     :type context ambari_commons.shell.RepoCallContext
     :type ignore_dependencies bool
-
-    :raise ValueError if name is empty
     """
-    if not name:
-      raise ValueError("Installation command were executed with no package name passed")
-    elif self._check_existence(name):
+    if self._check_existence(name):
       cmd = self.properties.remove_cmd[context.log_output] + [name]
       Logger.info("Removing package {0} ('{1}')".format(name, shell.string_cmd_from_args_list(cmd)))
       shell.repository_manager_executor(cmd, self.properties, context)
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index 60aac9c..626aa19 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -491,41 +491,24 @@ class Script(object):
 
     return Script.stack_version_from_distro_select
 
-  def get_package_from_available(self, name, available_packages_in_repos=None):
+
+  def get_package_from_available(self, name, available_packages_in_repos):
     """
     This function matches package names with ${stack_version} placeholder to actual package names from
     Ambari-managed repository.
     Package names without ${stack_version} placeholder are returned as is.
     """
-
     if STACK_VERSION_PLACEHOLDER not in name:
       return name
-
-    if not available_packages_in_repos:
-      available_packages_in_repos = self.load_available_packages()
-
-    from resource_management.libraries.functions.default import default
-
     package_delimiter = '-' if OSCheck.is_ubuntu_family() else '_'
     package_regex = name.replace(STACK_VERSION_PLACEHOLDER, '(\d|{0})+'.format(package_delimiter)) + "$"
-    repo = default('/repositoryFile', None)
-    name_with_version = None
-
-    if repo:
-      command_repo = CommandRepository(repo)
-      version_str = command_repo.version_string.replace('.', package_delimiter).replace("-", package_delimiter)
-      name_with_version = name.replace(STACK_VERSION_PLACEHOLDER, version_str)
-
     for package in available_packages_in_repos:
       if re.match(package_regex, package):
         return package
+    Logger.warning("No package found for {0}({1})".format(name, package_regex))
 
-    if name_with_version:
-      raise Fail("No package found for {0}(expected name: {1})".format(name, name_with_version))
-    else:
-      raise Fail("Cannot match package for regexp name {0}. Available packages: {1}".format(name, self.available_packages_in_repos))
 
-  def format_package_name(self, name):
+  def format_package_name(self, name, repo_version=None):
     from resource_management.libraries.functions.default import default
     """
     This function replaces ${stack_version} placeholder with actual version.  If the package
@@ -554,7 +537,11 @@ class Script(object):
       package_version = default("hostLevelParams/package_version", None)
 
     if (package_version is None or '-' not in package_version) and default('/repositoryFile', None):
-      return self.get_package_from_available(name)
+      self.load_available_packages()
+      package_name = self.get_package_from_available(name, self.available_packages_in_repos)
+      if package_name is None:
+        raise Fail("Cannot match package for regexp name {0}. Available packages: {1}".format(name, self.available_packages_in_repos))
+      return package_name
 
     if package_version is not None:
       package_version = package_version.replace('.', package_delimiter).replace('-', package_delimiter)

-- 
To stop receiving notification emails like this one, please contact
hapylestat@apache.org.

[ambari] 01/03: Revert "fix UT and issues from review"

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 1b9055ba05cb9791c8f9239fb442b180c4b8099c
Author: Dmytro Grinenko <ha...@gmail.com>
AuthorDate: Wed May 2 09:38:54 2018 +0300

    Revert "fix UT and issues from review"
    
    This reverts commit a9ed08134716a41a4feee07f50c8954c306f3117.
---
 .../ambari_commons/repo_manager/apt_manager.py     |  2 +-
 .../ambari_commons/repo_manager/yum_manager.py     |  2 +-
 .../ambari_commons/repo_manager/zypper_manager.py  |  2 +-
 .../resource_management/libraries/script/script.py |  2 --
 .../python/custom_actions/TestInstallPackages.py   | 37 +++++++++++-----------
 5 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
index 9f4330a..fdee179 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
@@ -223,7 +223,7 @@ class AptManager(GenericManager):
     apt_sources_list_tmp_dir = None
 
     if not name:
-      raise ValueError("Installation command was executed with no package name")
+      raise ValueError("Installation command were executed with no package name passed")
     elif context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
       copied_sources_files = []
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
index 7df4632..0f056ba 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
@@ -207,7 +207,7 @@ class YumManager(GenericManager):
     """
 
     if not name:
-      raise ValueError("Installation command was executed with no package name")
+      raise ValueError("Installation command were executed with no package name passed")
     elif context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
       if context.use_repos:
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
index 8d901c2..592e7c8 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
@@ -182,7 +182,7 @@ class ZypperManager(GenericManager):
     :raise ValueError if name is empty
     """
     if not name:
-      raise ValueError("Installation command was executed with no package name")
+      raise ValueError("Installation command were executed with no package name passed")
     elif context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
 
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index 1ddc49a..60aac9c 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -783,8 +783,6 @@ class Script(object):
       Logger.exception("Unable to load available packages")
       self.available_packages_in_repos = []
 
-    return self.available_packages_in_repos
-
 
   def install_packages(self, env):
     """
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 6e04938..7efe226 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -49,14 +49,14 @@ class TestInstallPackages(RMFTestCase):
     self.maxDiff = None
 
   @staticmethod
-  def _add_packages(*args, **kwargs):
+  def _add_packages(*args):
     return [
       ["pkg1", "1.0", "repo"],
       ["pkg2", "2.0", "repo2"]
     ]
 
   @staticmethod
-  def _add_packages_available(*args, **kwargs):
+  def _add_packages_available(*args):
     return [
       ["hadoop_2_2_0_1_885", "1.0", "HDP-2.2"],
       ["hadooplzo_2_2_0_1_885", "1.0", "HDP-2.2"],
@@ -64,8 +64,8 @@ class TestInstallPackages(RMFTestCase):
     ]
 
   @staticmethod
-  def _add_packages_lookUpYum(*args, **kwargs):
-    return TestInstallPackages._add_packages_available(*args, **kwargs)
+  def _add_packages_lookUpYum(*args):
+    return TestInstallPackages._add_packages_available(*args)
 
   def test_get_installed_package_version(self):
     from ambari_commons.os_check import OSConst
@@ -185,18 +185,18 @@ class TestInstallPackages(RMFTestCase):
 
       get_provider.return_value = pkg_manager
 
-      try:
-        self.executeScript("scripts/install_packages.py",
-                           classname="InstallPackages",
-                           command="actionexecute",
-                           config_dict = command_json,
-                           target=RMFTestCase.TARGET_CUSTOM_ACTIONS,
-                           os_type=('Redhat', '6.4', 'Final'),
-        )
-      except Fail as e:
-        self.assertEquals(e.message, "Failed to distribute repositories/install packages")
-      else:
-        self.assertFalse("Packages can't be installed without repos")
+      self.executeScript("scripts/install_packages.py",
+                         classname="InstallPackages",
+                         command="actionexecute",
+                         config_dict = command_json,
+                         target=RMFTestCase.TARGET_CUSTOM_ACTIONS,
+                         os_type=('Redhat', '6.4', 'Final'),
+      )
+      self.assertTrue(put_structured_out_mock.called)
+      self.assertEquals(put_structured_out_mock.call_args[0][0],
+                        {'package_installation_result': 'SUCCESS',
+                         'repository_version_id': 1,
+                         'actual_version': VERSION_STUB})
 
       self.assertNoMoreResources()
 
@@ -339,7 +339,7 @@ class TestInstallPackages(RMFTestCase):
   _install_failed = False
 
   @staticmethod
-  def _add_packages_with_fail(*args, **kwargs):
+  def _add_packages_with_fail():
     arg = []
     arg.append(["pkg1_2_2_0_1_885_pack", "1.0", "repo"])
     arg.append(["pkg2_2_2_0_1_885_pack2", "2.0", "repo2"])
@@ -400,7 +400,8 @@ class TestInstallPackages(RMFTestCase):
       self.assertTrue(put_structured_out_mock.called)
       self.assertEquals(put_structured_out_mock.call_args[0][0],
                         {'repository_version_id': 1,
-                        'package_installation_result': 'FAIL'})
+                        'package_installation_result': 'FAIL',
+                         'actual_version': '2.2.0.1-885'})
       self.assertResourceCalled('Repository', 'HDP-UTILS-1.1.0.20',
                                 base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                                 action=['create'],

-- 
To stop receiving notification emails like this one, please contact
hapylestat@apache.org.

[ambari] 03/03: Revert "initial"

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 737dfc7781d06df9072be3f1559229b21c38a1c8
Author: Dmytro Grinenko <ha...@gmail.com>
AuthorDate: Wed May 2 09:38:54 2018 +0300

    Revert "initial"
    
    This reverts commit fb178d2fa3cdf6f2586648264a1888357dd95a3f.
---
 .../src/main/python/ambari_commons/repo_manager/apt_manager.py         | 3 ---
 .../src/main/python/ambari_commons/repo_manager/yum_manager.py         | 3 ---
 .../src/main/python/ambari_commons/repo_manager/zypper_manager.py      | 3 ---
 3 files changed, 9 deletions(-)

diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
index 76d31f1..38cf602 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
@@ -304,8 +304,5 @@ class AptManager(GenericManager):
     apt-get in inconsistant state (locked, used, having invalid repo). Once packages are installed
     we should not rely on that.
     """
-    if not name:
-      raise ValueError("Package name can't be empty")
-
     r = shell.subprocess_executor(self.properties.check_cmd % name)
     return not bool(r.code)
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
index 6a2b629..5e404b1 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
@@ -263,9 +263,6 @@ class YumManager(GenericManager):
     yum in inconsistant state (locked, used, having invalid repo). Once packages are installed
     we should not rely on that.
     """
-    if not name:
-      raise ValueError("Package name can't be empty")
-
     if os.geteuid() == 0:
       return self.yum_check_package_available(name)
     else:
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
index 9f6f09a..8617ef9 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
@@ -282,7 +282,4 @@ class ZypperManager(GenericManager):
     zypper in inconsistant state (locked, used, having invalid repo). Once packages are installed
     we should not rely on that.
     """
-    if not name:
-      raise ValueError("Package name can't be empty")
-
     return self.rpm_check_package_available(name)

-- 
To stop receiving notification emails like this one, please contact
hapylestat@apache.org.