diff options
author | Will Holland <william.holland@codethink.co.uk> | 2015-09-08 11:17:22 +0100 |
---|---|---|
committer | Will Holland <william.holland@codethink.co.uk> | 2015-09-08 11:17:22 +0100 |
commit | d4fce543b3e229ec2cb596aa1a026efb1a807655 (patch) | |
tree | 6be283ce04a0ce2db04fbc02383a1513a977a94e /source/bottlerock.py | |
parent | a9b700a73fdf1cc90388c7789151e4d37552b82e (diff) | |
download | orchestration-d4fce543b3e229ec2cb596aa1a026efb1a807655.tar.gz |
Add HTTP POST interface, bottlerock
This is so that hooks running in the Trove sandbox can trigger buildbot
Diffstat (limited to 'source/bottlerock.py')
-rw-r--r-- | source/bottlerock.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source/bottlerock.py b/source/bottlerock.py new file mode 100644 index 0000000..9b7915f --- /dev/null +++ b/source/bottlerock.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python2.7 + +# This script provides an interface for sandboxed code to trigger buildbot +# using plain HTTP + +from bottle import post, request, run, HTTPResponse + +trigger_names = [ + 'repo_update', + 'definitions_update', + 'build_complete'] + +def call_trigger(trigger_name,*args): + global trigger_names + assert trigger_name in trigger_names + import subprocess + trigger_cmd = ['sh','source/%s' % trigger_name] + for arg in args: trigger_cmd.append(arg) + trigger_ballback = subprocess.Popen(trigger_cmd) + return trigger_callback.wait() + +@post('/repo_update') +def repo_update(): + repo_name = request.forms.get("repo_name") + if not repo_name: + return HTTPResponse( + status=400, + body="400: A repo_name is required") + if call_trigger('repo_update',repo_name): + return HTTPResponse(status=500) + return 0 + +@post('/definitions_update') +def definitions_update(): + pass + +@post('/build_complete') +def repo_update(): + pass + +if __name__ == '__main__': + run(host='localhost', port=8080, debug=True) |