Add : the full demoCA certification autority so people can sign their own keys.
[shinken.git] / shinken / hostescalation.py
blobff331f925ae62bc3bf84b22ce626467e4bff5c79
1 #!/usr/bin/env python
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
21 from shinken.item import Item, Items
22 from shinken.util import to_int, to_split
23 from shinken.escalation import Escalation
24 from shinken.property import UnusedProp, BoolProp, IntegerProp, FloatProp, CharProp, StringProp, ListProp
26 class Hostescalation(Item):
27 id = 1 #0 is always special in database, so we do not take risk here
28 my_type = 'hostescalation'
30 properties={'host_name' : StringProp(),
31 'hostgroup_name' : StringProp(),
32 'first_notification' : IntegerProp(),
33 'last_notification' : IntegerProp(),
34 'notification_interval' : IntegerProp(),
35 'escalation_period' : StringProp(default=''),
36 'escalation_options' : ListProp(default='d,u,r,w,c'),
37 'contacts' : StringProp(),
38 'contact_groups' : StringProp(),
41 running_properties = {}
44 macros = {}
47 #For debugging purpose only (nice name)
48 def get_name(self):
49 return ''
52 class Hostescalations(Items):
53 name_property = ""
54 inner_class = Hostescalation
57 #We look for contacts property in contacts and
58 def explode(self, escalations):
59 #Now we explode all escalations (host_name, service_description) to escalations
60 for es in self:
61 properties = es.__class__.properties
62 name = getattr(es, 'host_name', getattr(es, 'hostgroup_name', ''))
63 creation_dict = {'escalation_name' : 'Generated-Hostescalation-%d-%s' % (es.id, name)}
64 for prop in properties:
65 if hasattr(es, prop):
66 creation_dict[prop] = getattr(es, prop)
67 s = Escalation(creation_dict)
68 escalations.add_escalation(s)
70 #print "All escalations"
71 #for es in escalations:
72 # print es