The swift
client tool allows you to easily list containers and objects within your OpenStack Object Storage account.
Ensure you are logged in to a Ubuntu host that has access to our OpenStack environment on the 192.168.100.0/24 public network. This host will be used to run client tools against the OpenStack environment created. If you are using the accompanying Vagrant environment, as described in the Preface, you can use the controller
node. It has the python-swiftclient
package that provides the swift
command-line client.
If you created this node with Vagrant, you can execute the following command:
vagrant ssh controller
Ensure you have set the following credentials (adjust the path to your certificates and key file to match your environment if not using the Vagrant environment):
export OS_TENANT_NAME=cookbook export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/ export OS_NO_CACHE=1 export OS_KEY=/vagrant/cakey.pem export OS_CACERT=/vagrant/ca.pem
Carry out the following to list objects within our OpenStack Object Storage environment.
Let's list all the objects in a container:
test
container, we issue the following command:swift list test
The preceding command will give you an output like this:
Let's list all the specific object paths in a container:
tmp/test
path, we specify this with the -p
parameter:swift list -p tmp/test test
The preceding command will list our two files:
tmp/test/test1
tmp/test/test2
-p
parameter too. For example, we issue the following command to list all files starting with tmp/ex
:swift list -p tmp/ex test
The preceding command will list files that match the string we specified:
tmp/example-500Mb
The swift
tool is a basic but versatile utility that allows us to do many of the things we want to do with files. Listing them in a way that suits the user is also possible. To simply list the contents of our container, use the following syntax:
swift list {container_name}
To list a file in a particular path within the container, we add in the -p
parameter to the syntax:
swift list -p path {container_name}