Title: [opsview] [10967] Merge from BRAN-4.2 10966: sharednotificationprofiles bug when generating Nagios
Revision
10967
Author
tvoon
Date
2012-12-10 16:12:14 +0000 (Mon, 10 Dec 2012)

Log Message

Merge from BRAN-4.2 10966: sharednotificationprofiles bug when generating Nagios
configuration file

Modified Paths

Property Changed


Property changes on: trunk/opsview-core
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/DEV-capside/release-3.9.0/opsview-core:6365-6370
/branches/DEV-extra-notification-data/opsview-core:6734-6746
/branches/DEV-odw-calculations/opsview-core:9016-9160
/branches/DEV-restapi-monitoringservers/opsview-core:9778
/branches/DEV-snmp-multi/opsview-core:7324-7376
/branches/US187/opsview-core:9403-9479
/branches/US198b/opsview-core:8875-8994
/branches/US310/opsview-core:9851-9873
/branches/enterprise/BRAN-3.14/opsview-core:6874,6882,6956
/branches/enterprise/DEV-professional/opsview-core:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093,10345,10347,10388,10407,10481,10549,10560-10562,10565,10568,10571,10577
/branches/nagvis-iframe/opsview-core:9764-9786
/branches/us168/opsview-core:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/BRAN-4.2:10966
/commercial/branches/BRAN-4.2/opsview-core:10944,10966
/commercial/branches/US306-slaves/opsview-core:9804-9823
/commercial/branches/US307-network-map/opsview-core:9685-9837

Modified: trunk/opsview-core/lib/Opsview/Schema/Sharednotificationprofiles.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Schema/Sharednotificationprofiles.pm	2012-12-10 16:00:57 UTC (rev 10966)
+++ trunk/opsview-core/lib/Opsview/Schema/Sharednotificationprofiles.pm	2012-12-10 16:12:14 UTC (rev 10967)
@@ -322,19 +322,21 @@
 Returns the name of the contact groups this contact is authorised to view. This is
 different from Opsview::Base::Contact as this needs to work out the all_hostgroups parameter first
 
