Brian O'Connor

Updating upload-bits scripts for nightly pushes

Change-Id: I84669b5a13c4f033cd564050254e0c6a44eb1431
......@@ -6,7 +6,6 @@
. $ONOS_ROOT/tools/build/envDefaults
#FIXME need to export s3Creds
#FIXME verify that ONOS_VERSION is set
#TODO we could verify that ONOS_VERSION is set, and only upload that version
# upload to EC2
upload-to-s3 -d release/ /tmp/onos-$ONOS_VERSION.*
python onosUploadBits.py
......
#!/usr/bin/env python
# -----------------------------------------------------------------------------
# Uploads ONOS distributable bits.
# -----------------------------------------------------------------------------
#FIXME need to export s3Creds
import re
from os import listdir
from os.path import isfile, join
from uploadToS3 import uploadFile
nightlyTag = 'NIGHTLY'
bitsPath = '/tmp'
prefix = 'onos-(\d+\.\d+\.\d+)'
buildNum = '\.?([\w-]*)'
ext = '\.(?:tar\.gz|zip)'
def findBits( path ):
for file in listdir( path ):
filePath = join( path, file )
if not isfile( filePath ):
continue
regex = prefix + buildNum + ext
match = re.match( regex, file )
if match:
version = match.group(1)
build = match.group(2)
if build:
if 'NIGHTLY' in build:
uploadFile(filePath, dest='nightly/')
else:
#no build; this is a release
uploadFile(filePath, dest='release/')
if __name__ == '__main__':
findBits( '/tmp' )
\ No newline at end of file
#!/usr/bin/python
#!/usr/bin/env python
"""
Upload a file to S3
"""
......@@ -13,7 +12,7 @@ from boto.s3.key import Key
from boto.s3.connection import S3Connection
def uploadFile( bucket, filename, dest=None ):
def uploadFile( filename, dest=None, bucket=None, overwrite=False ):
"Upload a file to a bucket"
if not bucket:
bucket = 'onos'
......@@ -37,10 +36,13 @@ def uploadFile( bucket, filename, dest=None ):
bucket = conn.get_bucket( bucket )
k = Key( bucket )
k.key = key
k.set_contents_from_filename( filename, cb=callback, num_cb=100 )
print
elapsed = time() - start
print "* elapsed time: %.2f seconds" % elapsed
if overwrite or not k.exists():
k.set_contents_from_filename( filename, cb=callback, num_cb=100 )
print
elapsed = time() - start
print "* elapsed time: %.2f seconds" % elapsed
else:
print 'file', basename( filename ), 'already exists in', bucket.name
if __name__ == '__main__':
usage = "Usage: %prog [options] <file to upload>"
......@@ -53,11 +55,13 @@ if __name__ == '__main__':
help="Bucket on S3")
parser.add_option("-s", "--secret", dest="awsSecret",
help="Bucket on S3")
parser.add_option("-f", "--force", dest="overwrite",
help="Overwrite existing file")
(options, args) = parser.parse_args()
if len( args ) == 0:
parser.error("missing filenames")
for file in args:
uploadFile( options.bucket, file, options.dest )
uploadFile( file, options.dest, options.bucket, options.overwrite )
#FIXME key and secret are unused
......