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

Naparuba naparuba at gmail.com
Tue Feb 28 22:16:04 UTC 2012


The following commit has been merged in the debian/master branch:
commit dd52334ca8fff28762861aa8949578cf4a8a2f19
Author: Naparuba <naparuba at gmail.com>
Date:   Tue Jan 24 09:12:38 2012 +0100

    Add : if missing alias in objects, put the name if available.

diff --git a/shinken/objects/item.py b/shinken/objects/item.py
index d788a4e..cbfd374 100644
--- a/shinken/objects/item.py
+++ b/shinken/objects/item.py
@@ -723,6 +723,12 @@ class Items(object):
 
         # Then look for individual ok
         for i in self:
+            # Alias hook
+            prop_name = getattr(self.__class__, 'name_property', None)
+            if prop_name and not hasattr(i, 'alias') and hasattr(i, prop_name):
+                setattr(i, 'alias', getattr(i, prop_name))
+
+            # Now other checks
             if not i.is_correct():
                 n = getattr(i, 'imported_from', "unknown source")
                 safe_print("Error: In", i.get_name(), "is incorrect ; from", n)
diff --git a/shinken/objects/itemgroup.py b/shinken/objects/itemgroup.py
index d5cb6db..c0c4301 100644
--- a/shinken/objects/itemgroup.py
+++ b/shinken/objects/itemgroup.py
@@ -115,8 +115,8 @@ class Itemgroup(Item):
         except ValueError:
             pass
 
-    #a item group is correct if all members actually exists,
-    #so if unknown_members is still []
+    # a item group is correct if all members actually exists,
+    # so if unknown_members is still []
     def is_correct(self):
         res = True
 
diff --git a/test/etc/1r_1h_1s/commands.cfg b/test/etc/groups_with_no_alias/commands.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/commands.cfg
copy to test/etc/groups_with_no_alias/commands.cfg
diff --git a/test/etc/1r_1h_1s/contacts.cfg b/test/etc/groups_with_no_alias/contacts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/contacts.cfg
copy to test/etc/groups_with_no_alias/contacts.cfg
diff --git a/test/etc/1r_1h_1s/hostgroups.cfg b/test/etc/groups_with_no_alias/hostgroups.cfg
similarity index 95%
copy from test/etc/1r_1h_1s/hostgroups.cfg
copy to test/etc/groups_with_no_alias/hostgroups.cfg
index d185548..fa52c9d 100644
--- a/test/etc/1r_1h_1s/hostgroups.cfg
+++ b/test/etc/groups_with_no_alias/hostgroups.cfg
@@ -60,3 +60,8 @@ define hostgroup {
     members                 test_router_0,test_host_0
 }
 
+
+
+define hostgroup {
+    hostgroup_name          NOALIAS
+}
diff --git a/test/etc/1r_1h_1s/hosts.cfg b/test/etc/groups_with_no_alias/hosts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hosts.cfg
copy to test/etc/groups_with_no_alias/hosts.cfg
diff --git a/test/etc/bad_escalation_on_groups/servicegroups.cfg b/test/etc/groups_with_no_alias/servicegroups.cfg
similarity index 95%
copy from test/etc/bad_escalation_on_groups/servicegroups.cfg
copy to test/etc/groups_with_no_alias/servicegroups.cfg
index 8357e3a..752c8c1 100644
--- a/test/etc/bad_escalation_on_groups/servicegroups.cfg
+++ b/test/etc/groups_with_no_alias/servicegroups.cfg
@@ -59,3 +59,8 @@ define servicegroup {
     servicegroup_name       flap
     alias                   All Flapping Services
 }
