Merge branch 'master' of ssh://lausser,shinken@shinken.git.sourceforge.net/gitroot...
[shinken.git] / shinken / acknowledge.py
blob2b8b289de9ea1dcd423563d16a3716ae955dcea6
1 #!/usr/bin/env python
2 # Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
5 # Gregory Starck, g.starck@gmail.com
6 # Hartmut Goebel, h.goebel@goebel-consult.de
8 # This file is part of Shinken.
10 # Shinken is free software: you can redistribute it and/or modify it
11 # under the terms of the GNU Affero General Public License as
12 # published by the Free Software Foundation, either version 3 of the
13 # License, or (at your option) any later version.
15 # Shinken is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Affero General Public License for more details.
20 # You should have received a copy of the GNU Affero General Public
21 # License along with Shinken. If not, see <http://www.gnu.org/licenses/>.
23 """
24 Allows you to acknowledge the current problem for the specified service.
25 By acknowledging the current problem, future notifications (for the same
26 servicestate) are disabled.
27 """
28 class Acknowledge:
29 id = 0
31 #Just to list the properties we will send as pickle
32 #so to others daemons, so all but NOT REF
33 properties = {
34 'id' : None,
35 'sticky' : None,
36 'notify' : None,
37 'author' : None,
38 'comment' : None,
42 # If the "sticky" option is set to one (1), the acknowledgement
43 # will remain until the service returns to an OK state. Otherwise
44 # the acknowledgement will automatically be removed when the
45 # service changes state. In this case Web interfaces set a value
46 # of (2).
48 # If the "notify" option is set to one (1), a notification will be
49 # sent out to contacts indicating that the current service problem
50 # has been acknowledged.
52 # If the "persistent" option is set to one (1), the comment
53 # associated with the acknowledgement will survive across restarts
54 # of the Shinken process. If not, the comment will be deleted the
55 # next time Nagios restarts. "persistent" not only means "survive
56 # restarts", but also
58 def __init__(self, ref, sticky, notify, persistent, author, comment):
59 self.id = self.__class__.id
60 self.__class__.id += 1
61 self.ref = ref # pointer to srv or host we are apply
62 self.sticky = sticky
63 self.notify = notify
64 self.author = author
65 self.comment = comment
68 #Call by picle for dataify the ackn
69 #because we DO NOT WANT REF in this pickleisation!
70 def __getstate__(self):
71 cls = self.__class__
72 # id is not in *_properties
73 res = {'id' : self.id}
74 for prop in cls.properties:
75 if hasattr(self, prop):
76 res[prop] = getattr(self, prop)
77 return res
80 #Inversed funtion of getstate
81 def __setstate__(self, state):
82 cls = self.__class__
83 self.id = state['id']
84 for prop in cls.properties:
85 if prop in state:
86 setattr(self, prop, state[prop])