+This is called by nagconfgen, so test with 990nagconfgen.t
+
 =cut
 
 sub contactgroups {
     my $self = shift;
     my @cgs  = ();
-    my @hgs  = $self->valid_hostgroups->search(
+    my @hgs  = $self->selected_hostgroups->search(
         {},
         {
             columns      => "id",
             result_class => "DBIx::Class::ResultClass::HashRefInflator"
         }
     );
-    my @sgs = $self->valid_servicegroups->search(
+    my @sgs = $self->selected_servicegroups->search(
         {},
         {
             columns      => "id",
@@ -347,7 +349,7 @@
         }
     }
     foreach my $k (
-        $self->valid_keywords->search(
+        $self->selected_keywords->search(
             {},
             {
                 columns => [ "id", "name" ],
@@ -362,21 +364,52 @@
 }
 
 # Returns an rs based on hostgroups this role is allowed to see
-sub valid_hostgroups {
+# NOTE: This is used by nagconfgen to get applicable hostgroups/servicegroups
+# so changes here should be tested with 990nagconfgen.t
+sub selected_hostgroups {
     my ($self) = @_;
-    return $self->role->valid_hostgroups;
+    if ( $self->all_hostgroups ) {
+        return $self->valid_hostgroups;
+    }
+    else {
+        return $self->hostgroups;
+    }
 }
 
-sub valid_servicegroups {
+sub selected_servicegroups {
     my ($self) = @_;
-    return $self->role->valid_servicegroups;
+    if ( $self->all_servicegroups ) {
+        return $self->valid_servicegroups;
+    }
+    else {
+        return $self->servicegroups;
+    }
 }
 
-sub valid_keywords {
+sub selected_keywords {
     my ($self) = @_;
-    return $self->role->valid_keywords;
+    if ( $self->all_keywords ) {
+        return $self->valid_keywords;
+    }
+    else {
+        return $self->keywords;
+    }
 }
 
+# valid_* is called by TT to get the list
+# of applicable objects
+sub valid_hostgroups {
+    return shift->role->valid_hostgroups;
+}
+
+sub valid_servicegroups {
+    shift->role->valid_servicegroups;
+}
+
+sub valid_keywords {
+    shift->role->valid_keywords;
+}
+
 sub host_notification_options {
     my $self = shift;
     $self->notification_options( "_host_notification_options", @_ );

Modified: trunk/opsview-core/t/var/configs/Master Monitoring Server/contacts.cfg
===================================================================
--- trunk/opsview-core/t/var/configs/Master Monitoring Server/contacts.cfg	2012-12-10 16:00:57 UTC (rev 10966)
+++ trunk/opsview-core/t/var/configs/Master Monitoring Server/contacts.cfg	2012-12-10 16:12:14 UTC (rev 10967)
@@ -75,7 +75,7 @@
 	service_notification_period	24x7
 	host_notification_period	24x7
 	notification_level		1
-	contactgroups	hostgroup2_servicegroup1,hostgroup4_servicegroup1,hostgroup4_servicegroup2,hostgroup5_servicegroup1
+	contactgroups	hostgroup4_servicegroup1
 	host_notification_options	n
 	service_notification_options	n
 }

Modified: trunk/opsview-core/t/var/configs/Master Monitoring Server/objects.cache
===================================================================
--- trunk/opsview-core/t/var/configs/Master Monitoring Server/objects.cache	2012-12-10 16:00:57 UTC (rev 10966)
+++ trunk/opsview-core/t/var/configs/Master Monitoring Server/objects.cache	2012-12-10 16:12:14 UTC (rev 10967)
@@ -358,7 +358,7 @@
 define contactgroup {
 	contactgroup_name	hostgroup2_servicegroup1
 	alias	hostgroup2_servicegroup1
-	members	admin,admin/01adminroleprofile1,adminnoc,nonadmin,nonadmin/01default,nonadmin/02viewsomechangesomeprofile2,nonadmin/03viewsomechangesomeprofile3,onlyunknowns,readonly,readonly/01default,testviewallchangenone,testviewallchangenone/01default,testviewallchangesome,testviewallchangesome/01default
+	members	admin,admin/01adminroleprofile1,adminnoc,nonadmin,nonadmin/01default,nonadmin/03viewsomechangesomeprofile3,onlyunknowns,readonly,readonly/01default,testviewallchangenone,testviewallchangenone/01default,testviewallchangesome,testviewallchangesome/01default
 	}
 
 define contactgroup {
@@ -370,13 +370,13 @@
 define contactgroup {
 	contactgroup_name	hostgroup4_servicegroup2
 	alias	hostgroup4_servicegroup2
-	members	admin,admin/01adminroleprofile1,adminnoc,nonadmin,nonadmin/01default,nonadmin/02viewsomechangesomeprofile2,nonadmin/03viewsomechangesomeprofile3,onlyunknowns,readonly,readonly/01default,testviewallchangenone,testviewallchangenone/01default,testviewallchangesome,testviewallchangesome/01default
+	members	admin,admin/01adminroleprofile1,adminnoc,nonadmin,nonadmin/01default,nonadmin/03viewsomechangesomeprofile3,onlyunknowns,readonly,readonly/01default,testviewallchangenone,testviewallchangenone/01default,testviewallchangesome,testviewallchangesome/01default
 	}
 
 define contactgroup {
 	contactgroup_name	hostgroup5_servicegroup1
 	alias	hostgroup5_servicegroup1
-	members	admin,admin/01adminroleprofile1,adminnoc,nonadmin,nonadmin/01default,nonadmin/02viewsomechangesomeprofile2,nonadmin/03viewsomechangesomeprofile3,onlyunknowns,readonly,readonly/01default,somehosts,somehosts/01nonworkhourssms,somehosts/02default,testviewallchangenone,testviewallchangenone/01default,testviewallchangesome,testviewallchangesome/01default,viewsomechangenone,viewsomechangenone/01default,viewsomechangenonewonotify,viewsomechangenonewonotify/01default
+	members	admin,admin/01adminroleprofile1,adminnoc,nonadmin,nonadmin/01default,nonadmin/03viewsomechangesomeprofile3,onlyunknowns,readonly,readonly/01default,somehosts,somehosts/01nonworkhourssms,somehosts/02default,testviewallchangenone,testviewallchangenone/01default,testviewallchangesome,testviewallchangesome/01default,viewsomechangenone,viewsomechangenone/01default,viewsomechangenonewonotify,viewsomechangenonewonotify/01default
 	}
 
 define contactgroup {

Modified: trunk/opsview-core/t/var/configs/dbic_trace
===================================================================
--- trunk/opsview-core/t/var/configs/dbic_trace	2012-12-10 16:00:57 UTC (rev 10966)
+++ trunk/opsview-core/t/var/configs/dbic_trace	2012-12-10 16:12:14 UTC (rev 10967)
@@ -315,10 +315,9 @@
 SELECT me.id, me.name, me.alias, me.sunday, me.monday, me.tuesday, me.wednesday, me.thursday, me.friday, me.saturday, me.uncommitted FROM opsview.timeperiods me WHERE ( me.id = ? ) ORDER BY name: '1'
 SELECT me.contactid, me.name, me.value FROM opsview.contact_variables me WHERE ( me.contactid = ? ) ORDER BY name: '2'
 SELECT notificationmethod.id, notificationmethod.active, notificationmethod.name, notificationmethod.namespace, notificationmethod.master, notificationmethod.command, notificationmethod.priority, notificationmethod.uncommitted, notificationmethod.contact_variables FROM opsview.notificationprofile_notificationmethods me  JOIN opsview.notificationmethods notificationmethod ON notificationmethod.id = me.notificationmethodid WHERE ( ( active = ? AND me.notificationprofileid = ? ) ) ORDER BY priority: '1', '2'
-SELECT me.id, me.name, me.description, me.priority, me.all_hostgroups, me.all_servicegroups, me.all_keywords, me.uncommitted FROM opsview.roles me WHERE ( me.id = ? ): '12'
-SELECT me.id FROM opsview.hostgroups me WHERE ( rgt = lft+1 ) ORDER BY name, id: 
-SELECT me.id FROM opsview.servicegroups me ORDER BY name: 
-SELECT keywordid.id, keywordid.name FROM opsview.role_access_keywords me  JOIN opsview.keywords keywordid ON keywordid.id = me.keywordid WHERE ( me.roleid = ? ) ORDER BY name: '12'
+SELECT hostgroup.id FROM opsview.sharednotificationprofile_hostgroups me  JOIN opsview.hostgroups hostgroup ON hostgroup.id = me.hostgroupid WHERE ( me.sharednotificationprofileid = ? ) ORDER BY name, id: '6'
+SELECT servicegroup.id FROM opsview.sharednotificationprofile_servicegroups me  JOIN opsview.servicegroups servicegroup ON servicegroup.id = me.servicegroupid WHERE ( me.sharednotificationprofileid = ? ) ORDER BY name: '6'
+SELECT keyword.id, keyword.name FROM opsview.sharednotificationprofile_keywords me  JOIN opsview.keywords keyword ON keyword.id = me.keywordid WHERE ( me.sharednotificationprofileid = ? ) ORDER BY name: '6'
 SELECT me.id, me.name, me.alias, me.sunday, me.monday, me.tuesday, me.wednesday, me.thursday, me.friday, me.saturday, me.uncommitted FROM opsview.timeperiods me WHERE ( me.id = ? ) ORDER BY name: '1'
 SELECT me.contactid, me.name, me.value FROM opsview.contact_variables me WHERE ( me.contactid = ? ) ORDER BY name: '2'
 SELECT notificationmethod.id, notificationmethod.active, notificationmethod.name, notificationmethod.namespace, notificationmethod.master, notificationmethod.command, notificationmethod.priority, notificationmethod.uncommitted, notificationmethod.contact_variables FROM opsview.sharednotificationprofile_notificationmethods me  JOIN opsview.notificationmethods notificationmethod ON notificationmethod.id = me.notificationmethodid WHERE ( ( active = ? AND me.sharednotificationprofileid = ? ) ) ORDER BY priority: '1', '6'

Modified: trunk/opsview-core/t/var/opsview.test.db
===================================================================
--- trunk/opsview-core/t/var/opsview.test.db	2012-12-10 16:00:57 UTC (rev 10966)
+++ trunk/opsview-core/t/var/opsview.test.db	2012-12-10 16:12:14 UTC (rev 10967)
@@ -2503,6 +2503,8 @@
 
 LOCK TABLES `sharednotificationprofile_hostgroups` WRITE;
 /*!40000 ALTER TABLE `sharednotificationprofile_hostgroups` DISABLE KEYS */;
+INSERT INTO `sharednotificationprofile_hostgroups` VALUES (6,4);
+INSERT INTO `sharednotificationprofile_hostgroups` VALUES (6,9);
 /*!40000 ALTER TABLE `sharednotificationprofile_hostgroups` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -2557,6 +2559,7 @@
 
 LOCK TABLES `sharednotificationprofile_servicegroups` WRITE;
 /*!40000 ALTER TABLE `sharednotificationprofile_servicegroups` DISABLE KEYS */;
+INSERT INTO `sharednotificationprofile_servicegroups` VALUES (6,1);
 /*!40000 ALTER TABLE `sharednotificationprofile_servicegroups` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -2590,7 +2593,7 @@
 INSERT INTO `sharednotificationprofiles` VALUES (3,'demorole profile 1','u,d,r,f','w,c,r,u,f',1,1,1,1,1,17,0);
 INSERT INTO `sharednotificationprofiles` VALUES (4,'demorole profile 2','u,d,r,f','w,c,r,u,f',1,1,1,1,1,17,0);
 INSERT INTO `sharednotificationprofiles` VALUES (5,'View some change some profile 1','u,d,r,f','w,c,r,u,f',1,1,1,1,1,12,0);
-INSERT INTO `sharednotificationprofiles` VALUES (6,'View some change some profile 2','u,d,r,f','w,c,r,u,f',1,1,1,1,1,12,0);
+INSERT INTO `sharednotificationprofiles` VALUES (6,'View some change some profile 2','u,d,r,f','w,c,r,u,f',1,0,0,0,1,12,0);
 INSERT INTO `sharednotificationprofiles` VALUES (7,'View some change some profile 3','u,d,r,f','w,c,r,u,f',1,1,1,1,1,12,0);
 /*!40000 ALTER TABLE `sharednotificationprofiles` ENABLE KEYS */;
 UNLOCK TABLES;

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to