ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject [1/2] ambari git commit: AMBARI-22127. Installation of stack selector fails on Debian
Date Thu, 05 Oct 2017 14:16:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 710c93065 -> f1eaa6502
  refs/heads/trunk b0421821e -> 2512dc83c


AMBARI-22127. Installation of stack selector fails on Debian


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

Branch: refs/heads/branch-2.6
Commit: f1eaa6502ea53cd90f674cd87d3010d37ea4dc46
Parents: 710c930
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Wed Oct 4 08:15:12 2017 +0200
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Thu Oct 5 15:27:36 2017 +0200

----------------------------------------------------------------------
 .../resource_management/TestPackageResource.py  |  4 +-
 .../core/providers/package/__init__.py          |  4 +-
 .../core/providers/package/apt.py               | 35 ++++++++------
 .../core/providers/package/choco.py             |  8 ++--
 .../core/providers/package/yumrpm.py            |  8 ++--
 .../core/providers/package/zypper.py            |  7 +--
 .../core/resources/packaging.py                 | 14 +++++-
 .../libraries/functions/repository_util.py      |  8 +++-
 .../custom_actions/scripts/install_packages.py  | 12 ++++-
 .../custom_actions/TestInstallPackages.py       | 50 ++++++++++++--------
 10 files changed, 96 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-agent/src/test/python/resource_management/TestPackageResource.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestPackageResource.py b/ambari-agent/src/test/python/resource_management/TestPackageResource.py
index a1e827d..958dfbd 100644
--- a/ambari-agent/src/test/python/resource_management/TestPackageResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestPackageResource.py
@@ -181,13 +181,13 @@ class TestPackageResource(TestCase):
   def test_action_install_use_repos_rhel(self, shell_mock):
     shell_mock.return_value = (0,'')
     with Environment('/') as env:
-      Package("some_package", use_repos=['HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'],
+      Package("some_package", use_repos={'HDP-UTILS-2.2.0.1-885': 'ambari-hdp-1', 'HDP-2.2.0.1-885':
'ambari-hdp-1'},
               logoutput = False
               )
     self.assertEquals(shell_mock.call_args[0][0],
                       ['/usr/bin/yum', '-d', '0', '-e', '0', '-y', 'install',
                        '--disablerepo=*',
-                       '--enablerepo=HDP-UTILS-2.2.0.1-885,HDP-2.2.0.1-885', 'some_package'])
+                       '--enablerepo=HDP-2.2.0.1-885,HDP-UTILS-2.2.0.1-885', 'some_package'])
 
   @patch.object(shell, "call", new = MagicMock(return_value=(0, None)))
   @patch.object(shell, "checked_call")

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/core/providers/package/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/package/__init__.py
b/ambari-common/src/main/python/resource_management/core/providers/package/__init__.py
index 84ff9cc..13cb784 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/package/__init__.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/package/__init__.py
@@ -39,13 +39,13 @@ class PackageProvider(Provider):
   def __init__(self, *args, **kwargs):
     super(PackageProvider, self).__init__(*args, **kwargs)   
   
-  def install_package(self, name, use_repos=set(), skip_repos=set(), is_upgrade=False):
+  def install_package(self, name, use_repos={}, skip_repos=set(), is_upgrade=False):
     raise NotImplementedError()
 
   def remove_package(self, name, ignore_dependencies=False):
     raise NotImplementedError()
 
