Updates to the release scripts
Change-Id: I4584bd5c66c22bb2ffe3d8f73923cff8807d5008
Showing
3 changed files
with
68 additions
and
2 deletions
... | @@ -18,6 +18,7 @@ cd $ONOS_ROOT | ... | @@ -18,6 +18,7 @@ cd $ONOS_ROOT |
18 | 18 | ||
19 | # Change the version | 19 | # Change the version |
20 | onos-change-version $NEW_VERSION | 20 | onos-change-version $NEW_VERSION |
21 | +export ONOS_VERSION=$NEW_VERSION | ||
21 | 22 | ||
22 | # Build ONOS & deploy to staging repo using the release profile. | 23 | # Build ONOS & deploy to staging repo using the release profile. |
23 | onos-build && onos-package && mvn -Prelease clean deploy -DskipTests | 24 | onos-build && onos-package && mvn -Prelease clean deploy -DskipTests | ... | ... |
... | @@ -2,9 +2,11 @@ | ... | @@ -2,9 +2,11 @@ |
2 | # ----------------------------------------------------------------------------- | 2 | # ----------------------------------------------------------------------------- |
3 | # Uploads ONOS distributable bits. | 3 | # Uploads ONOS distributable bits. |
4 | # ----------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------- |
5 | - | ||
6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | 5 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
7 | . $ONOS_ROOT/tools/build/envDefaults | 6 | . $ONOS_ROOT/tools/build/envDefaults |
8 | 7 | ||
9 | -# TODO: upload to EC2 | 8 | +#FIXME need to export s3Creds |
9 | +#FIXME verify that ONOS_VERSION is set | ||
10 | 10 | ||
11 | +# upload to EC2 | ||
12 | +upload-to-s3 -d release/ /tmp/onos-$ONOS_VERSION.* | ... | ... |
tools/build/upload-to-s3
0 → 100755
1 | +#!/usr/bin/python | ||
2 | + | ||
3 | +""" | ||
4 | +Upload a file to S3 | ||
5 | +""" | ||
6 | + | ||
7 | +from sys import argv, stdout | ||
8 | +from time import time | ||
9 | +from os.path import basename | ||
10 | +from optparse import OptionParser | ||
11 | + | ||
12 | +from boto.s3.key import Key | ||
13 | +from boto.s3.connection import S3Connection | ||
14 | + | ||
15 | + | ||
16 | +def uploadFile( bucket, filename, dest=None ): | ||
17 | + "Upload a file to a bucket" | ||
18 | + if not bucket: | ||
19 | + bucket = 'onos' | ||
20 | + if not dest: | ||
21 | + key = basename( filename ) | ||
22 | + else: | ||
23 | + key = dest + basename( filename ) #FIXME add the / | ||
24 | + print '* Uploading', filename, 'to bucket', bucket, 'as', key | ||
25 | + stdout.flush() | ||
26 | + start = time() | ||
27 | + def callback( transmitted, size ): | ||
28 | + "Progress callback for set_contents_from_filename" | ||
29 | + elapsed = time() - start | ||
30 | + percent = 100.0 * transmitted / size | ||
31 | + kbps = .001 * transmitted / elapsed | ||
32 | + print ( '\r%d bytes transmitted of %d (%.2f%%),' | ||
33 | + ' %.2f KB/sec ' % | ||
34 | + ( transmitted, size, percent, kbps ) ), | ||
35 | + stdout.flush() | ||
36 | + conn = S3Connection() | ||
37 | + bucket = conn.get_bucket( bucket ) | ||
38 | + k = Key( bucket ) | ||
39 | + k.key = key | ||
40 | + k.set_contents_from_filename( filename, cb=callback, num_cb=100 ) | ||
41 | |||
42 | + elapsed = time() - start | ||
43 | + print "* elapsed time: %.2f seconds" % elapsed | ||
44 | + | ||
45 | +if __name__ == '__main__': | ||
46 | + usage = "Usage: %prog [options] <file to upload>" | ||
47 | + parser = OptionParser(usage=usage) | ||
48 | + parser.add_option("-b", "--bucket", dest="bucket", | ||
49 | + help="Bucket on S3") | ||
50 | + parser.add_option("-d", "--dest", dest="dest", | ||
51 | + help="Destination path in bucket") | ||
52 | + parser.add_option("-k", "--key", dest="awsKey", | ||
53 | + help="Bucket on S3") | ||
54 | + parser.add_option("-s", "--secret", dest="awsSecret", | ||
55 | + help="Bucket on S3") | ||
56 | + (options, args) = parser.parse_args() | ||
57 | + | ||
58 | + if len( args ) == 0: | ||
59 | + parser.error("missing filenames") | ||
60 | + for file in args: | ||
61 | + uploadFile( options.bucket, file, options.dest ) | ||
62 | + | ||
63 | + #FIXME key and secret are unused |
-
Please register or login to post a comment