Merge pull request #44 from chmouel/delete-accounts-improvements
Delete some account imp.
This commit is contained in:
commit
50882d90a1
@ -15,6 +15,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -28,16 +29,24 @@ MAX_RETRIES = 5
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Delete some accounts."""
|
"""Delete some accounts."""
|
||||||
if len(sys.argv) != 2:
|
parser = argparse.ArgumentParser(add_help=True)
|
||||||
print "%s NUMBER_OF_ACCOUNT_TO_DELETE" % (sys.argv[0])
|
parser.add_argument('-d', action='store_true',
|
||||||
sys.exit(1)
|
dest="dest",
|
||||||
raw_input("Are you sure you want to delete? Control-C if you don't")
|
help='Check destination')
|
||||||
time.sleep(5)
|
parser.add_argument('number', nargs=1, type=int)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
print "Are you sure you want to delete? Control-C if you don't"
|
||||||
|
time.sleep(5)
|
||||||
|
number = args.number[0]
|
||||||
|
|
||||||
number = int(sys.argv[1])
|
|
||||||
credentials = swsync.utils.get_config('auth',
|
credentials = swsync.utils.get_config('auth',
|
||||||
'keystone_origin_admin_credentials')
|
'keystone_origin_admin_credentials')
|
||||||
(tenant_name, username, password) = credentials.split(':')
|
(tenant_name, username, password) = credentials.split(':')
|
||||||
|
if args.dest:
|
||||||
|
auth_url = swsync.utils.get_config('auth', 'keystone_dest')
|
||||||
|
else:
|
||||||
auth_url = swsync.utils.get_config('auth', 'keystone_origin')
|
auth_url = swsync.utils.get_config('auth', 'keystone_origin')
|
||||||
keystone_cnx = keystoneclient.v2_0.client.Client(auth_url=auth_url,
|
keystone_cnx = keystoneclient.v2_0.client.Client(auth_url=auth_url,
|
||||||
username=username,
|
username=username,
|
||||||
@ -59,7 +68,9 @@ def main():
|
|||||||
_, containers = swiftcnx.get_account()
|
_, containers = swiftcnx.get_account()
|
||||||
for cont in containers:
|
for cont in containers:
|
||||||
_, objects = swiftcnx.get_container(cont['name'])
|
_, objects = swiftcnx.get_container(cont['name'])
|
||||||
|
print "deleting %s" % (cont['name'])
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
|
print "deleting %s/%s" % (cont['name'], obj['name'])
|
||||||
swiftcnx.delete_object(cont['name'], obj['name'])
|
swiftcnx.delete_object(cont['name'], obj['name'])
|
||||||
swiftcnx.delete_container(cont['name'])
|
swiftcnx.delete_container(cont['name'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user