ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [2/2] ambari git commit: AMBARI-17047. AMBARI-17047: Firewall check returns WARNING even if iptables and firewalld are stopped on CentOS7 (Masahiro Tanaka via aonishuk)
Date Tue, 12 Jul 2016 08:01:21 GMT
AMBARI-17047. AMBARI-17047: Firewall check returns WARNING even if iptables and firewalld are
stopped on CentOS7 (Masahiro Tanaka via aonishuk)


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

Branch: refs/heads/branch-2.4
Commit: 8294cc4fb3917d7fda5c585592dbb8a08ccd1e8b
Parents: 8c366c1
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Tue Jul 12 11:01:11 2016 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Tue Jul 12 11:01:11 2016 +0300

----------------------------------------------------------------------
 .../src/main/python/ambari_commons/firewall.py          | 12 ++++++++----
 ambari-server/src/test/python/TestAmbariServer.py       |  8 ++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8294cc4f/ambari-common/src/main/python/ambari_commons/firewall.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/firewall.py b/ambari-common/src/main/python/ambari_commons/firewall.py
index 72e6d26..6868d3f 100644
--- a/ambari-common/src/main/python/ambari_commons/firewall.py
+++ b/ambari-common/src/main/python/ambari_commons/firewall.py
@@ -21,7 +21,7 @@ limitations under the License.
 from ambari_commons import OSCheck, OSConst
 from ambari_commons.logging_utils import print_warning_msg
 from ambari_commons.os_family_impl import OsFamilyImpl
-from ambari_commons.os_utils import run_os_command, run_in_shell
+from ambari_commons.os_utils import run_os_command
 
 
 class Firewall(object):
@@ -120,13 +120,17 @@ class RedHat7FirewallChecks(FirewallChecks):
   #firewalld added to support default firewall (started from RHEL7/CentOS7)
   #script default iptables checked as user can use iptables as known from previous RHEL releases.
   def get_command(self):
-    return "%(servcmd)s is-active %(fwl1)s || %(servcmd)s is-active %(fwl2)s" % {"servcmd":self.SERVICE_CMD,"fwl1":"iptables",
"fwl2":"firewalld"}
+    return "%(servcmd)s is-active %(fwl1)s %(fwl2)s" % {"servcmd":self.SERVICE_CMD,"fwl1":"iptables",
"fwl2":"firewalld"}
 
   def check_result(self):
-    return self.returncode == 0
+    for line in self.stdoutdata.split("\n"):
+      if line.strip() == "active":
+        return True
+    return False
+
 
   def run_command(self):
-    retcode, out, err = run_in_shell(self.get_command())
+    retcode, out, err = run_os_command(self.get_command())
     self.returncode = retcode
     self.stdoutdata = out
     self.stderrdata = err

http://git-wip-us.apache.org/repos/asf/ambari/blob/8294cc4f/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 254aeb7..279a172 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -1934,9 +1934,17 @@ class TestAmbariServer(TestCase):
     get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
 
     firewall_obj = Firewall().getFirewallObject()
+    p.communicate.return_value = ("active\nactive", "err")
     p.returncode = 0
     self.assertEqual("RedHat7FirewallChecks", firewall_obj.__class__.__name__)
     self.assertTrue(firewall_obj.check_firewall())
+    p.communicate.return_value = ("inactive\nactive", "err")
+    p.returncode = 3
+    self.assertTrue(firewall_obj.check_firewall())
+    p.communicate.return_value = ("active\ninactive", "err")
+    p.returncode = 3
+    self.assertTrue(firewall_obj.check_firewall())
+    p.communicate.return_value = ("inactive\ninactive", "err")
     p.returncode = 3
     self.assertFalse(firewall_obj.check_firewall())
     self.assertEqual("err", firewall_obj.stderrdata)


Mime
View raw message