Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / objsync / boto_del.py
1 #!/usr/bin/env python
2
3 #
4 # Ceph - scalable distributed file system
5 #
6 # Copyright (C) 2011 New Dream Network
7 #
8 # This is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License version 2.1, as published by the Free Software
11 # Foundation.  See file COPYING.
12 #
13
14 """
15 boto_del.py: simple bucket deletion program
16
17 A lot of common s3 clients can't delete weirdly named buckets.
18 But this little script can do it!
19 """
20
21 from boto.s3.connection import OrdinaryCallingFormat
22 from boto.s3.connection import S3Connection
23 from boto.s3.key import Key
24 from sys import stderr
25 import boto
26 import os
27 import sys
28
29 bucket_name = sys.argv[1]
30 conn = S3Connection(calling_format=OrdinaryCallingFormat(), is_secure=False,
31                 aws_access_key_id=os.environ["AKEY"],
32                 aws_secret_access_key=os.environ["SKEY"])
33 bucket = conn.lookup(bucket_name)
34 if (bucket == None):
35     print "bucket '%s' no longer exists" % bucket_name
36     sys.exit(0)
37
38 print "deleting bucket '%s' ..." % bucket_name
39 bucket.delete()
40 print "done."
41 sys.exit(0)