Merge lp:~pfalcon/linaro-android-build-tools/new-pub-staging into lp:linaro-android-build-tools

Proposed by Paul Sokolovsky
Status: Merged
Approved by: Georgy Redkozubov
Approved revision: 596
Merged at revision: 597
Proposed branch: lp:~pfalcon/linaro-android-build-tools/new-pub-staging
Merge into: lp:linaro-android-build-tools
Diff against target: 89 lines (+22/-9)
2 files modified
utils/new-publish/propagate.py (+17/-8)
utils/new-publish/publish (+5/-1)
To merge this branch: bzr merge lp:~pfalcon/linaro-android-build-tools/new-pub-staging
Reviewer Review Type Date Requested Status
Georgy Redkozubov Approve
James Tunnicliffe (community) Approve
Review via email: mp+159652@code.launchpad.net

Description of the change

Add support to publish to staging with new publish interface. For consistency with existing script --staging (-s) option is used.

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good to me. Shame we don't have tests for this though.

review: Approve
Revision history for this message
Georgy Redkozubov (gesha) wrote :

+1

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

Well, this codebase has only unit tests, not high-level tests for this stuff, and as it's just a prototype, doesn't make much sense to invest much into that (we already have projects with broken integration tests).

597. By Paul Sokolovsky

Unset option is None, not False.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utils/new-publish/propagate.py'
2--- utils/new-publish/propagate.py 2013-04-18 04:01:55 +0000
3+++ utils/new-publish/propagate.py 2013-04-18 18:55:34 +0000
4@@ -10,7 +10,8 @@
5 import publib
6
7
8-REMOTE_HOST = "mombin.canonical.com"
9+REMOTE_HOST_PRODUCTION = "mombin.canonical.com"
10+REMOTE_HOST_STAGING = "staging.snapshots.linaro.org"
11 PUBLISH_USER_NAME = "linaro-android-build-publish"
12 TRIGGER_USER_NAME = "linaro-android-build-publish-trigger"
13 PUBLISH_KEY_FILE = "/home/ubuntu/snapshots-sync2.new/linaro-android-build-publish"
14@@ -21,17 +22,25 @@
15
16 if __name__ == "__main__":
17 optparser = optparse.OptionParser(usage="%prog")
18+ optparser.add_option("-s", "--staging", action="store_true", help="Publish to staging server")
19 optparser.add_option("--identity-publish", metavar="KEY", default=PUBLISH_KEY_FILE, help="Publish SSH key file")
20 optparser.add_option("--identity-trigger", metavar="KEY", default=TRIGGER_KEY_FILE, help="Trigger SSH key file")
21 optparser.add_option("-n", "--dry-run", action="store_true", help="Don't actually publish files, log commands")
22- optparser.add_option("--stage", default="all", help="Run only specific stage")
23+ optparser.add_option("--step", default="all", help="Run only specific step")
24 options, args = optparser.parse_args(sys.argv[1:])
25 if len(args) != 1:
26 optparser.error("Wrong number of arguments")
27
28 publib.validate_build_id(args[0])
29
30- if options.stage in ("all", "1"):
31+ if options.staging:
32+ remote_host = REMOTE_HOST_STAGING
33+ opt_staging = "-s"
34+ else:
35+ remote_host = REMOTE_HOST_PRODUCTION
36+ opt_staging = ""
37+
38+ if options.step in ("all", "1"):
39 file_list = []
40 for root, dirs, files in os.walk(os.path.join(LOCAL_UPLOAD_DIR, args[0])):
41 file_list.extend([os.path.join(root, f) for f in files])
42@@ -40,18 +49,18 @@
43 dir_list = publib.make_dir_struct(file_list, REMOTE_UPLOAD_DIR, strip=strip)
44 print "Dirs:", dir_list
45 if not options.dry_run:
46- publib.create_dir_struct(dir_list, REMOTE_HOST, PUBLISH_USER_NAME,
47+ publib.create_dir_struct(dir_list, remote_host, PUBLISH_USER_NAME,
48 options.identity_publish)
49 upload_script = publib.make_upload_script(file_list, REMOTE_UPLOAD_DIR, strip=strip)
50- publib.upload_files(upload_script, REMOTE_HOST, PUBLISH_USER_NAME,
51+ publib.upload_files(upload_script, remote_host, PUBLISH_USER_NAME,
52 options.identity_publish, options)
53
54- if options.stage in ("all", "2"):
55+ if options.step in ("all", "2"):
56 job, build = args[0].split("/")
57 client = paramiko.SSHClient()
58 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
59- client.connect(REMOTE_HOST, username=TRIGGER_USER_NAME, key_filename=TRIGGER_KEY_FILE)
60- stdin, stdout, stderr = client.exec_command("reshuffle-files -t android -j %s -n %s -m" % (job, build))
61+ client.connect(remote_host, username=TRIGGER_USER_NAME, key_filename=TRIGGER_KEY_FILE)
62+ stdin, stdout, stderr = client.exec_command("reshuffle-files -t android -j %s -n %s -m %s" % (job, build, opt_staging))
63 stdin.close()
64 print "=== stdout ==="
65 print stdout.read()
66
67=== modified file 'utils/new-publish/publish'
68--- utils/new-publish/publish 2013-04-18 12:47:51 +0000
69+++ utils/new-publish/publish 2013-04-18 18:55:34 +0000
70@@ -19,6 +19,7 @@
71 optparser.add_option("-t", "--type", help="Build type")
72 optparser.add_option("-p", "--strip", metavar="NUM", type=int, default=0,
73 help="Strip leading components from dest file names.")
74+ optparser.add_option("-s", "--staging", action="store_true", help="Publish to staging")
75 optparser.add_option("--identity-copy", metavar="KEY", default=COPY_KEY_FILE, help="SSH key file")
76 optparser.add_option("--identity-trigger", metavar="KEY", default=TRIGGER_KEY_FILE, help="SSH key file")
77 optparser.add_option("-n", "--dry-run", action="store_true", help="Don't actually publish files, log commands")
78@@ -48,7 +49,10 @@
79 upload_script = publib.make_upload_script(file_list, UPLOAD_DIR, build_id, options.strip)
80 publib.upload_files(upload_script, REMOTE_HOST, COPY_USER_NAME, options.identity_copy, options)
81
82- rc = os.system("ssh -i %s %s@%s propagate.py %s" % (options.identity_trigger, TRIGGER_USER_NAME, REMOTE_HOST, build_id))
83+ rc = os.system("ssh -i %s %s@%s propagate.py %s %s" % (options.identity_trigger,
84+ TRIGGER_USER_NAME, REMOTE_HOST,
85+ "-s" if options.staging else "",
86+ build_id))
87 if rc != 0:
88 print "Publishing failed"
89 sys.exit(1)

Subscribers

People subscribed via source and target branches