ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-7724 Use versioned packages for Ubuntu for HDP 2.2 stack (dsen)
Date Fri, 10 Oct 2014 17:03:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 55b60c4d4 -> 605852aa5


AMBARI-7724 Use versioned packages for Ubuntu for HDP 2.2 stack (dsen)


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

Branch: refs/heads/branch-1.7.0
Commit: 605852aa5c719f6cd6eab50536d518dd1125f758
Parents: 55b60c4
Author: Dmytro Sen <dsen@hortonworks.com>
Authored: Fri Oct 10 20:03:51 2014 +0300
Committer: Dmytro Sen <dsen@hortonworks.com>
Committed: Fri Oct 10 20:03:51 2014 +0300

----------------------------------------------------------------------
 .../resource_management/TestPackageResource.py  | 20 +++++++++++++++-----
 .../core/providers/package/apt.py               | 12 ++++++++++++
 .../scripts/shared_initialization.py            |  2 +-
 3 files changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/605852aa/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 1b0e7d2..a28eb2d 100644
--- a/ambari-agent/src/test/python/resource_management/TestPackageResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestPackageResource.py
@@ -24,6 +24,7 @@ from resource_management.core.system import System
 from resource_management.core.resources import Package
 
 from resource_management.core import shell
+from resource_management.core.providers.package.apt import replace_underscores
 
 class TestPackageResource(TestCase):
   @patch.object(shell, "call")
@@ -34,13 +35,13 @@ class TestPackageResource(TestCase):
     with Environment('/') as env:
       Package("some_package",
       )
-    call_mock.assert_has_calls([call("dpkg --get-selections some_package | grep -v deinstall"),
+    call_mock.assert_has_calls([call("dpkg --get-selections some-package | grep -v deinstall"),
                                 call("DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get -q
-o Dpkg::Options::='--force-confdef'"
-                                      " --allow-unauthenticated --assume-yes install some_package"),
+                                      " --allow-unauthenticated --assume-yes install some-package"),
                                 call("apt-get update -qq")
                               ])
     
-    shell_mock.assert_has_calls([call("DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get -q
-o Dpkg::Options::='--force-confdef' --allow-unauthenticated --assume-yes install some_package")
+    shell_mock.assert_has_calls([call("DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get -q
-o Dpkg::Options::='--force-confdef' --allow-unauthenticated --assume-yes install some-package")
                               ])
   
   @patch.object(shell, "call")
@@ -51,9 +52,9 @@ class TestPackageResource(TestCase):
     with Environment('/') as env:
       Package("some_package",
       )
-    call_mock.assert_has_calls([call("dpkg --get-selections some_package | grep -v deinstall"),
+    call_mock.assert_has_calls([call("dpkg --get-selections some-package | grep -v deinstall"),
                                 call("DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get -q
-o Dpkg::Options::='--force-confdef'"
-                                      " --allow-unauthenticated --assume-yes install some_package")
+                                      " --allow-unauthenticated --assume-yes install some-package")
                               ])
     
     self.assertEqual(shell_mock.call_count, 0, "shell.checked_call shouldn't be called")
@@ -129,3 +130,12 @@ class TestPackageResource(TestCase):
               version = "3.5.0"
       )
     shell_mock.assert_called_with("/usr/bin/yum -d 0 -e 0 -y install some_package-3.5.0")
+
+  @replace_underscores
+  def func_to_test(self, name):
+    return name
+
+  def testReplaceUnderscore(self):
+    self.assertEqual("-", self.func_to_test("_"))
+    self.assertEqual("hadoop-x-x-x-*", self.func_to_test("hadoop_x_x_x-*"))
+    self.assertEqual("hadoop", self.func_to_test("hadoop"))

http://git-wip-us.apache.org/repos/asf/ambari/blob/605852aa/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 f001f14..19786dd 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
@@ -28,7 +28,16 @@ REPO_UPDATE_CMD = "apt-get update -qq"
 REMOVE_CMD = "/usr/bin/apt-get -y -q remove %s"
 CHECK_CMD = "dpkg --get-selections %s | grep -v deinstall"
 
+def replace_underscores(function_to_decorate):
+  def wrapper(*args):
+    self = args[0]
+    name = args[1].replace("_", "-")
+    return function_to_decorate(self, name)
+  return wrapper
+
 class AptProvider(PackageProvider):
+
+  @replace_underscores
   def install_package(self, name):
     if not self._check_existence(name):
       cmd = INSTALL_CMD % (name)
@@ -49,9 +58,11 @@ class AptProvider(PackageProvider):
     else:
       Logger.info("Skipping installing existent package %s" % (name))
 
+  @replace_underscores
   def upgrade_package(self, name):
     return self.install_package(name)
 
+  @replace_underscores
   def remove_package(self, name):
     if self._check_existence(name):
       cmd = REMOVE_CMD % (name)
@@ -60,6 +71,7 @@ class AptProvider(PackageProvider):
     else:
       Logger.info("Skipping removing non-existent package %s" % (name))
 
+  @replace_underscores
   def _check_existence(self, name):
     code, out = shell.call(CHECK_CMD % name)
     return not bool(code)

http://git-wip-us.apache.org/repos/asf/ambari/blob/605852aa/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
index 064356a..9f9345d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
@@ -22,7 +22,7 @@ from resource_management import *
 def setup_hdp_install_directory():
   import params
   if params.rpm_version:
-    Execute(format('hdp-select set all `hdp-select versions | grep ^{rpm_version}- | tail
-1`')
+    Execute(format('ambari-python-wrap /usr/bin/hdp-select set all `ambari-python-wrap /usr/bin/hdp-select
versions | grep ^{rpm_version}- | tail -1`')
     )
 
 def setup_config():


Mime
View raw message