Title: [opsview] [11241] Simplified is_handled logic.
Revision
11241
Author
tvoon
Date
2013-01-25 14:41:24 +0000 (Fri, 25 Jan 2013)

Log Message

Simplified is_handled logic. Updated test cases to check for Acknowledge option 
in menus. Updated test db for one object which is listed as having downtime, but
the service status didn't include it

Modified Paths

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2013-01-25 14:34:36 UTC (rev 11240)
+++ trunk/CHANGES	2013-01-25 14:41:24 UTC (rev 11241)
@@ -49,6 +49,7 @@
     The web cache (/opt/opsview/work/web-cache) is now cleared upon starting opsview-web
     Fix cell borders in keyword view
     The reload timings are now centred
+    Fixed acknowledgement option to only appear in menus if the object is unhandled
 
 3.20120925
     FEATURES:

Modified: trunk/opsview-core/lib/Runtime/Host.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/Host.pm	2013-01-25 14:34:36 UTC (rev 11240)
+++ trunk/opsview-core/lib/Runtime/Host.pm	2013-01-25 14:41:24 UTC (rev 11241)
@@ -310,9 +310,11 @@
 
 sub is_handled {
     my $self = shift;
-    return (  $self->current_state != 0
-          and $self->problem_has_been_acknowledged == 0
-          and $self->scheduled_downtime_depth == 0 ) ? 0 : 1;
+    return (
+             $self->current_state != 1
+          or $self->problem_has_been_acknowledged == 1
+          or $self->scheduled_downtime_depth > 0
+    );
 }
 
 =back

Modified: trunk/opsview-core/lib/Runtime/Service.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/Service.pm	2013-01-25 14:34:36 UTC (rev 11240)
+++ trunk/opsview-core/lib/Runtime/Service.pm	2013-01-25 14:41:24 UTC (rev 11241)
@@ -36,7 +36,8 @@
 *name = \&servicename;
 
 __PACKAGE__->might_have( servicestatus => "Runtime::Servicestatus" =>
-      qw(current_state output last_check problem_has_been_acknowledged) );
+      qw(current_state output last_check scheduled_downtime_depth problem_has_been_acknowledged)
+);
 __PACKAGE__->has_a( host_object_id => "Runtime::Host" );
 
 =head1 NAME
@@ -232,9 +233,12 @@
 
 sub is_handled {
     my $self = shift;
-    return (  $self->current_state != 0
-          and $self->problem_has_been_acknowledged == 0
-          and $self->host_object_id->current_state == 0 ) ? 0 : 1;
+    return (
+             $self->current_state == 0
+          or $self->problem_has_been_acknowledged == 1
+          or $self->scheduled_downtime_depth > 0
+          or $self->host_object_id->current_state != 0
+    );
 }
 
 =back

Modified: trunk/opsview-core/lib/Runtime/Servicestatus.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/Servicestatus.pm	2013-01-25 14:34:36 UTC (rev 11240)
+++ trunk/opsview-core/lib/Runtime/Servicestatus.pm	2013-01-25 14:41:24 UTC (rev 11241)
@@ -29,7 +29,7 @@
 
 __PACKAGE__->columns( Primary => qw/service_object_id/ );
 __PACKAGE__->columns( Essential =>
-      qw/output last_check next_check current_state problem_has_been_acknowledged/
+      qw/output last_check next_check current_state scheduled_downtime_depth problem_has_been_acknowledged/
 );
 
 __PACKAGE__->has_datetime( 'last_check' );

Modified: trunk/opsview-core/t/var/runtime.test.db
===================================================================
--- trunk/opsview-core/t/var/runtime.test.db	2013-01-25 14:34:36 UTC (rev 11240)
+++ trunk/opsview-core/t/var/runtime.test.db	2013-01-25 14:41:24 UTC (rev 11241)
@@ -2371,7 +2371,7 @@
 INSERT INTO `nagios_servicestatus` VALUES (23,1,155,'2007-10-31 13:20:41','**Disk failure** on *sd1* - see [internal2 wiki](http://opsview2.org)','',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
 INSERT INTO `nagios_servicestatus` VALUES (24,1,156,'2007-10-31 13:20:41','forced result','',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
 INSERT INTO `nagios_servicestatus` VALUES (25,1,157,'2007-10-31 13:20:41','forced result','/=104MB /var=124MB /boot=84MB',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
-INSERT INTO `nagios_servicestatus` VALUES (26,1,158,'2007-10-31 13:20:41','forced result','',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
+INSERT INTO `nagios_servicestatus` VALUES (26,1,158,'2007-10-31 13:20:41','forced result','',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,1,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
 INSERT INTO `nagios_servicestatus` VALUES (27,1,159,'2007-10-31 13:20:41','forced result','',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
 INSERT INTO `nagios_servicestatus` VALUES (28,1,160,'2007-10-31 13:20:41','forced result','',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,1,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);
 INSERT INTO `nagios_servicestatus` VALUES (29,1,161,'2007-10-31 13:20:41','forced result','losspct=0 rta=25ms',3,1,1,1,3,'2007-10-31 13:20:40','2007-10-31 13:21:35',1,'2007-10-31 12:28:57','2007-10-31 12:28:57',3,'1970-01-01 01:00:00','1970-01-01 01:00:00','2007-10-31 13:20:40','1970-01-01 01:00:00',1,'1970-01-01 01:00:00','1970-01-01 01:00:00',0,1,0,0,0,1,1,1,1,0,5.72368,1.12799,0,0,1,1,0,0,'','host4_service45_check_nrpe',5,1,4);

Modified: trunk/opsview-web/t/860menus.t
===================================================================
--- trunk/opsview-web/t/860menus.t	2013-01-25 14:34:36 UTC (rev 11240)
+++ trunk/opsview-web/t/860menus.t	2013-01-25 14:41:24 UTC (rev 11241)
@@ -360,8 +360,15 @@
 $mech->content_contains( "Acknowledge", "Ack option for host" );
 
 $mech->get_ok( "http://localhost/state/service/216/menus" );
-$mech->content_contains( "Acknowledge", "Ack options for service" );
+$mech->content_lacks( "Acknowledge",
+    "No acknowledge as the service's host is not UP"
+);
 
+$mech->get_ok( "http://localhost/state/service/158/menus" );
+$mech->content_lacks( "Acknowledge",
+    "No acknowledge as the service is in downtime"
+);
+
 $mech->get_ok( "http://localhost/state/host/name/doesnt_exist_2/menus" );
 $mech->content_lacks( "Acknowledge", "None because already ackd" );
 

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

Reply via email to