aboutsummaryrefslogtreecommitdiffstats
path: root/userdata/conf/boardready.py
blob: ad3ddf5605a4af80f7c1232d999e4504bc74b89f (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python

import xmlrpclib
import ssl
import sys
import time
# bug, ssl chain cannot be verified (letsencrypt)
ssl._create_default_https_context = ssl._create_unverified_context

#server = xmlrpclib.ServerProxy("https://porter.agl.homelinux.org/RPC2")

print "Starting ..."
sys.stdout.flush()

arg = None

if len(sys.argv) > 1:
        arg = sys.argv[1]

if arg == None:
        print("No argument, need lava jobnumber as argument.")
        sys.exit(1)

username = "FILL-IN-USERNAME"
token = "FILL-IN-TOKEN"
hostname = "porter.agl.homelinux.org"

server = xmlrpclib.ServerProxy("https://%s:%s@%s/RPC2" % (username, token, hostname))

#print(arg)
#sys.stdout.flush()

# Poll loop
while True:
	try:
            x = server.scheduler.job_status(arg)['job_status']
        except:
	    print("Error, quitting.")
	    sys.stdout.flush()
	    break
        if 'Submitted' in x:
                print("Job submitted - pending")
                sys.stdout.flush()
                time.sleep(20)
                continue
        if 'Running' in x:
                print("Job Running now.")
                print("Remote boot takes around 6 minutes to complete ...")
                sys.stdout.flush()
                time.sleep(360)
                y = server.scheduler.job_status(arg)['job_status']
                if 'Running' in y:
                        break
                else:
                        continue
                break
        break

# end