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-8037. Alerts are present on host after enabling maintenance mode - post fixes (dlysnichenko)
Date Thu, 30 Oct 2014 15:33:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 2beca1023 -> 713510f43
  refs/heads/trunk cb2b446da -> bff65d160


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


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

Branch: refs/heads/trunk
Commit: bff65d1601bf9f472558aea7a3a3811af59e7a0d
Parents: cb2b446
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Oct 30 17:32:20 2014 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Oct 30 17:32:20 2014 +0200

----------------------------------------------------------------------
 .../services/NAGIOS/package/files/mm_wrapper.py | 26 ++++++++++++++------
 .../package/templates/hadoop-services.cfg.j2    |  2 +-
 .../stacks/2.0.6/NAGIOS/test_mm_wrapper.py      |  6 ++---
 3 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bff65d16/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/mm_wrapper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/mm_wrapper.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/mm_wrapper.py
index e9ea422..8923e6c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/mm_wrapper.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/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
 
 
@@ -121,6 +126,7 @@ def print_usage():
 
 
 def parse_args(args):
+  # ToDo: re-organize params parsing, possibly use standard python class for that?
   if not args or not LIST_SEPARATOR in args or args[0] not in MODES:
     print_usage()
   else:
@@ -133,7 +139,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/bff65d16/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
index 04423fb..0d8b2e8 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
@@ -444,7 +444,7 @@ define service {
 {% endif %}
 
 {% if hostgroup_defs['resourcemanager'] %}
-# YARN::RESOURCEMANAGER Checks 
+# YARN::RESOURCEMANAGER Checks
 define service {
         hostgroup_name          nagios-server
         use                     hadoop-service

http://git-wip-us.apache.org/repos/asf/ambari/blob/bff65d16/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_mm_wrapper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_mm_wrapper.py b/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_mm_wrapper.py
index 169fa70..ff556ce 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_mm_wrapper.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/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