|
|
@ -53,7 +53,7 @@ def channel_name_to_raw_incident_number( channel_name ):
|
|
|
|
return channel_name[ len( app.config[ "MATTERMOST_INCIDENT_CHANNEL_PREFIX" ] ): ]
|
|
|
|
return channel_name[ len( app.config[ "MATTERMOST_INCIDENT_CHANNEL_PREFIX" ] ): ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, user_id ):
|
|
|
|
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" ] )
|
|
|
|
index = event.Index( path = app.config[ "STATUS_EVENT_INDEX" ] )
|
|
|
@ -69,10 +69,13 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
'message': "### `PUBLISH` requested by @%s!" % user_name,
|
|
|
|
'message': "### `PUBLISH` requested by @%s!" % user_name,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private_channel = app.mm.channels.create_direct_message_channel( [ app.config[ "MATTERMOST_USER_ID" ], user_id ] )
|
|
|
|
|
|
|
|
private_channel_id = private_channel[ 'id' ]
|
|
|
|
|
|
|
|
|
|
|
|
# update local repository
|
|
|
|
# update local repository
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " update"
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " update"
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
@ -84,21 +87,21 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
ev.set_published( datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ) )
|
|
|
|
ev.set_published( datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" ) )
|
|
|
|
written = ev.write()
|
|
|
|
written = ev.write()
|
|
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': "#### Written `%s`:\n\n```\n%s```" % ( ev.path_short(), written ),
|
|
|
|
'message': "#### Written `%s`:\n\n```\n%s```" % ( ev.path_short(), written ),
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " add " + ev.path_short()
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " add " + ev.path_short()
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " commit -m 'event for incident " + raw_incident_number + " via FIH' " + ev.path_short()
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " commit -m 'event for incident " + raw_incident_number + " via FIH' " + ev.path_short()
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
@ -107,21 +110,21 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " pull " + pull_from
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " pull " + pull_from
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " merge"
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " merge"
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " commit -m 'merge from " + pull_from + "'"
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " commit -m 'merge from " + pull_from + "'"
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
@ -130,7 +133,7 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " push " + pull_from
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " push " + pull_from
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
@ -138,11 +141,11 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
cmdline = app.config[ "GROW_BIN" ] + " deploy -f " + deploy_to
|
|
|
|
cmdline = app.config[ "GROW_BIN" ] + " deploy -f " + deploy_to
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
if message:
|
|
|
|
if message:
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': private_channel_id,
|
|
|
|
'message': message,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
'message': "### `PUBLISH` completed!",
|
|
|
|
'message': "### `PUBLISH` completed!",
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
@ -246,30 +249,11 @@ def mattermost_incident_command( command, args, channel_id, raw_incident_number,
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
'message': "Flags set by @%s to: `%s`" % ( user_name, flags ),
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "WTF command?"
|
|
|
|
post_help( channel, raw_incident_number, user_name )
|
|
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
def mattermost_incident_start( description, team_id, user_name, user_id, channel_id ):
|
|
|
|
def post_help( channel, raw_incident_number, user_name ):
|
|
|
|
raw_incident_number = generate_raw_incident_number()
|
|
|
|
|
|
|
|
fi_number = raw_incident_number_to_public_incident_number( raw_incident_number )
|
|
|
|
|
|
|
|
channel_name = raw_incident_number_to_channel_name( raw_incident_number )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
channel = app.mm.channels.create_channel( options = { "team_id": team_id,
|
|
|
|
|
|
|
|
"name": channel_name,
|
|
|
|
|
|
|
|
"display_name": fi_number,
|
|
|
|
|
|
|
|
"purpose": description,
|
|
|
|
|
|
|
|
"header": "",
|
|
|
|
|
|
|
|
"type": "O",
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# add user to the channel we just created
|
|
|
|
|
|
|
|
app.mm.client.make_request( 'post', '/channels/' + channel[ 'id' ] + '/members', options = { 'user_id': user_id,
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel[ 'id' ],
|
|
|
|
|
|
|
|
'message': "Incident discussion channel for [%s](%s) created by @%s." % ( fi_number, raw_incident_number_to_url( raw_incident_number ), user_name ),
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
now = datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" )
|
|
|
|
now = datetime.datetime.utcnow().strftime( "%Y-%m-%d %H:%M" )
|
|
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel[ 'id' ],
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel[ 'id' ],
|
|
|
@ -297,11 +281,7 @@ Again, don't forget to **/incident PUBLISH** once making changes.
|
|
|
|
|
|
|
|
|
|
|
|
## Front Page Status
|
|
|
|
## Front Page Status
|
|
|
|
|
|
|
|
|
|
|
|
* **/incident INCIDENT**
|
|
|
|
* **/incident [ INCIDENT | DEGRADED | MAINTENANCE | NOTICE | OK ]**
|
|
|
|
* **/incident DEGRADED**
|
|
|
|
|
|
|
|
* **/incident MAINTENANCE**
|
|
|
|
|
|
|
|
* **/incident NOTICE**
|
|
|
|
|
|
|
|
* **/incident OK**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Again, after setting the headline status you must: **/incident PUBLISH**
|
|
|
|
Again, after setting the headline status you must: **/incident PUBLISH**
|
|
|
|
|
|
|
|
|
|
|
@ -311,8 +291,31 @@ Again, after setting the headline status you must: **/incident PUBLISH**
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mattermost_incident_start( description, team_id, user_name, user_id, channel_id ):
|
|
|
|
|
|
|
|
raw_incident_number = generate_raw_incident_number()
|
|
|
|
|
|
|
|
fi_number = raw_incident_number_to_public_incident_number( raw_incident_number )
|
|
|
|
|
|
|
|
channel_name = raw_incident_number_to_channel_name( raw_incident_number )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
channel = app.mm.channels.create_channel( options = { "team_id": team_id,
|
|
|
|
|
|
|
|
"name": channel_name,
|
|
|
|
|
|
|
|
"display_name": fi_number,
|
|
|
|
|
|
|
|
"purpose": description,
|
|
|
|
|
|
|
|
"header": "",
|
|
|
|
|
|
|
|
"type": "O",
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# add user to the channel we just created
|
|
|
|
|
|
|
|
app.mm.client.make_request( 'post', '/channels/' + channel[ 'id' ] + '/members', options = { 'user_id': user_id,
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel[ 'id' ],
|
|
|
|
|
|
|
|
'message': "Incident discussion channel for [%s](%s) created by @%s." % ( fi_number, raw_incident_number_to_url( raw_incident_number ), user_name ),
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
post_help( channel, raw_incident_number, user_name )
|
|
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': channel_id,
|
|
|
|
'message': 'On behalf of @%s I have started incident ~%s.' % ( request.form[ 'user_name' ], channel_name, ),
|
|
|
|
'message': 'On behalf of @%s I have started incident ~%s.' % ( user_name, channel_name, ),
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
@ -338,6 +341,7 @@ def mattermost_incident():
|
|
|
|
args = " ".join( text[ 1: ] ),
|
|
|
|
args = " ".join( text[ 1: ] ),
|
|
|
|
channel_id = request.form[ 'channel_id' ],
|
|
|
|
channel_id = request.form[ 'channel_id' ],
|
|
|
|
user_name = request.form[ 'user_name' ],
|
|
|
|
user_name = request.form[ 'user_name' ],
|
|
|
|
|
|
|
|
user_id = request.form[ 'user_id' ],
|
|
|
|
raw_incident_number = raw_incident_number,
|
|
|
|
raw_incident_number = raw_incident_number,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|