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