5

I want to delete all files and folders using folder or container path without listing all files in it. Is it possible?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
hjjo
  • 105
  • 1
  • 6

4 Answers4

3

Note that with more recent versions of openstack, there is a --recursive option available if you're deleting any entire container:

openstack container delete --recursive mycontainer
larsks
  • 277,717
  • 41
  • 399
  • 399
  • Thanks! Is it possible from API? – Andrej Apr 13 '20 at 20:46
  • 1
    The CLI tools interact with Swift using the API, so it must be. If you run the above command with `--debug` enabled, you can see the API calls the tool is making. – larsks Apr 14 '20 at 13:26
2

You use the following 2 steps method based on swift package (https://launchpad.net/swift) - Successfully tested on debian jessie

In a terminal, once swift tool configurated, type :

# swift list | grep > yourobjectname.lst

# cat yourobjectname.lst | xargs swift delete {}

Regards

c-tools
  • 83
  • 7
1

No it's not possible with the OpenStack API that comes out-of-the-box. You need to explicity list the objects/containers and delete them using the bulk operation

Chen Xie
  • 3,849
  • 8
  • 27
  • 46
1

you can use the following command as said in this QA:

for i in $(swift list); do swift delete $i; done

Note that you need to have your environment variables for the user and project and domain set before running this command. e.g. admin-rc.sh

sajjadG
  • 2,546
  • 2
  • 30
  • 35