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 item
import Item
, Items
22 from util
import to_int
, to_split
23 from escalation
import Escalation
25 class Serviceescalation(Item
):
26 id = 1 #0 is always special in database, so we do not take risk here
27 my_type
= 'serviceescalation'
29 properties
={'host_name' : {'required' : True},
30 'hostgroup_name' : {'required' : True},
31 'service_description' : {'required' : True},
32 'first_notification' : {'required' : True, 'pythonize' : to_int
},
33 'last_notification' : {'required': True, 'pythonize' : to_int
},
34 'notification_interval' : {'required' : True, 'pythonize' : to_int
},
35 'escalation_period' : {'required': False},
36 'escalation_options' : {'required': False, 'default': 'd,u,r,w,c', 'pythonize' : to_split
},
37 'contacts' : {'required':True},
38 'contact_groups' : {'required':True},
41 running_properties
= {}
47 #For debugging purpose only (nice name)
52 class Serviceescalations(Items
):
54 inner_class
= Serviceescalation
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
61 properties
= es
.__class
__.properties
63 creation_dict
= {'escalation_name' : 'Generated-Serviceescalation-%d' % es
.id}
64 for prop
in properties
:
66 creation_dict
[prop
] = getattr(es
, prop
)
67 #print "Creation an escalation with :", creation_dict
68 s
= Escalation(creation_dict
)
69 escalations
.add_escalation(s
)