Merge lp:~liuyq0307/linaro-android-build-tools/support-http into lp:linaro-android-build-tools

Proposed by Yongqin Liu
Status: Superseded
Proposed branch: lp:~liuyq0307/linaro-android-build-tools/support-http
Merge into: lp:linaro-android-build-tools
Diff against target: 84 lines (+33/-16)
1 file modified
build-scripts/post-build-lava.py (+33/-16)
To merge this branch: bzr merge lp:~liuyq0307/linaro-android-build-tools/support-http
Reviewer Review Type Date Requested Status
Paul Sokolovsky Needs Fixing
Review via email: mp+119302@code.launchpad.net

This proposal has been superseded by a proposal from 2012-08-14.

Description of the change

1. Add support to submit job to non-https lava-server instances
2. Change to use LAVA_TOKEN_FILE instead of LAVA_TOKEN to get the token information

To post a comment you must log in.
500. By Yongqin Liu

also change the url for submit result

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

This looks pretty good, thanks for making sure that proper URL schema is used throughout.

The only problem is at line 48. I proposed that value of LAVA_TOKEN_FILE would be just a filename of file containing a token, relative to the predefined dir (/var/run/lava/), not absolute path name. I don't think it's worth to expose full path name to lava tokens in the public build configs.

review: Needs Fixing
501. By Yongqin Liu

merge with trunk

502. By Yongqin Liu

update according to the review comment that the LAVA_TOKEN_FILE should be just the file name that no including the dir path information

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build-scripts/post-build-lava.py'
2--- build-scripts/post-build-lava.py 2012-08-13 05:32:23 +0000
3+++ build-scripts/post-build-lava.py 2012-08-14 04:03:19 +0000
4@@ -237,6 +237,21 @@
5 print "Don't know how to test this board. Skip testing."
6 return
7
8+ lava_server = os.environ.get("LAVA_SERVER")
9+ if lava_server == None:
10+ schema = 'https'
11+ url_no_schema = "validation.linaro.org/lava-server/RPC2/"
12+ elif lava_server.find('://') >= 0:
13+ schema = lava_server[:lava_server.find('://')]
14+ url_no_schema = lava_server[lava_server.find('://') + len('://'):]
15+ else:
16+ ## the case that no https and http specified in the url
17+ ## like: validation.linaro.org/lava-server/RPC2/
18+ schema = 'https'
19+ url_no_schema = lava_server #for compare with above condition
20+ schema_url = '%s://%s' % (schema, url_no_schema)
21+ lava_server = url_no_schema
22+
23 lava_user = os.environ.get("LAVA_USER")
24 if lava_user == None:
25 f = open('/var/run/lava/lava-user')
26@@ -279,7 +294,7 @@
27 "command": "submit_results_on_host",
28 "parameters":
29 {
30- "server": "http://validation.linaro.org/lava-server/RPC2/",
31+ "server": schema_url,
32 "stream": PRODUCT_MAP[target_product].get(
33 "test_stream", default_stream)
34 }
35@@ -310,21 +325,23 @@
36
37 print config
38
39- lava_token = os.environ.get("LAVA_TOKEN")
40- if lava_token == None:
41- f = open('/var/run/lava/lava-token')
42- lava_token = f.read().strip()
43- f.close()
44+ lava_token_f = os.environ.get("LAVA_TOKEN_FILE")
45+ if lava_token_f == None:
46+ lava_token_f = '/var/run/lava/lava-token'
47+ else:
48+ lava_token_f = '/var/run/lava/%s' % lava_token_f
49
50- lava_server = os.environ.get("LAVA_SERVER")
51- if lava_server == None:
52- lava_server = "validation.linaro.org/lava-server/RPC2/"
53+ with open(lava_token_f) as fd:
54+ lava_token = fd.read().strip()
55
56 try:
57- server = xmlrpclib.ServerProxy(
58- "https://%(lava_user)s:%(lava_token)s@%(lava_server)s" % \
59- dict(lava_user=lava_user, lava_token=lava_token,
60- lava_server=lava_server))
61+ report_url = ("%(schema)s://"
62+ "%(lava_user)s:%(lava_token)s@%(lava_server)s") % dict(
63+ schema=schema,
64+ lava_user=lava_user,
65+ lava_token=lava_token,
66+ lava_server=lava_server)
67+ server = xmlrpclib.ServerProxy(report_url)
68 lava_job_id = server.scheduler.submit_job(config)
69 lava_server_root = lava_server.rstrip("/")
70 if lava_server_root.endswith("/RPC2"):
71@@ -333,11 +350,11 @@
72 print "Error making a LAVA request:", obfuscate_credentials(str(e))
73 sys.exit(1)
74
75- print "LAVA Job Id: %s, URL: http://%s/scheduler/job/%s" % \
76- (lava_job_id, lava_server_root, lava_job_id)
77+ print "LAVA Job Id: %s, URL: %s://%s/scheduler/job/%s" % \
78+ (lava_job_id, schema, lava_server_root, lava_job_id)
79
80 json.dump({
81- 'lava_url': "http://" + lava_server_root,
82+ 'lava_url': "%s://%s" % (schema, lava_server_root),
83 'job_id': lava_job_id,
84 }, open('out/lava-job-info', 'w'))
85

Subscribers

People subscribed via source and target branches