summaryrefslogtreecommitdiff
path: root/deploy_logic.py
diff options
context:
space:
mode:
authorWill Holland <william.holland@codethink.co.uk>2015-09-11 10:19:47 +0100
committerWill Holland <william.holland@codethink.co.uk>2015-09-11 10:19:47 +0100
commit5652f4625f6fb6fc82dd7feed8c2be0edd73e61a (patch)
tree05ccaf15566e7448a26467bf20a58f331c9b6898 /deploy_logic.py
parent7aa22de16092fc8da48f9541cb82b6fbbdf568ac (diff)
downloadbuildslave-scripts-5652f4625f6fb6fc82dd7feed8c2be0edd73e61a.tar.gz
Separate deploy trigger from builder trigger
Diffstat (limited to 'deploy_logic.py')
-rw-r--r--deploy_logic.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/deploy_logic.py b/deploy_logic.py
new file mode 100644
index 0000000..cc52a2b
--- /dev/null
+++ b/deploy_logic.py
@@ -0,0 +1,52 @@
+import subprocess
+
+ORCHE_URL = 'http://127.0.0.1:8080/'
+BUILD_SCRIPT = 'build_a_system.sh'
+DEPLOY_SCRIPT = 'deploy_a_system.sh'
+DEFINITIONS_DIR='definitions'
+REF = "cu010-trove/br6/firehose-test-1"
+
+whitelist = [
+ 'clusters/tlsa.morph',
+ 'systems/base-system-x86_64-generic.morph',
+ 'strata/build-essential.morph',
+ 'strata/core.morph',
+ 'strata/foundation.morph',
+ 'strata/bsp-x86_64-generic.morph',
+ ]
+
+LOGFILE = '/home/williamholland/orchestration/trigger_log'
+
+log_file = open(LOGFILE,'a')
+
+def log(msg):
+ ''' write message to log file with timestamp and script name '''
+ import datetime
+ global log_file
+ dt = str(datetime.datetime.now()).split('.')[0]
+ log_file.write("[%s] Builder Trigger: %s\n" % (dt, msg))
+
+def _exit(exit_val):
+ if exit_val: log('exiting unhappily')
+ exit(exit_val)
+
+def deploy(cluster):
+ log('deploying %s' % cluster)
+ exit_val = subprocess.call(['sh','%s' % DEPLOY_SCRIPT, '%s' % cluster])
+ log('deployment complete')
+ _exit(exit_val)
+
+def trigger_testing(build_id):
+ import requests
+ global url
+ url = '%sdeploy_complete' % ORCHE_URL
+ payload = {'artefact':build_id}
+ r = requests.post(url,data=payload)
+ return r.ok
+
+if __name__ == '__main__':
+ import sys
+ system = sys.argv[1]
+ deploy_exit_val = deploy('clusters/tlsa.morph')
+ if deploy_exit_val: _exit(deploy_exit_val)
+ _exit(trigger_testing())