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
11 #it under the terms of the GNU Affero General Public License as published by
12 #the Free Software Foundation, either version 3 of the License, or
13 #(at your option) any later version.
15 #Shinken is distributed in the hope that it will be useful,
16 #but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 #GNU Affero General Public License for more details.
20 #You should have received a copy of the GNU Affero General Public License
21 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
23 from shinken
.objects
.item
import Item
, Items
24 from shinken
.objects
.escalation
import Escalation
26 from shinken
.property import IntegerProp
, StringProp
, ListProp
28 class Hostescalation(Item
):
29 id = 1 #0 is always special in database, so we do not take risk here
30 my_type
= 'hostescalation'
33 'host_name': StringProp (),
34 'hostgroup_name': StringProp (),
35 'first_notification': IntegerProp(),
36 'last_notification': IntegerProp(),
37 'notification_interval': IntegerProp(),
38 'escalation_period': StringProp (default
=''),
39 'escalation_options': ListProp (default
='d,u,r,w,c'),
40 'contacts': StringProp (),
41 'contact_groups': StringProp (),
44 running_properties
= {}
49 #For debugging purpose only (nice name)
54 class Hostescalations(Items
):
56 inner_class
= Hostescalation
59 #We look for contacts property in contacts and
60 def explode(self
, escalations
):
61 #Now we explode all escalations (host_name, service_description) to escalations
63 properties
= es
.__class
__.properties
64 name
= getattr(es
, 'host_name', getattr(es
, 'hostgroup_name', ''))
65 creation_dict
= {'escalation_name' : 'Generated-Hostescalation-%d-%s' % (es
.id, name
)}
66 for prop
in properties
:
68 creation_dict
[prop
] = getattr(es
, prop
)
69 s
= Escalation(creation_dict
)
70 escalations
.add_escalation(s
)
72 #print "All escalations"
73 #for es in escalations: