Now that we have configured OpenStack Object Storage, we can also retrieve the stored objects using our swift
client.
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. This has the python-swiftclient
package installed 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
We will download objects from our OpenStack Object Storage environment using different swift
client options.
To download the tmp/test/test1
object, we issue the following command:
swift download test tmp/test/test1
The preceding command downloads the object to our filesystem. As we downloaded a file with the full path, this directory structure is preserved. So, we end up with a new directory structure of tmp/test
with a file called test1
.
To download the file without preserving the file structure, or to simply rename it to something else, we specify the -o
parameter:
swift download test tmp/test/test1 -o test1
We can also download complete containers to our local filesystem. To do this, we simply specify the container we want to download:
swift download test
The preceding command will download all objects found under the test
container.
We can download all objects that reside under our OpenStack Object Storage account. If we have multiple containers, all objects from all containers will be downloaded. We do this with the --all
parameter:
swift download --all
The preceding command will download all objects with full paths preceded by the container name, as shown here:
The swift
client is a basic but versatile tool that allows us to do many of the things we want to do with files. You can download objects
and containers
using the following syntax:
swift download container_name {object … }
To download an object and rename the file on the local filesystem, we use the -o
parameter to specify a different local filename:
swift download container_name object -o renamed_object
To download all objects
from our account (for example, from all containers), we specify the following syntax:
swift download --all