Commit 6e830292 by Fred Smith

Merge pull request #2103 from edx/derf/abbey_notifier_callbacks

OPS-522 - abbey notifier callbacks
parents cb1ead5b 445a38aa
...@@ -11,3 +11,4 @@ docopt==0.6.1 ...@@ -11,3 +11,4 @@ docopt==0.6.1
python-simple-hipchat==0.2 python-simple-hipchat==0.2
prettytable==0.7.2 prettytable==0.7.2
awscli==1.4.2 awscli==1.4.2
requests
...@@ -97,6 +97,13 @@ cleanup_params="" ...@@ -97,6 +97,13 @@ cleanup_params=""
if [[ "$cleanup" == "false" ]]; then if [[ "$cleanup" == "false" ]]; then
cleanup_params="--no-cleanup" cleanup_params="--no-cleanup"
fi fi
notification_params=""
if [[ ! -z "$callback_url" ]]; then
if [[ ! -z "$jobid" ]]; then
notification_params="--callback-url $callback_url$jobid"
curl "$callback_url$jobid/starting%20abbey%20for%20$jobid"
fi
fi
cd configuration cd configuration
pip install -r requirements.txt pip install -r requirements.txt
...@@ -105,5 +112,4 @@ cd util/vpc-tools/ ...@@ -105,5 +112,4 @@ cd util/vpc-tools/
echo "$vars" > /var/tmp/$BUILD_ID-extra-vars.yml echo "$vars" > /var/tmp/$BUILD_ID-extra-vars.yml
cat /var/tmp/$BUILD_ID-extra-vars.yml cat /var/tmp/$BUILD_ID-extra-vars.yml
python -u abbey.py -p $play -t c3.large -d $deployment -e $environment -i /edx/var/jenkins/.ssh/id_rsa $base_params $blessed_params $playbookdir_params --vars /var/tmp/$BUILD_ID-extra-vars.yml -c $BUILD_NUMBER --configuration-version $configuration --configuration-secure-version $configuration_secure -k $jenkins_admin_ec2_key --configuration-secure-repo $jenkins_admin_configuration_secure_repo $configurationprivate_params $hipchat_params $cleanup_params $notification_params
python -u abbey.py -p $play -t c3.large -d $deployment -e $environment -i /edx/var/jenkins/.ssh/id_rsa $base_params $blessed_params $playbookdir_params --vars /var/tmp/$BUILD_ID-extra-vars.yml -c $BUILD_NUMBER --configuration-version $configuration --configuration-secure-version $configuration_secure -k $jenkins_admin_ec2_key --configuration-secure-repo $jenkins_admin_configuration_secure_repo $configurationprivate_params $hipchat_params $cleanup_params
...@@ -5,6 +5,7 @@ import time ...@@ -5,6 +5,7 @@ import time
import json import json
import yaml import yaml
import os import os
import requests
try: try:
import boto.ec2 import boto.ec2
import boto.sqs import boto.sqs
...@@ -124,6 +125,9 @@ def parse_args(): ...@@ -124,6 +125,9 @@ def parse_args():
parser.add_argument("--hipchat-api-token", required=False, parser.add_argument("--hipchat-api-token", required=False,
default=None, default=None,
help="The API token for Hipchat integration") help="The API token for Hipchat integration")
parser.add_argument("--callback-url", required=False,
default=None,
help="The callback URL to send notifications to")
parser.add_argument("--root-vol-size", required=False, parser.add_argument("--root-vol-size", required=False,
default=50, default=50,
help="The size of the root volume to use for the " help="The size of the root volume to use for the "
...@@ -139,7 +143,6 @@ def parse_args(): ...@@ -139,7 +143,6 @@ def parse_args():
return parser.parse_args() return parser.parse_args()
def get_instance_sec_group(vpc_id): def get_instance_sec_group(vpc_id):
grp_details = ec2.get_all_security_groups( grp_details = ec2.get_all_security_groups(
...@@ -669,6 +672,9 @@ def launch_and_configure(ec2_args): ...@@ -669,6 +672,9 @@ def launch_and_configure(ec2_args):
def send_hipchat_message(message): def send_hipchat_message(message):
print(message) print(message)
if args.callback_url:
r=requests.get("{}/{}".format(args.callback_url, message))
#If hipchat is configured send the details to the specified room #If hipchat is configured send the details to the specified room
if args.hipchat_api_token and args.hipchat_room_id: if args.hipchat_api_token and args.hipchat_room_id:
import hipchat import hipchat
......
boto boto
docopt docopt
requests
python-simple-hipchat==0.2 python-simple-hipchat==0.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment