*Remove the dot from some import paths, so python 2.4 is happy
[shinken.git] / shinken / objects / hostescalation.py
blob356df0b13731ba1982f0e9d944fd9ccb9892b3a1
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
7 #This file is part of Shinken.
9 #Shinken is free software: you can redistribute it and/or modify
10 #it under the terms of the GNU Affero General Public License as published by
11 #the Free Software Foundation, either version 3 of the License, or
12 #(at your option) any later version.
14 #Shinken is distributed in the hope that it will be useful,
15 #but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 #GNU Affero General Public License for more details.
19 #You should have received a copy of the GNU Affero General Public License
20 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 from item import Item, Items
23 from escalation import Escalation
24 from shinken.util import to_int, to_split
25 from shinken.property import UnusedProp, BoolProp, IntegerProp, FloatProp, CharProp, StringProp, ListProp
27 class Hostescalation(Item):
28 id = 1 #0 is always special in database, so we do not take risk here
29 my_type = 'hostescalation'
31 properties={'host_name' : StringProp(),
32 'hostgroup_name' : StringProp(),
33 'first_notification' : IntegerProp(),
34 'last_notification' : IntegerProp(),
35 'notification_interval' : IntegerProp(),
36 'escalation_period' : StringProp(default=''),
37 'escalation_options' : ListProp(default='d,u,r,w,c'),
38 'contacts' : StringProp(),
39 'contact_groups' : StringProp(),
42 running_properties = {}
45 macros = {}
48 #For debugging purpose only (nice name)
49 def get_name(self):
50 return ''
53 class Hostescalations(Items):
54 name_property = ""
55 inner_class = Hostescalation
58 #We look for contacts property in contacts and
59 def explode(self, escalations):
60 #Now we explode all escalations (host_name, service_description) to escalations
61 for es in self:
62 properties = es.__class__.properties
63 name = getattr(es, 'host_name', getattr(es, 'hostgroup_name', ''))
64 creation_dict = {'escalation_name' : 'Generated-Hostescalation-%d-%s' % (es.id, name)}
65 for prop in properties:
66 if hasattr(es, prop):
67 creation_dict[prop] = getattr(es, prop)
68 s = Escalation(creation_dict)
69 escalations.add_escalation(s)
71 #print "All escalations"
72 #for es in escalations:
73 # print es