-  def upgrade_package(self, name, use_repos=set(), skip_repos=set(), is_upgrade=True):
+  def upgrade_package(self, name, use_repos={}, skip_repos=set(), is_upgrade=True):
     raise NotImplementedError()
 
   def action_install(self):

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/core/providers/package/apt.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/package/apt.py
b/ambari-common/src/main/python/resource_management/core/providers/package/apt.py
index 65caeff..5fcb945 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/package/apt.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/package/apt.py
@@ -45,6 +45,7 @@ REMOVE_CMD = {
 REPO_UPDATE_CMD = ['/usr/bin/apt-get', 'update','-qq']
 REMOVE_WITHOUT_DEPENDENCIES_CMD = ['/usr/bin/dpkg', '--remove', '--ignore-depends']
 
+EMPTY_FILE = "/dev/null"
 APT_SOURCES_LIST_DIR = "/etc/apt/sources.list.d"
 
 CHECK_CMD = "dpkg --get-selections | grep -v deinstall | awk '{print $1}' | grep ^%s$"
@@ -339,38 +340,44 @@ class AptProvider(PackageProvider):
     return True
 
   @replace_underscores
-  def install_package(self, name, use_repos=set(), skip_repos=set(), is_upgrade=False):
+  def install_package(self, name, use_repos={}, skip_repos=set(), is_upgrade=False):
     if is_upgrade or use_repos or not self._check_existence(name):
       cmd = INSTALL_CMD[self.get_logoutput()]
       copied_sources_files = []
       is_tmp_dir_created = False
       if use_repos:
-        is_tmp_dir_created = True
-        apt_sources_list_tmp_dir = tempfile.mkdtemp(suffix="-ambari-apt-sources-d")
-        Logger.info("Temporal sources directory was created: %s" % apt_sources_list_tmp_dir)
-        if 'base' not in use_repos:
+        if 'base' in use_repos:
+          use_repos = set([v for k,v in use_repos.items() if k != 'base'])
+        else:
           cmd = cmd + ['-o', 'Dir::Etc::SourceList=%s' % EMPTY_FILE]
-        for repo in use_repos:
-          if repo != 'base':
+          use_repos = set(use_repos.values())
+
+        if use_repos:
+          is_tmp_dir_created = True
+          apt_sources_list_tmp_dir = tempfile.mkdtemp(suffix="-ambari-apt-sources-d")
+          Logger.info("Temporary sources directory was created: %s" % apt_sources_list_tmp_dir)
+
+          for repo in use_repos:
             new_sources_file = os.path.join(apt_sources_list_tmp_dir, repo + '.list')
-            Logger.info("Temporal sources file will be copied: %s" % new_sources_file)
+            Logger.info("Temporary sources file will be copied: %s" % new_sources_file)
             sudo.copy(os.path.join(APT_SOURCES_LIST_DIR, repo + '.list'), new_sources_file)
             copied_sources_files.append(new_sources_file)
-        cmd = cmd + ['-o', 'Dir::Etc::SourceParts=%s' % apt_sources_list_tmp_dir]
+          cmd = cmd + ['-o', 'Dir::Etc::SourceParts=%s' % apt_sources_list_tmp_dir]
 
       cmd = cmd + [name]
       Logger.info("Installing package %s ('%s')" % (name, string_cmd_from_args_list(cmd)))
       self.checked_call_with_retries(cmd, sudo=True, env=INSTALL_CMD_ENV, logoutput=self.get_logoutput())
 
       if is_tmp_dir_created:
-        for temporal_sources_file in copied_sources_files:
-          Logger.info("Removing temporal sources file: %s" % temporal_sources_file)
-          os.remove(temporal_sources_file)
-        Logger.info("Removing temporal sources directory: %s" % apt_sources_list_tmp_dir)
+        for temporary_sources_file in copied_sources_files:
+          Logger.info("Removing temporary sources file: %s" % temporary_sources_file)
+          os.remove(temporary_sources_file)
+        Logger.info("Removing temporary sources directory: %s" % apt_sources_list_tmp_dir)
         os.rmdir(apt_sources_list_tmp_dir)
     else:
       Logger.info("Skipping installation of existing package %s" % (name))
       
+
   def is_locked_output(self, out):
     return "Unable to lock the administration directory" in out
 
@@ -381,7 +388,7 @@ class AptProvider(PackageProvider):
     return REPO_UPDATE_CMD
 
   @replace_underscores
-  def upgrade_package(self, name, use_repos=set(), skip_repos=set(), is_upgrade=True):
+  def upgrade_package(self, name, use_repos={}, skip_repos=set(), is_upgrade=True):
     return self.install_package(name, use_repos, skip_repos, is_upgrade)
 
   @replace_underscores

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/core/providers/package/choco.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/package/choco.py
b/ambari-common/src/main/python/resource_management/core/providers/package/choco.py
index 1bb6abf..19db787 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/package/choco.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/package/choco.py
@@ -46,11 +46,11 @@ CHECK_CMD = {
 }
 
 class ChocoProvider(PackageProvider):
-  def install_package(self, name, use_repos=[], skip_repos=[]):
+  def install_package(self, name, use_repos={}, skip_repos=[]):
     if not self._check_existence(name) or use_repos:
       cmd = INSTALL_CMD[self.get_logoutput()]
       if use_repos:
-        enable_repo_option = '-s' + ",".join(use_repos)
+        enable_repo_option = '-s' + ",".join(sorted(use_repos.keys()))
         cmd = cmd + [enable_repo_option]
       cmd = cmd + [name]
       cmdString = " ".join(cmd)
@@ -62,10 +62,10 @@ class ChocoProvider(PackageProvider):
     else:
       Logger.info("Skipping installation of existing package %s" % (name))
 
-  def upgrade_package(self, name, use_repos=[], skip_repos=[]):
+  def upgrade_package(self, name, use_repos={}, skip_repos=[]):
     cmd = UPGRADE_CMD[self.get_logoutput()]
     if use_repos:
-      enable_repo_option = '-s' + ",".join(use_repos)
+      enable_repo_option = '-s' + ",".join(sorted(use_repos.keys()))
       cmd = cmd + [enable_repo_option]
     cmd = cmd + [name]
     cmdString = " ".join(cmd)

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/core/providers/package/yumrpm.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/package/yumrpm.py
b/ambari-common/src/main/python/resource_management/core/providers/package/yumrpm.py
index 90b79ec..e54ac78 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/package/yumrpm.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/package/yumrpm.py
@@ -211,11 +211,11 @@ class YumProvider(RPMBasedPackageProvider):
 
     return True
 
-  def install_package(self, name, use_repos=set(), skip_repos=set(), is_upgrade=False):
+  def install_package(self, name, use_repos={}, skip_repos=set(), is_upgrade=False):
     if is_upgrade or use_repos or not self._check_existence(name):
       cmd = INSTALL_CMD[self.get_logoutput()]
       if use_repos:
-        enable_repo_option = '--enablerepo=' + ",".join(use_repos)
+        enable_repo_option = '--enablerepo=' + ",".join(sorted(use_repos.keys()))
         disable_repo_option = '--disablerepo=' + "*" if len(skip_repos) == 0 else ','.join(skip_repos)
         cmd = cmd + [disable_repo_option, enable_repo_option]
       cmd = cmd + [name]
@@ -224,7 +224,7 @@ class YumProvider(RPMBasedPackageProvider):
     else:
       Logger.info("Skipping installation of existing package %s" % (name))
 
-  def upgrade_package(self, name, use_repos=set(), skip_repos=set(), is_upgrade=True):
+  def upgrade_package(self, name, use_repos={}, skip_repos=set(), is_upgrade=True):
     return self.install_package(name, use_repos, skip_repos, is_upgrade)
 
   def remove_package(self, name, ignore_dependencies=False):
@@ -321,4 +321,4 @@ class YumProvider(RPMBasedPackageProvider):
           if mirror in mirrors:
             repo_ids.append(section)
 
-    return set(repo_ids)
\ No newline at end of file
+    return set(repo_ids)

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/core/providers/package/zypper.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/package/zypper.py
b/ambari-common/src/main/python/resource_management/core/providers/package/zypper.py
index 1e5fb90..21769a5 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/package/zypper.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/package/zypper.py
@@ -179,9 +179,10 @@ class ZypperProvider(RPMBasedPackageProvider):
 
     return True
 
-  def install_package(self, name, use_repos=[], skip_repos=[], is_upgrade=False):
+  def install_package(self, name, use_repos={}, skip_repos=[], is_upgrade=False):
     if is_upgrade or use_repos or not self._check_existence(name):
       cmd = INSTALL_CMD[self.get_logoutput()]
+      use_repos = use_repos.keys()
       if use_repos:
         active_base_repos = self.get_active_base_repos()
         if 'base' in use_repos:
@@ -189,7 +190,7 @@ class ZypperProvider(RPMBasedPackageProvider):
           use_repos = filter(lambda x: x != 'base', use_repos)
           use_repos.extend(active_base_repos)
         use_repos_options = []
-        for repo in use_repos:
+        for repo in sorted(use_repos):
           use_repos_options = use_repos_options + ['--repo', repo]
         cmd = cmd + use_repos_options
 
@@ -199,7 +200,7 @@ class ZypperProvider(RPMBasedPackageProvider):
     else:
       Logger.info("Skipping installation of existing package %s" % (name))
 
-  def upgrade_package(self, name, use_repos=[], skip_repos=[], is_upgrade=True):
+  def upgrade_package(self, name, use_repos={}, skip_repos=[], is_upgrade=True):
     return self.install_package(name, use_repos, skip_repos, is_upgrade)
   
   def remove_package(self, name, ignore_dependencies = False):

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/core/resources/packaging.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/resources/packaging.py
b/ambari-common/src/main/python/resource_management/core/resources/packaging.py
index 5febdae..e66044c 100644
--- a/ambari-common/src/main/python/resource_management/core/resources/packaging.py
+++ b/ambari-common/src/main/python/resource_management/core/resources/packaging.py
@@ -30,9 +30,19 @@ class Package(Resource):
   package_name = ResourceArgument(default=lambda obj: obj.name)
   location = ResourceArgument(default=lambda obj: obj.package_name)
 
-  # Allow using only specific list of repositories when performing action
-  use_repos = ResourceArgument(default=[])
+  """
+  Dictionary of repositories (repo ID => repo file name) to allow using
+  only a specific list of repositories when performing action.
+  (APT requires repo file names while other providers can filter by repo ID,
+  hence the need to pass both.)
+  """
+  use_repos = ResourceArgument(default={})
+
+  """
+  List of repositories to avoid using (currently only respected by YUM provider)
+  """
   skip_repos = ResourceArgument(default=[])
+
   """
   True           -  log it in INFO mode
   False          -  never log it

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
b/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
index b2f65d8..22249d1 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
@@ -33,7 +33,7 @@ def create_repo_files(template, command_repository):
   """
   Creates repositories in a consistent manner for all types
   :param command_repository: a CommandRepository instance
-  :return:
+  :return: a dictionary with repo ID => repo file name mapping
   """
 
   if command_repository.version_id is None:
@@ -43,7 +43,7 @@ def create_repo_files(template, command_repository):
     Logger.warning(
       "Repository for {0}/{1} has no repositories.  Ambari may not be managing this version.".format(
         command_repository.stack_name, command_repository.version_string))
-    return
+    return {}
 
   # add the stack name to the file name just to make it a little easier to debug
   # version_id is the primary id of the repo_version table in the database
@@ -51,6 +51,7 @@ def create_repo_files(template, command_repository):
                                       command_repository.version_id)
 
   append_to_file = False  # initialize to False to create the file anew.
+  repo_files = {}
 
   for repository in command_repository.repositories:
 
@@ -71,6 +72,9 @@ def create_repo_files(template, command_repository):
                  components = repository.ubuntu_components,
                  append_to_file = append_to_file)
       append_to_file = True
+      repo_files[repository.repo_id] = file_name
+
+  return repo_files
 
 
 def _find_value(dictionary, key):

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/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 0ef7dab..e71d078 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
@@ -58,6 +58,8 @@ class InstallPackages(Script):
     super(InstallPackages, self).__init__()
 
     self.pkg_provider = get_provider("Package")
+    self.repo_files = {}
+
 
   def actionexecute(self, env):
     num_errors = 0
@@ -110,7 +112,8 @@ class InstallPackages(Script):
       else:
         Logger.info(
           "Will install packages for repository version {0}".format(self.repository_version))
-        create_repo_files(template, command_repository)
+        new_repo_files = create_repo_files(template, command_repository)
+        self.repo_files.update(new_repo_files)
     except Exception, err:
       Logger.logger.exception("Cannot install repository files. Error: {0}".format(str(err)))
       num_errors += 1
@@ -328,9 +331,14 @@ class InstallPackages(Script):
       # patches installed
       repositories = config['repositoryFile']['repositories']
       repository_ids = [repository['repoId'] for repository in repositories]
+      repos_to_use = {}
+      for repo_id in repository_ids:
+        if repo_id in self.repo_files:
+          repos_to_use[repo_id] = self.repo_files[repo_id]
+
       Package(stack_selector_package,
         action="upgrade",
-        use_repos=repository_ids,
+        use_repos=repos_to_use,
         retry_on_repo_unavailability=agent_stack_retry_on_unavailability,
         retry_count=agent_stack_retry_count)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f1eaa650/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 0f303be..3a2fc98 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -109,6 +109,8 @@ class TestInstallPackages(RMFTestCase):
       lookup_packages.side_effect = TestInstallPackages._add_packages_lookUpYum
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value=[]
+      repo_file_name = 'ambari-hdp-1'
+      use_repos = { 'HDP-UTILS-1.1.0.20': repo_file_name, 'HDP-2.2': repo_file_name }
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -126,7 +128,7 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP-UTILS', 'main'],
                                 repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=False,
       )
@@ -135,11 +137,11 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP', 'main'],
                                 repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=True,
       )
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=['HDP-UTILS-1.1.0.20',
'HDP-2.2'], retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=use_repos,
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy-devel', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
@@ -190,7 +192,7 @@ class TestInstallPackages(RMFTestCase):
                          'repository_version_id': 1,
                          'actual_version': VERSION_STUB})
 
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=[],
retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos={},
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', None, action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy-devel', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
@@ -224,6 +226,8 @@ class TestInstallPackages(RMFTestCase):
       lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value=[]
+      repo_file_name = 'ambari-hdp-1'
+      use_repos = { 'HDP-UTILS-1.1.0.20': repo_file_name, 'HDP-2.2': repo_file_name }
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -241,7 +245,7 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP-UTILS', 'main'],
                                 repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=False,
                                 )
@@ -250,11 +254,11 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=True,
                                 )
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=['HDP-UTILS-1.1.0.20',
'HDP-2.2'], retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=use_repos,
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy-devel', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
@@ -289,6 +293,8 @@ class TestInstallPackages(RMFTestCase):
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value=["HDP-UTILS-2.2.0.1-885"]
       is_redhat_family_mock.return_value = True
+      repo_file_name = 'ambari-hdp-1'
+      use_repos = { 'HDP-UTILS-1.1.0.20': repo_file_name, 'HDP-2.2': repo_file_name }
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -306,7 +312,7 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP-UTILS', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name='ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=False,
       )
@@ -315,11 +321,11 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=True,
       )
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=['HDP-UTILS-1.1.0.20',
'HDP-2.2'], retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=use_repos,
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy-devel', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
@@ -434,6 +440,8 @@ class TestInstallPackages(RMFTestCase):
 
       get_provider.return_value = provider
       is_suse_family_mock.return_value = True
+      repo_file_name = 'ambari-hdp-1'
+      use_repos = { 'HDP-UTILS-1.1.0.20': repo_file_name, 'HDP-2.2': repo_file_name }
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -451,7 +459,7 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP-UTILS', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=False,
                                 )
@@ -460,11 +468,11 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-1',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=True,
                                 )
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=['HDP-UTILS-1.1.0.20',
'HDP-2.2'], retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=use_repos,
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy-devel', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
@@ -509,6 +517,8 @@ class TestInstallPackages(RMFTestCase):
 
       command_json['repositoryFile']['repoVersion'] = '2.2.0.1-990'
 
+      repo_file_name = 'ambari-hdp-4'
+      use_repos = { 'HDP-UTILS-1.1.0.20-repo-4': repo_file_name, 'HDP-2.2-repo-4': repo_file_name
}
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -526,7 +536,7 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP-UTILS', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-4',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=False,
                                 )
@@ -535,11 +545,11 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP', 'main'],
                                 repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-4',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=True,
                                 )
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=['HDP-UTILS-1.1.0.20-repo-4',
'HDP-2.2-repo-4'], retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=use_repos,
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
                                 retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
@@ -1146,6 +1156,8 @@ class TestInstallPackages(RMFTestCase):
       lookup_packages.side_effect = TestInstallPackages._add_packages_lookUpYum
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value=[]
+      repo_file_name = 'ambari-hdp-4'
+      use_repos = { 'HDP-UTILS-1.1.0.20-repo-4': repo_file_name, 'HDP-2.2-repo-4': repo_file_name
}
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -1164,7 +1176,7 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP-UTILS', 'main'],
                                 repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-4',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=False,
       )
@@ -1173,11 +1185,11 @@ class TestInstallPackages(RMFTestCase):
                                 action=['create'],
                                 components=[u'HDP', 'main'],
                                 repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
-                                repo_file_name=u'ambari-hdp-4',
+                                repo_file_name=repo_file_name,
                                 mirror_list=None,
                                 append_to_file=True,
       )
-      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=['HDP-UTILS-1.1.0.20-repo-4',
'HDP-2.2-repo-4'], retry_count=5, retry_on_repo_unavailability=False)
+      self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], use_repos=use_repos,
retry_count=5, retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
                                 retry_on_repo_unavailability=False)
       self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)


Mime
View raw message