Repository: ambari
Updated Branches:
  refs/heads/trunk 47626bd65 -> 02bea739b


AMBARI-5194. mprove User Experience during install - iptables warning. (Scott 
Creeley via mahadev)


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

Branch: refs/heads/trunk
Commit: 02bea739bcc217980f9cb793b74ca0efd81b6b75
Parents: 47626bd
Author: Mahadev Konar <[email protected]>
Authored: Wed Apr 9 16:20:17 2014 -0700
Committer: Mahadev Konar <[email protected]>
Committed: Wed Apr 9 16:20:17 2014 -0700

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/HostInfo.py   | 12 +++++++-----
 .../src/test/python/ambari_agent/TestHostInfo.py        |  9 ++++-----
 2 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/02bea739/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py 
b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 725f24f..8e0cf90 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -126,6 +126,7 @@ class HostInfo:
     self.packages = PackagesAnalyzer()
     self.reportFileHandler = HostCheckReportFileHandler(config)
 
+
   def dirType(self, path):
     if not os.path.exists(path):
       return 'not_exist'
@@ -280,18 +281,19 @@ class HostInfo:
 
 
   def checkIptables(self):
-    iptablesIsRunning = False
+    iptablesIsRunning = True
     try:
-      iptables = subprocess.Popen(self.FIREWALL_STATUS_CMD.split(), 
stdout=subprocess.PIPE)
-      iptables.communicate()
-      if iptables.returncode == 0:
-        iptablesIsRunning = True
+      iptables = subprocess.Popen(["iptables", "-S"], stdout=subprocess.PIPE)
+      stdout = iptables.communicate()
+      if stdout == ('-P INPUT ACCEPT\n-P FORWARD ACCEPT\n-P OUTPUT ACCEPT\n', 
None):
+        iptablesIsRunning = False
     except:
       pass
     return iptablesIsRunning
 
 
 
+
   """ Return various details about the host
   componentsMapped: indicates if any components are mapped to this host
   commandsInProgress: indicates if any commands are in progress

http://git-wip-us.apache.org/repos/asf/ambari/blob/02bea739/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py 
b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
index e76ccc4..627261d 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
@@ -515,16 +515,15 @@ class TestHostInfo(TestCase):
   def test_checkIptables(self, subproc_popen_mock):
     hostInfo = HostInfo()
     p = MagicMock()
-    p.returncode = 0
+
     subproc_popen_mock.return_value = p
+    
     result = hostInfo.checkIptables()
+    self.assertTrue(result == True)
 
-    self.assertTrue(result)
-
-    p.returncode = 1
     result = hostInfo.checkIptables()
+    self.assertFalse(result == False)
 
-    self.assertFalse(result)
 
 
 if __name__ == "__main__":

Reply via email to