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] Deploy 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',DEPLOY_SCRIPT,cluster]) log('deployment complete') return exit_val def trigger_testing(): import requests global url url = '%sdeploy_complete' % ORCHE_URL log("triggering testing, %s" % url) r = requests.post(url) return not 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())