|
|
|
@ -56,6 +56,7 @@ def channel_name_to_raw_incident_number( channel_name ):
|
|
|
|
|
def mattermost_incident_command( command, args, channel_id, raw_incident_number, user_name ):
|
|
|
|
|
channel = app.mm.channels.get_channel( channel_id )
|
|
|
|
|
slug = slugify.slugify( channel[ 'purpose' ] )
|
|
|
|
|
index = event.Index( path = app.config[ "STATUS_EVENT_INDEX" ] )
|
|
|
|
|
ev = event.Event( path = app.config[ "STATUS_EVENT_SCHEME" ] % { "incident_number": raw_incident_number,
|
|
|
|
|
"slug": slug,
|
|
|
|
|
},
|
|
|
|
@ -154,7 +155,7 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
elif command == "START":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
started = ev.set_started( args or datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ) )
|
|
|
|
|
ev.write()
|
|
|
|
|
|
|
|
|
@ -162,7 +163,7 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
|
'message': "Event start date set by %s to: `%s`" % ( user_name, started ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "ETR":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
expected = ev.set_expected( args or datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ) )
|
|
|
|
|
ev.write()
|
|
|
|
|
|
|
|
|
@ -170,7 +171,7 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
|
'message': "Event estimated time of resolution set by %s to: `%s`" % ( user_name, expected ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "FINISHED":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
finished = ev.set_finished( args or datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ) )
|
|
|
|
|
ev.write()
|
|
|
|
|
|
|
|
|
@ -178,7 +179,7 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
|
'message': "Event finished time set by %s to: `%s`" % ( user_name, finished ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "RESOLVED":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
resolved = ev.set_resolved( args or datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ) )
|
|
|
|
|
ev.write()
|
|
|
|
|
|
|
|
|
@ -189,7 +190,7 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
|
if not args:
|
|
|
|
|
return "You need to specify some text to add to the timeline..."
|
|
|
|
|
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
ev.add_timeline( time = datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ), line = args )
|
|
|
|
|
ev.write()
|
|
|
|
|
|
|
|
|
@ -198,41 +199,56 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
elif command == "INCIDENT":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
flags = ev.toggle_incident()
|
|
|
|
|
ev.write()
|
|
|
|
|
index.open()
|
|
|
|
|
index.set_flags( flags.split() )
|
|
|
|
|
index.write()
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "DEGRADED":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
flags = ev.toggle_degraded()
|
|
|
|
|
ev.write()
|
|
|
|
|
index.open()
|
|
|
|
|
index.set_flags( flags.split() )
|
|
|
|
|
index.write()
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "MAINTENANCE":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
flags = ev.toggle_maintenance()
|
|
|
|
|
ev.write()
|
|
|
|
|
index.open()
|
|
|
|
|
index.set_flags( flags.split() )
|
|
|
|
|
index.write()
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "NOTICE":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
flags = ev.toggle_notice()
|
|
|
|
|
ev.write()
|
|
|
|
|
index.open()
|
|
|
|
|
index.set_flags( flags.split() )
|
|
|
|
|
index.write()
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
|
} )
|
|
|
|
|
elif command == "OK":
|
|
|
|
|
new = ev.open()
|
|
|
|
|
ev.open()
|
|
|
|
|
flags = ev.toggle_ok()
|
|
|
|
|
ev.write()
|
|
|
|
|
index.open()
|
|
|
|
|
index.set_flags( flags.split() )
|
|
|
|
|
index.write()
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
|