+
+
+define servicegroup {
+    servicegroup_name       NOALIAS
+}
diff --git a/test/etc/1r_1h_1s/services.cfg b/test/etc/groups_with_no_alias/services.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/services.cfg
copy to test/etc/groups_with_no_alias/services.cfg
diff --git a/test/etc/1r_1h_1s/shinken-specific.cfg b/test/etc/groups_with_no_alias/shinken-specific.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/shinken-specific.cfg
copy to test/etc/groups_with_no_alias/shinken-specific.cfg
diff --git a/test/etc/10r_1000h_20000s/timeperiods.cfg b/test/etc/groups_with_no_alias/timeperiods.cfg
similarity index 100%
copy from test/etc/10r_1000h_20000s/timeperiods.cfg
copy to test/etc/groups_with_no_alias/timeperiods.cfg
diff --git a/test/etc/nagios_1r_1h_1s.cfg b/test/etc/nagios_groups_with_no_alias.cfg
similarity index 88%
copy from test/etc/nagios_1r_1h_1s.cfg
copy to test/etc/nagios_groups_with_no_alias.cfg
index 1566c73..0a99e6b 100644
--- a/test/etc/nagios_1r_1h_1s.cfg
+++ b/test/etc/nagios_groups_with_no_alias.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=groups_with_no_alias/hosts.cfg
+cfg_file=groups_with_no_alias/services.cfg
+cfg_file=groups_with_no_alias/contacts.cfg
+cfg_file=groups_with_no_alias/commands.cfg
+cfg_file=groups_with_no_alias/timeperiods.cfg
+cfg_file=groups_with_no_alias/hostgroups.cfg
+cfg_file=groups_with_no_alias/servicegroups.cfg
+cfg_file=groups_with_no_alias/shinken-specific.cfg
 check_external_commands=1
 check_for_orphaned_hosts=1
 check_for_orphaned_services=1
diff --git a/test/jenkins/longtests.txt b/test/jenkins/longtests.txt
index 364eb15..3ab862d 100644
--- a/test/jenkins/longtests.txt
+++ b/test/jenkins/longtests.txt
@@ -89,6 +89,7 @@ test_dot_virg_in_command.py
 test_bad_escalation_on_groups.py
 test_no_host_template.py
 test_notif_too_much.py
+test_groups_with_no_alias.py
 test_parse_perfdata.py
 
 # takes long
diff --git a/test/jenkins/shorttests.txt b/test/jenkins/shorttests.txt
index 7166721..f317918 100644
--- a/test/jenkins/shorttests.txt
+++ b/test/jenkins/shorttests.txt
@@ -96,4 +96,5 @@ test_dot_virg_in_command.py
 test_bad_escalation_on_groups.py
 test_no_host_template.py
 test_notif_too_much.py
+test_groups_with_no_alias.py
 test_parse_perfdata.py
diff --git a/test/quick_tests.sh b/test/quick_tests.sh
index 0db5388..5e2174a 100755
--- a/test/quick_tests.sh
+++ b/test/quick_tests.sh
@@ -133,6 +133,7 @@ launch_and_assert test_module_ip_tag.py
 launch_and_assert test_dot_virg_in_command.py
 launch_and_assert test_bad_escalation_on_groups.py
 launch_and_assert test_no_host_template.py
+launch_and_assert test_groups_with_no_alias.py
 launch_and_assert test_notif_too_much.py
 
 launch_and_assert test_maintenance_period.py
diff --git a/test/test_no_host_template.py b/test/test_groups_with_no_alias.py
similarity index 72%
copy from test/test_no_host_template.py
copy to test/test_groups_with_no_alias.py
index c902d7b..dc64457 100755
--- a/test/test_no_host_template.py
+++ b/test/test_groups_with_no_alias.py
@@ -26,25 +26,31 @@
 from shinken_test import *
 
 
-class TestNoHostTemplate(ShinkenTest):
+class TestGroupwithNoAlias(ShinkenTest):
     #Uncomment this is you want to use a specific configuration
     #for your test
     def setUp(self):
-        self.setup_with_file('etc/nagios_no_host_template.cfg')
+        self.setup_with_file('etc/nagios_groups_with_no_alias.cfg')
 
     
     #Change ME :)
-    def test_host_without_a_template(self):
+    def test_look_for_alias(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()
-        host = self.sched.hosts.find_by_name("my_host")
-        b = host.is_correct()
-        self.assert_(b)
-
+        hg = self.sched.hostgroups.find_by_name("NOALIAS")
+        self.assert_(hg is not None)
+        print hg.__dict__
+        self.assert_(hg.alias == "NOALIAS")
+
+        sg = self.sched.servicegroups.find_by_name("NOALIAS")
+        self.assert_(sg is not None)
+        print sg.__dict__
+        self.assert_(sg.alias == "NOALIAS")
+        
 
 if __name__ == '__main__':
     unittest.main()

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list