ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [1/2] git commit: AMBARI-8044. Alerts are present on host after enabling maintenance mode - post fixes 2 (dlysnichenko)
Date Thu, 30 Oct 2014 16:17:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 713510f43 -> ce051947e
  refs/heads/trunk bff65d160 -> df98ca9e4


AMBARI-8044. Alerts are present on host after enabling maintenance mode - post fixes 2 (dlysnichenko)


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

Branch: refs/heads/branch-1.7.0
Commit: ce051947e4aa07ac3f8d053996f72d6594885a28
Parents: 713510f
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Oct 30 18:16:27 2014 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Oct 30 18:16:27 2014 +0200

----------------------------------------------------------------------
 .../services/NAGIOS/package/files/mm_wrapper.py | 25 +++++++++++++-------
 .../stacks/1.3.2/NAGIOS/test_mm_wrapper.py      |  6 ++---
 2 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ce051947/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/NAGIOS/package/files/mm_wrapper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/NAGIOS/package/files/mm_wrapper.py
b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/NAGIOS/package/files/mm_wrapper.py
index b1b6a84..bd7a94f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/NAGIOS/package/files/mm_wrapper.py
+++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/services/NAGIOS/package/files/mm_wrapper.py
@@ -44,18 +44,23 @@ def ignored_host_list(service, component):
   :param component: current component
   :return: all hosts where specified host component is in ignored state
   """
+  def str_norm(s):
+    return s.strip().upper()
+
+  result = []
+
   try:
-    with open(IGNORE_DAT_FILE) as f:
-      lines = f.readlines()
+    with open(IGNORE_DAT_FILE, 'r') as f:
+      lines = filter(None, f.read().split(os.linesep))
   except IOError:
-    return []
-  result = []
+    return result
+
   if lines:
     for l in lines:
       tokens = l.split(' ')
-      if len(tokens) == 3 and tokens[1].strip().upper() == service.strip().upper() and \
-        tokens[2].strip().upper() == component.strip().upper():
-          result.append(tokens[0])
+      if len(tokens) == 3 and str_norm(tokens[1]) == str_norm(service) \
+          and str_norm(tokens[2]) == str_norm(component):
+        result.append(tokens[0])
   return result
 
 
@@ -133,7 +138,11 @@ def parse_args(args):
     for arg in args:
       if not passed_separator:
         if arg != LIST_SEPARATOR:
-          hostnames.append(arg)
+          #check if was passed list of hosts instead of one
+          if ',' in arg:
+            hostnames += arg.split(',')
+          else:
+            hostnames.append(arg)
         else:
           passed_separator = True
       else:

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce051947/ambari-server/src/test/python/stacks/1.3.2/NAGIOS/test_mm_wrapper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/1.3.2/NAGIOS/test_mm_wrapper.py b/ambari-server/src/test/python/stacks/1.3.2/NAGIOS/test_mm_wrapper.py
index 04869a4..a75e92a 100644
--- a/ambari-server/src/test/python/stacks/1.3.2/NAGIOS/test_mm_wrapper.py
+++ b/ambari-server/src/test/python/stacks/1.3.2/NAGIOS/test_mm_wrapper.py
@@ -73,15 +73,15 @@ vm-3.vm ZOOKEEPER ZOOKEEPER_SERVER
   @patch("__builtin__.open")
   def test_ignored_host_list(self, open_mock):
     # Check with empty file content
-    open_mock.return_value.__enter__.return_value.readlines.return_value = []
+    open_mock.return_value.__enter__.return_value.read.return_value = ""
     lst = mm_wrapper.ignored_host_list('STORM', 'SUPERVISOR')
     self.assertEqual(pprint.pformat(lst), '[]')
     # Check with dummy content
-    open_mock.return_value.__enter__.return_value.readlines.return_value = self.dummy_ignore_file.splitlines()
+    open_mock.return_value.__enter__.return_value.read.return_value = self.dummy_ignore_file
     lst = mm_wrapper.ignored_host_list('STORM', 'SUPERVISOR')
     self.assertEqual(pprint.pformat(lst), "['vm-4.vm', 'vm-3.vm']")
     # Check if service name/comp name are not defined
-    open_mock.return_value.__enter__.return_value.readlines.return_value = self.dummy_ignore_file.splitlines()
+    open_mock.return_value.__enter__.return_value.read.return_value = self.dummy_ignore_file
     lst = mm_wrapper.ignored_host_list('', '')
     self.assertEqual(pprint.pformat(lst), "[]")
 


Mime
View raw message