ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [1/2] ambari git commit: AMBARI-9050. Stack Advisor Exception During install (dlysnichenko)
Date Thu, 08 Jan 2015 19:49:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 76b7d3d46 -> eaa65facf


AMBARI-9050. Stack Advisor Exception During install (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 48aea274efedb325db8be9ce20124fb7a00d5408
Parents: 76b7d3d
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Jan 8 21:47:38 2015 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Jan 8 21:47:38 2015 +0200

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/Hardware.py       | 9 ++++++++-
 ambari-agent/src/test/python/ambari_agent/TestController.py | 3 +++
 ambari-agent/src/test/python/ambari_agent/TestHardware.py   | 3 ++-
 ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py  | 4 ++++
 .../src/test/python/ambari_agent/TestRegistration.py        | 2 ++
 5 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/main/python/ambari_agent/Hardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Hardware.py b/ambari-agent/src/main/python/ambari_agent/Hardware.py
index 7b8e501..ba53e12 100644
--- a/ambari-agent/src/main/python/ambari_agent/Hardware.py
+++ b/ambari-agent/src/main/python/ambari_agent/Hardware.py
@@ -78,13 +78,20 @@ class Hardware:
     lines = dfdata.splitlines()
     for l in lines:
       mountinfo = Hardware.extractMountInfo(l)
-      if mountinfo != None and os.access(mountinfo['mountpoint'], os.W_OK):
+      if mountinfo != None and Hardware._chk_mount(mountinfo['mountpoint']):
         mounts.append(mountinfo)
       pass
     pass
     return mounts
 
   @staticmethod
+  def _chk_mount(mountpoint):
+    if subprocess.call("sudo test -w '{0}'".format(mountpoint), shell=True) == 0:
+      return True
+    else:
+      return False
+
+  @staticmethod
   def _osdisks_win():
     mounts = []
     runner = shellRunner()

http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestController.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestController.py b/ambari-agent/src/test/python/ambari_agent/TestController.py
index 24d416a..92ce46f 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestController.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestController.py
@@ -41,6 +41,7 @@ with patch.object(OSCheck, "os_distribution", new = MagicMock(return_value
= os_
   from ambari_agent import hostname
   from ambari_agent.Controller import AGENT_AUTO_RESTART_EXIT_CODE
   from ambari_commons import OSCheck
+  from ambari_agent.Hardware import Hardware
   import ambari_commons
 
 @only_for_platform(PLATFORM_LINUX)
@@ -166,6 +167,7 @@ class TestController(unittest.TestCase):
 
 
 
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch("urllib2.build_opener")
   @patch("urllib2.install_opener")
   @patch.object(Controller, "ActionQueue")
@@ -204,6 +206,7 @@ class TestController(unittest.TestCase):
     self.assertTrue(aq.start.called)
 
 
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch("urllib2.build_opener")
   @patch("urllib2.install_opener")
   @patch.object(ActionQueue.ActionQueue, "run")

http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestHardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHardware.py b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
index 2a24d40..164417b 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHardware.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
@@ -19,7 +19,7 @@ limitations under the License.
 '''
 
 from unittest import TestCase
-from mock.mock import patch
+from mock.mock import patch, MagicMock
 import unittest
 import platform
 from only_for_platform import only_for_platform, PLATFORM_LINUX
@@ -33,6 +33,7 @@ with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
 @only_for_platform(PLATFORM_LINUX)
 @patch.object(platform,"linux_distribution", new = ('Suse','11','Final'))
 class TestHardware(TestCase):
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(OSCheck, "get_os_type")
   @patch.object(OSCheck, "get_os_version")
   def test_build(self, get_os_version_mock, get_os_type_mock):

http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
index 1145cd8..fc52c95 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
@@ -29,6 +29,7 @@ import sys
 
 
 with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
+  from ambari_agent.Hardware import Hardware
   from ambari_agent.Heartbeat import Heartbeat
   from ambari_agent.ActionQueue import ActionQueue
   from ambari_agent.LiveStatus import LiveStatus
@@ -75,6 +76,7 @@ class TestHeartbeat(TestCase):
     self.assertEquals(not heartbeat.reports, True, "Heartbeat should not contain task in
progress")
 
 
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(ActionQueue, "result")
   @patch.object(HostInfoLinux, "register")
   def test_no_mapping(self, register_mock, result_mock):
@@ -196,6 +198,7 @@ class TestHeartbeat(TestCase):
     self.assertEquals(hb, expected)
 
 
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(HostInfoLinux, 'register')
   def test_heartbeat_no_host_check_cmd_in_queue(self, register_mock):
     config = AmbariConfig.AmbariConfig().getConfig()
@@ -221,6 +224,7 @@ class TestHeartbeat(TestCase):
     self.assertFalse(args[1])
 
 
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(HostInfoLinux, 'register')
   def test_heartbeat_host_check_no_cmd(self, register_mock):
     config = AmbariConfig.AmbariConfig().getConfig()

http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index 676266f..41f9880 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -29,10 +29,12 @@ with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
   from ambari_agent.Register import Register
   from ambari_agent.AmbariConfig import AmbariConfig
   from ambari_commons import OSCheck, Firewall, FirewallChecks
+  from ambari_agent.Hardware import Hardware
 
 class TestRegistration(TestCase):
 
   @only_for_platform(PLATFORM_LINUX)
+  @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(FirewallChecks, "run_os_command")
   @patch.object(OSCheck, "get_os_type")
   @patch.object(OSCheck, "get_os_version")


Mime
View raw message