Brian O'Connor
Committed by Gerrit Code Review

Adding test access to S3 upload script

Change-Id: Ie80ad43a8d75277a8900995049c59f7a9f4ba0e9
...@@ -44,6 +44,16 @@ def uploadFile( filename, dest=None, bucket=None, overwrite=False ): ...@@ -44,6 +44,16 @@ def uploadFile( filename, dest=None, bucket=None, overwrite=False ):
44 else: 44 else:
45 print 'file', basename( filename ), 'already exists in', bucket.name 45 print 'file', basename( filename ), 'already exists in', bucket.name
46 46
47 +def testAccess( bucket=None ):
48 + "Verify access to a bucket"
49 + if not bucket:
50 + bucket = 'onos'
51 +
52 + conn = S3Connection()
53 + bucket = conn.get_bucket( bucket )
54 + print bucket.get_acl()
55 +
56 +
47 if __name__ == '__main__': 57 if __name__ == '__main__':
48 usage = "Usage: %prog [options] <file to upload>" 58 usage = "Usage: %prog [options] <file to upload>"
49 parser = OptionParser(usage=usage) 59 parser = OptionParser(usage=usage)
...@@ -57,8 +67,14 @@ if __name__ == '__main__': ...@@ -57,8 +67,14 @@ if __name__ == '__main__':
57 help="Bucket on S3") 67 help="Bucket on S3")
58 parser.add_option("-f", "--force", dest="overwrite", 68 parser.add_option("-f", "--force", dest="overwrite",
59 help="Overwrite existing file") 69 help="Overwrite existing file")
70 + parser.add_option("-v", "--verify", dest="verify", action="store_true",
71 + help="Verify access to a bucket")
60 (options, args) = parser.parse_args() 72 (options, args) = parser.parse_args()
61 - 73 +
74 + if options.verify:
75 + testAccess(options.bucket)
76 + exit()
77 +
62 if len( args ) == 0: 78 if len( args ) == 0:
63 parser.error("missing filenames") 79 parser.error("missing filenames")
64 for file in args: 80 for file in args:
......