-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild_python_script.py
36 lines (28 loc) · 1.26 KB
/
build_python_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# This script uses the Duffy node management api to get fresh machines to run
# your CI tests on. Once allocated you will be able to ssh into that machine
# as the root user and setup the environ
#
# XXX: You need to add your own api key below, and also set the right cmd= line
# needed to run the tests
#
# Please note, this is a basic script, there is no error handling and there are
# no real tests for any exceptions. Patches welcome!
import json, urllib, subprocess, sys
url_base="http://admin.ci.centos.org:8080"
# This file was generated on your slave. See https://wiki.centos.org/QaWiki/CI/GettingStarted
api=open('duffy.key').read().strip()
ver="7"
arch="x86_64"
count=1
git_url="https://example.com/test.git"
get_nodes_url="%s/Node/get?key=%s&ver=%s&arch=%s&count=%s" % (url_base,api,ver,arch,count)
dat=urllib.urlopen(get_nodes_url).read()
b=json.loads(dat)
for h in b['hosts']:
cmd="ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s 'yum -y install git && git clone %s tests && cd tests && chmod +x ./run_tests && ./run_tests'" % (h, git_url)
print cmd
rtn_code=subprocess.call(cmd, shell=True)
done_nodes_url="%s/Node/done?key=%s&ssid=%s" % (url_base, api, b['ssid'])
das=urllib.urlopen(done_nodes_url).read()
sys.exit(rtn_code)