Updating upload-bits scripts for nightly pushes
Change-Id: I84669b5a13c4f033cd564050254e0c6a44eb1431
Showing
3 changed files
with
50 additions
and
7 deletions
| ... | @@ -6,7 +6,6 @@ | ... | @@ -6,7 +6,6 @@ |
| 6 | . $ONOS_ROOT/tools/build/envDefaults | 6 | . $ONOS_ROOT/tools/build/envDefaults |
| 7 | 7 | ||
| 8 | #FIXME need to export s3Creds | 8 | #FIXME need to export s3Creds |
| 9 | -#FIXME verify that ONOS_VERSION is set | 9 | +#TODO we could verify that ONOS_VERSION is set, and only upload that version |
| 10 | 10 | ||
| 11 | -# upload to EC2 | 11 | +python onosUploadBits.py |
| 12 | -upload-to-s3 -d release/ /tmp/onos-$ONOS_VERSION.* | ... | ... |
tools/build/onosUploadBits.py
0 → 100755
| 1 | +#!/usr/bin/env python | ||
| 2 | +# ----------------------------------------------------------------------------- | ||
| 3 | +# Uploads ONOS distributable bits. | ||
| 4 | +# ----------------------------------------------------------------------------- | ||
| 5 | + | ||
| 6 | +#FIXME need to export s3Creds | ||
| 7 | + | ||
| 8 | +import re | ||
| 9 | +from os import listdir | ||
| 10 | +from os.path import isfile, join | ||
| 11 | + | ||
| 12 | +from uploadToS3 import uploadFile | ||
| 13 | + | ||
| 14 | +nightlyTag = 'NIGHTLY' | ||
| 15 | +bitsPath = '/tmp' | ||
| 16 | + | ||
| 17 | +prefix = 'onos-(\d+\.\d+\.\d+)' | ||
| 18 | +buildNum = '\.?([\w-]*)' | ||
| 19 | +ext = '\.(?:tar\.gz|zip)' | ||
| 20 | + | ||
| 21 | +def findBits( path ): | ||
| 22 | + for file in listdir( path ): | ||
| 23 | + filePath = join( path, file ) | ||
| 24 | + if not isfile( filePath ): | ||
| 25 | + continue | ||
| 26 | + | ||
| 27 | + regex = prefix + buildNum + ext | ||
| 28 | + match = re.match( regex, file ) | ||
| 29 | + if match: | ||
| 30 | + version = match.group(1) | ||
| 31 | + build = match.group(2) | ||
| 32 | + if build: | ||
| 33 | + if 'NIGHTLY' in build: | ||
| 34 | + uploadFile(filePath, dest='nightly/') | ||
| 35 | + else: | ||
| 36 | + #no build; this is a release | ||
| 37 | + uploadFile(filePath, dest='release/') | ||
| 38 | + | ||
| 39 | +if __name__ == '__main__': | ||
| 40 | + findBits( '/tmp' ) | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | -#!/usr/bin/python | 1 | +#!/usr/bin/env python |
| 2 | - | ||
| 3 | """ | 2 | """ |
| 4 | Upload a file to S3 | 3 | Upload a file to S3 |
| 5 | """ | 4 | """ |
| ... | @@ -13,7 +12,7 @@ from boto.s3.key import Key | ... | @@ -13,7 +12,7 @@ from boto.s3.key import Key |
| 13 | from boto.s3.connection import S3Connection | 12 | from boto.s3.connection import S3Connection |
| 14 | 13 | ||
| 15 | 14 | ||
| 16 | -def uploadFile( bucket, filename, dest=None ): | 15 | +def uploadFile( filename, dest=None, bucket=None, overwrite=False ): |
| 17 | "Upload a file to a bucket" | 16 | "Upload a file to a bucket" |
| 18 | if not bucket: | 17 | if not bucket: |
| 19 | bucket = 'onos' | 18 | bucket = 'onos' |
| ... | @@ -37,10 +36,13 @@ def uploadFile( bucket, filename, dest=None ): | ... | @@ -37,10 +36,13 @@ def uploadFile( bucket, filename, dest=None ): |
| 37 | bucket = conn.get_bucket( bucket ) | 36 | bucket = conn.get_bucket( bucket ) |
| 38 | k = Key( bucket ) | 37 | k = Key( bucket ) |
| 39 | k.key = key | 38 | k.key = key |
| 39 | + if overwrite or not k.exists(): | ||
| 40 | k.set_contents_from_filename( filename, cb=callback, num_cb=100 ) | 40 | k.set_contents_from_filename( filename, cb=callback, num_cb=100 ) |
| 41 | 41 | ||
| 42 | elapsed = time() - start | 42 | elapsed = time() - start |
| 43 | print "* elapsed time: %.2f seconds" % elapsed | 43 | print "* elapsed time: %.2f seconds" % elapsed |
| 44 | + else: | ||
| 45 | + print 'file', basename( filename ), 'already exists in', bucket.name | ||
| 44 | 46 | ||
| 45 | if __name__ == '__main__': | 47 | if __name__ == '__main__': |
| 46 | usage = "Usage: %prog [options] <file to upload>" | 48 | usage = "Usage: %prog [options] <file to upload>" |
| ... | @@ -53,11 +55,13 @@ if __name__ == '__main__': | ... | @@ -53,11 +55,13 @@ if __name__ == '__main__': |
| 53 | help="Bucket on S3") | 55 | help="Bucket on S3") |
| 54 | parser.add_option("-s", "--secret", dest="awsSecret", | 56 | parser.add_option("-s", "--secret", dest="awsSecret", |
| 55 | help="Bucket on S3") | 57 | help="Bucket on S3") |
| 58 | + parser.add_option("-f", "--force", dest="overwrite", | ||
| 59 | + help="Overwrite existing file") | ||
| 56 | (options, args) = parser.parse_args() | 60 | (options, args) = parser.parse_args() |
| 57 | 61 | ||
| 58 | if len( args ) == 0: | 62 | if len( args ) == 0: |
| 59 | parser.error("missing filenames") | 63 | parser.error("missing filenames") |
| 60 | for file in args: | 64 | for file in args: |
| 61 | - uploadFile( options.bucket, file, options.dest ) | 65 | + uploadFile( file, options.dest, options.bucket, options.overwrite ) |
| 62 | 66 | ||
| 63 | #FIXME key and secret are unused | 67 | #FIXME key and secret are unused | ... | ... |
-
Please register or login to post a comment