[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Naparuba naparuba at gmail.com
Tue Feb 28 22:18:08 UTC 2012


The following commit has been merged in the debian/master branch:
commit 9ae1db696704937ddff349460bdbce3fe8f49a22
Author: Naparuba <naparuba at gmail.com>
Date:   Fri Feb 3 09:32:05 2012 +0100

    Fix : (reported by: Landry MINOZA) status.dat and regenerator got problem with pure notif ways contacts.

diff --git a/shinken/misc/regenerator.py b/shinken/misc/regenerator.py
index 62578b2..5e86a75 100644
--- a/shinken/misc/regenerator.py
+++ b/shinken/misc/regenerator.py
@@ -265,7 +265,7 @@ class Regenerator(object):
             new_exclude = []
             for ex in tp.exclude:
                 exname = ex.timeperiod_name
-                t = self.timeperiods(exname)
+                t = self.timeperiods.find_by_name(exname)
                 if t:
                     new_exclude.append(t)
             tp.exclude = new_exclude
diff --git a/shinken/modules/status_dat_broker/objectscache.py b/shinken/modules/status_dat_broker/objectscache.py
index 641a051..fd30dbc 100644
--- a/shinken/modules/status_dat_broker/objectscache.py
+++ b/shinken/modules/status_dat_broker/objectscache.py
@@ -119,14 +119,14 @@ class ObjectsCacheFile:
         Contact : {
             'contact_name' : {'required' : True, 'default' : '0'},
             'alias' : {'required' : False, 'default' : '0'},
-            'host_notifications_enabled' : {'required' : True, 'depythonize' : from_bool_to_string},
-            'service_notifications_enabled' : {'required' : True, 'depythonize' : from_bool_to_string},
-            'host_notification_period' : {'required' : True, 'depythonize' : 'get_name'},
-            'service_notification_period' : {'required' : True, 'depythonize' : 'get_name'},
-            'host_notification_options' : {'required' : True, 'depythonize' : from_list_to_split, 'default' : 'd,u,r,f,s,n'},
-            'service_notification_options' : {'required' : True, 'depythonize' : from_list_to_split, 'default' : 'w,u,c,r,f,s,n'},
-            'host_notification_commands' : {'required' : True, 'depythonize' : 'call'},
-            'service_notification_commands' : {'required' : True, 'depythonize' : 'call'},
+            'host_notifications_enabled' : {'required' : True},
+            'service_notifications_enabled' : {'required' : True},
+            'host_notification_period' : {'required' : True},
+            'service_notification_period' : {'required' : True},
+            'host_notification_options' : {'required' : True},
+            'service_notification_options' : {'required' : True},
+            'host_notification_commands' : {'required' : True},
+            'service_notification_commands' : {'required' : True},
             'email' : {'required' : False},
             'pager' : {'required' : False},
             'address1' : {'required' : False},
@@ -266,10 +266,6 @@ class ObjectsCacheFile:
                                 value = ','.join(['%s' % y for x in value if isinstance(x, list) for y in x] + \
                                     ['%s' % x for x in value if not isinstance(x, list)])
                             else:
-                                #ok not a direct function, maybe a functin provided by value...
-                                # DBG : lmimoza
-                                if not hasattr(value, f):
-                                    print "DBG"*10, "object", value, type(value), 'is missing', f
                                 f = getattr(value, f)
                                 if callable(f):
                                     value = f()
diff --git a/shinken/modules/status_dat_broker/status.py b/shinken/modules/status_dat_broker/status.py
index 04a6d71..010d9a1 100644
--- a/shinken/modules/status_dat_broker/status.py
+++ b/shinken/modules/status_dat_broker/status.py
@@ -145,8 +145,8 @@ class StatusFile:
             'modified_attributes' : {'prop' : None, 'default' : '0'},
             'modified_host_attributes' : {'prop' : None, 'default' : '0'},
             'modified_service_attributes' : {'prop' : None, 'default' : '0'},
-            'host_notification_period' : {'depythonize' : 'get_name'},
-            'service_notification_period' : {'depythonize' : 'get_name'},
+            'host_notification_period' : {},
+            'service_notification_period' : {},
             'last_host_notification' : {'prop' : None, 'default' : '0'},
             'last_service_notification' : {'prop' : None, 'default' : '0'},
             'host_notifications_enabled' : {'depythonize' : from_bool_to_string},
diff --git a/shinken/modules/status_dat_broker/status_dat_broker.py b/shinken/modules/status_dat_broker/status_dat_broker.py
index e65922a..5e355a7 100644
--- a/shinken/modules/status_dat_broker/status_dat_broker.py
+++ b/shinken/modules/status_dat_broker/status_dat_broker.py
@@ -28,6 +28,7 @@ import os
 import Queue
 
 #And now include from this global directory
+from shinken.objects import *
 from shinken.objects import Host
 from shinken.objects import Hostgroup
 from shinken.objects import Service
diff --git a/shinken/objects/contact.py b/shinken/objects/contact.py
index b0f0837..349688b 100644
--- a/shinken/objects/contact.py
+++ b/shinken/objects/contact.py
@@ -24,7 +24,7 @@
 from item import Item, Items
 
 from shinken.util import strip_and_uniq
-from shinken.property import BoolProp, IntegerProp, StringProp, ListProp
+from shinken.property import BoolProp, IntegerProp, StringProp
 from shinken.log import logger
 
 
@@ -52,8 +52,8 @@ class Contact(Item):
         'service_notifications_enabled': BoolProp(default='1', fill_brok=['full_status']),
         'host_notification_period': StringProp(fill_brok=['full_status']),
         'service_notification_period': StringProp(fill_brok=['full_status']),
-        'host_notification_options': ListProp(fill_brok=['full_status']),
-        'service_notification_options': ListProp(fill_brok=['full_status']),
+        'host_notification_options': StringProp(fill_brok=['full_status']),
+        'service_notification_options': StringProp(fill_brok=['full_status']),
         'host_notification_commands': StringProp(fill_brok=['full_status']),
         'service_notification_commands': StringProp(fill_brok=['full_status']),
         'min_business_impact':    IntegerProp(default = '0', fill_brok=['full_status']),
@@ -189,6 +189,7 @@ class Contact(Item):
         else:
             if hasattr(self, 'alias'): #take the alias if we miss the contact_name
                 self.contact_name = self.alias
+
         return state
 
 
@@ -216,10 +217,10 @@ class Contacts(Items):
     inner_class = Contact
 
     def linkify(self, timeperiods, commands, notificationways):
-        self.linkify_with_timeperiods(timeperiods, 'service_notification_period')
-        self.linkify_with_timeperiods(timeperiods, 'host_notification_period')
-        self.linkify_command_list_with_commands(commands, 'service_notification_commands')
-        self.linkify_command_list_with_commands(commands, 'host_notification_commands')
+        #self.linkify_with_timeperiods(timeperiods, 'service_notification_period')
+        #self.linkify_with_timeperiods(timeperiods, 'host_notification_period')
+        #self.linkify_command_list_with_commands(commands, 'service_notification_commands')
+        #self.linkify_command_list_with_commands(commands, 'host_notification_commands')
         self.linkify_with_notificationways(notificationways)
 
     #We've got a notificationways property with , separated contacts names
@@ -251,8 +252,8 @@ class Contacts(Items):
             for cg in c.contactgroups.split(','):
                 contactgroups.add_member(c.contact_name, cg.strip())
 
-        #Now create a notification way with the simple parameter of the
-        #contacts
+        # Now create a notification way with the simple parameter of the
+        # contacts
         for c in self:
             if not c.is_tpl():
                 need_notificationway = False
@@ -261,6 +262,10 @@ class Contacts(Items):
                     if hasattr(c, p):
                         need_notificationway = True
                         params[p] = getattr(c, p)
+                    else: # put a default text value
+                        # Remove the value and put a default value
+                        setattr(c, p, '')
+                    
 
                 if need_notificationway:
                     #print "Create notif way with", params
diff --git a/test/etc/nagios_1r_1h_1s.cfg b/test/etc/nagios_objects_and_notifways.cfg
similarity index 88%
copy from test/etc/nagios_1r_1h_1s.cfg
copy to test/etc/nagios_objects_and_notifways.cfg
index 1566c73..1b6d260 100644
--- a/test/etc/nagios_1r_1h_1s.cfg
+++ b/test/etc/nagios_objects_and_notifways.cfg
@@ -8,14 +8,14 @@ auto_rescheduling_interval=30
 auto_rescheduling_window=180
 cached_host_check_horizon=15
 cached_service_check_horizon=15
-cfg_file=1r_1h_1s/hosts.cfg
-cfg_file=1r_1h_1s/services.cfg
-cfg_file=1r_1h_1s/contacts.cfg
-cfg_file=1r_1h_1s/commands.cfg
-cfg_file=1r_1h_1s/timeperiods.cfg
-cfg_file=1r_1h_1s/hostgroups.cfg
-cfg_file=1r_1h_1s/servicegroups.cfg
-cfg_file=1r_1h_1s/shinken-specific.cfg
+cfg_file=objects_and_notifways/hosts.cfg
+cfg_file=objects_and_notifways/services.cfg
+cfg_file=objects_and_notifways/contacts.cfg
+cfg_file=objects_and_notifways/commands.cfg
+cfg_file=objects_and_notifways/timeperiods.cfg
+cfg_file=objects_and_notifways/hostgroups.cfg
+cfg_file=objects_and_notifways/servicegroups.cfg
+cfg_file=objects_and_notifways/shinken-specific.cfg
 check_external_commands=1
 check_for_orphaned_hosts=1
 check_for_orphaned_services=1
diff --git a/test/etc/1r_1h_1s/commands.cfg b/test/etc/objects_and_notifways/commands.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/commands.cfg
copy to test/etc/objects_and_notifways/commands.cfg
diff --git a/test/etc/notif_way/contacts.cfg b/test/etc/objects_and_notifways/contacts.cfg
similarity index 67%
copy from test/etc/notif_way/contacts.cfg
copy to test/etc/objects_and_notifways/contacts.cfg
index e75b44c..b5ec233 100644
--- a/test/etc/notif_way/contacts.cfg
+++ b/test/etc/objects_and_notifways/contacts.cfg
@@ -7,21 +7,10 @@ define contactgroup{
 define contact{
     contact_name                    test_contact
     alias                           test_contact_alias
-    email                           nobody at localhost
-    can_submit_commands             1
-    notificationways		    email_in_day,sms_the_night
-}
-
-
-define contact{
-    contact_name                    test_contact_simple
-    alias                           test_contact_simple
     service_notification_period     24x7
     host_notification_period        24x7
-#no w here, for tests
-    service_notification_options    u,c,r,f
-#and no flapping hehe
-    host_notification_options       d,u,r,s
+    service_notification_options    w,u,c,r,f
+    host_notification_options       d,u,r,f,s
     service_notification_commands   notify-service
     host_notification_commands      notify-host
     email                           nobody at localhost
@@ -30,9 +19,19 @@ define contact{
 
 
 
-#EMail the whole 24x7 is ok
+
+# And a contact with notif ways
+define contact{
+    contact_name                    test_contact_nw
+    alias                           test_contact_alias
+    email                           nobody at localhost
+    notificationways                email_in_day,sms_the_night
+}
+
+
+#Email the whole 24x7 is ok
 define notificationway{
-       notificationway_name	email_in_day
+       notificationway_name            email_in_day
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f
@@ -43,15 +42,11 @@ define notificationway{
 
 #But SMS only the night
 define notificationway{
-       notificationway_name     sms_the_night
+       notificationway_name            sms_the_night
        service_notification_period     night
        host_notification_period        night
-       service_notification_options    c
-       host_notification_options       d
+       service_notification_options    c   ; so only CRITICAL
+       host_notification_options       d   ; and DOWN
        service_notification_commands   notify-service-sms
        host_notification_commands      notify-host-sms
-       min_criticity		       5
-
-}
-
-
+}
\ No newline at end of file
diff --git a/test/etc/1r_1h_1s/hostgroups.cfg b/test/etc/objects_and_notifways/hostgroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hostgroups.cfg
copy to test/etc/objects_and_notifways/hostgroups.cfg
diff --git a/test/etc/1r_1h_1s/hosts.cfg b/test/etc/objects_and_notifways/hosts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hosts.cfg
copy to test/etc/objects_and_notifways/hosts.cfg
diff --git a/test/etc/1r_1h_1s/servicegroups.cfg b/test/etc/objects_and_notifways/servicegroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/servicegroups.cfg
copy to test/etc/objects_and_notifways/servicegroups.cfg
diff --git a/test/etc/1r_1h_1s/services.cfg b/test/etc/objects_and_notifways/services.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/services.cfg
copy to test/etc/objects_and_notifways/services.cfg
diff --git a/test/etc/1r_1h_1s/shinken-specific.cfg b/test/etc/objects_and_notifways/shinken-specific.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/shinken-specific.cfg
copy to test/etc/objects_and_notifways/shinken-specific.cfg
diff --git a/test/etc/10r_1000h_20000s/timeperiods.cfg b/test/etc/objects_and_notifways/timeperiods.cfg
similarity index 100%
copy from test/etc/10r_1000h_20000s/timeperiods.cfg
copy to test/etc/objects_and_notifways/timeperiods.cfg
diff --git a/test/etc/regenerator/timeperiods.cfg b/test/etc/regenerator/timeperiods.cfg
index bfdb9a8..2dcec2d 100644
--- a/test/etc/regenerator/timeperiods.cfg
+++ b/test/etc/regenerator/timeperiods.cfg
@@ -8,4 +8,12 @@ define timeperiod{
     thursday        00:00-24:00
     friday          00:00-24:00
     saturday        00:00-24:00
+    exclude	    none
+}
+
+
+
+define timeperiod{
+    timeperiod_name none
+    alias           none
 }
diff --git a/test/jenkins/longtests.txt b/test/jenkins/longtests.txt
index 4e7d407..558c9df 100644
--- a/test/jenkins/longtests.txt
+++ b/test/jenkins/longtests.txt
@@ -92,6 +92,7 @@ test_notif_too_much.py
 test_timeperiods_state_logs.py
 test_groups_with_no_alias.py
 test_define_with_space.py
+test_objects_and_notifways.py
 test_parse_perfdata.py
 
 # takes long
diff --git a/test/jenkins/shorttests.txt b/test/jenkins/shorttests.txt
index 081ffbb..fa11196 100644
--- a/test/jenkins/shorttests.txt
+++ b/test/jenkins/shorttests.txt
@@ -99,4 +99,5 @@ test_notif_too_much.py
 test_groups_with_no_alias.py
 test_timeperiods_state_logs.py
 test_define_with_space.py
+test_objects_and_notifways.py
 test_parse_perfdata.py
diff --git a/test/quick_tests.sh b/test/quick_tests.sh
index 0165bed..236b448 100755
--- a/test/quick_tests.sh
+++ b/test/quick_tests.sh
@@ -137,6 +137,7 @@ launch_and_assert test_groups_with_no_alias.py
 launch_and_assert test_notif_too_much.py
 launch_and_assert test_timeperiods_state_logs.py
 launch_and_assert test_define_with_space.py
+launch_and_assert test_objects_and_notifways.py
 
 launch_and_assert test_maintenance_period.py
 #Live status is a bit longer than the previous, so we put it at the end.
diff --git a/test/test_module_on_module.py b/test/test_objects_and_notifways.py
similarity index 58%
copy from test/test_module_on_module.py
copy to test/test_objects_and_notifways.py
index fa6e9be..736df0c 100755
--- a/test/test_module_on_module.py
+++ b/test/test_objects_and_notifways.py
@@ -26,30 +26,27 @@
 from shinken_test import *
 
 
-class TestModuleOnModule(ShinkenTest):
+class TestObjectsAndNotifWays(ShinkenTest):
     #Uncomment this is you want to use a specific configuration
     #for your test
     def setUp(self):
-        self.setup_with_file('etc/nagios_module_on_module.cfg')
+        self.setup_with_file('etc/nagios_objects_and_notifways.cfg')
 
     
-    #Change ME :)
-    def test_module_on_module(self):
-        #
-        # Config is not correct because of a wrong relative path
-        # in the main config file
-        #
-        print "Get the hosts and services"
-        now = time.time()
-        mod1 = self.sched.conf.modules.find_by_name("Simple-log")
-        self.assert_(mod1 is not None)
-        print "Got module", mod1.get_name()
-        mod_sub = self.sched.conf.modules.find_by_name("ToNdodb_Mysql")
-        self.assert_(mod_sub is not None)
-        print "Got sub module", mod_sub.get_name()
-        self.assert_(mod_sub in mod1.modules)
-        self.assert_(mod_sub.modules == [])
-
+    # We got strange "objects" for some contacts property when we are using notif ways
+    # and asking for  broks. Search why
+    def test_dummy(self):
+        c_normal = self.sched.contacts.find_by_name("test_contact")
+        self.assert_(c_normal is not None)
+        c_nw = self.sched.contacts.find_by_name("test_contact_nw")
+        self.assert_(c_nw is not None)
+
+        b = c_normal.get_initial_status_brok()
+        print "B normal", b
+        self.assert_(b.data['host_notification_options'] ==  u'd,u,r,f,s')
+        b2 = c_nw.get_initial_status_brok()
+        print "B nw", b2
+        self.assert_(b2.data['host_notification_options'] == u'')
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/test/test_regenerator.py b/test/test_regenerator.py
index 7d29e16..6bba036 100755
--- a/test/test_regenerator.py
+++ b/test/test_regenerator.py
@@ -124,6 +124,9 @@ class TestRegenerator(ShinkenTest):
 
         self.look_for_same_values()
 
+        
+
+        
 
 if __name__ == '__main__':
     unittest.main()

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list