forked from alertmanager/alert_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalert_manager_config.py
More file actions
77 lines (60 loc) · 3.1 KB
/
alert_manager_config.py
File metadata and controls
77 lines (60 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import splunk.admin as admin
import splunk.entity as entity
class AlertHandlerApp(admin.MConfigHandler):
'''
Set up supported arguments
'''
def setup(self):
if self.requestedAction == admin.ACTION_EDIT:
for arg in ['index', 'incident_list_length', 'default_owner', 'default_impact', 'default_urgency', 'default_priority', 'user_directories']:
self.supportedArgs.addOptArg(arg)
pass
def handleList(self, confInfo):
confDict = self.readConf("alert_manager")
if None != confDict:
for stanza, settings in confDict.items():
for key, val in settings.items():
#if key in ['save_results']:
# if int(val) == 1:
# val = '1'
# else:
# val = '0'
if key in ['index'] and val in [None, '']:
val = ''
if key in ['incident_list_length'] and val in [None, '']:
val = ''
if key in ['default_owner'] and val in [None, '']:
val = ''
if key in ['default_impact'] and val in [None, '']:
val = ''
if key in ['default_urgency'] and val in [None, '']:
val = ''
if key in ['default_priority'] and val in [None, '']:
val = ''
if key in ['user_directories'] and val in [None, '']:
val = ''
confInfo[stanza].append(key, val)
def handleEdit(self, confInfo):
name = self.callerArgs.id
args = self.callerArgs
if self.callerArgs.data['index'][0] in [None, '']:
self.callerArgs.data['index'][0] = ''
if self.callerArgs.data['incident_list_length'][0] in [None, '']:
self.callerArgs.data['incident_list_length'][0] = ''
if self.callerArgs.data['default_owner'][0] in [None, '']:
self.callerArgs.data['default_owner'][0] = ''
if self.callerArgs.data['default_impact'][0] in [None, '']:
self.callerArgs.data['default_impact'][0] = ''
if self.callerArgs.data['default_urgency'][0] in [None, '']:
self.callerArgs.data['default_urgency'][0] = ''
if self.callerArgs.data['default_priority'][0] in [None, '']:
self.callerArgs.data['default_priority'][0] = ''
if self.callerArgs.data['user_directories'][0] in [None, '']:
self.callerArgs.data['user_directories'][0] = ''
#if int(self.callerArgs.data['save_results'][0]) == 1:
# self.callerArgs.data['save_results'][0] = '1'
#else:
# self.callerArgs.data['save_results'][0] = '0'
self.writeConf('alert_manager', 'settings', self.callerArgs.data)
# initialize the handler
admin.init(AlertHandlerApp, admin.CONTEXT_APP_AND_USER)