aboutsummaryrefslogtreecommitdiffstats
path: root/userdata/conf/lava/boardready.py
blob: 45639f6b8b00ef52b7249b2d84a035d48452d952 (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
60
61
62
63
64
65
#!/usr/bin/python

import xmlrpclib
import ssl
import sys
import time

# bug, ssl chain cannot be verified (letsencrypt)
# to be fixed
ssl._create_default_https_context = ssl._create_unverified_context
#server = xmlrpclib.ServerProxy("https://porter.automotivelinux.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 = "replace-with-username"
token = "replace-with-token"
hostname = "porter.automotivelinux.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()
	    sys.exit(1)
	    break
        if 'Cancelled' in x:
                sys.exit(1)
                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-10 minutes to complete ...")
                sys.stdout.flush()
                time.sleep(600)
                # todo: check for ssh port and wait a little longer if not
                y = server.scheduler.job_status(arg)['job_status']
                if 'Running' in y:
                        break
                else:
                        continue
                break
        break

# end