I usually create a virtualenv for swift and install it using pip3.
virtualenv swift_venv
source swift_venv/bin/activate
pip3 install python-swiftclient
Because python hates interoperating with anything.. hahaha.. I usually use a virtualenv and just activate it when ever I want to run swift.
Openstack uses a bunch of environment variables to authenticate..
These are project specific and appropriate settings are contained in the project_name-openrc.sh file which is available for download from the NeCTAR dashboard.
- Login to the dashboard
- Select the appropriate project
- Click the Access & Security link on the left hand panel
- Select the API Access tab in the centre pane.
- Click the Download OpenStack RC file button.
- Save the file somewhere you will be able to find it! It will be called
<project_name>-openrc.sh
You will need your Open Stack API key. If you don't already have one, you can get it or reset it and get a new one from the NeCTAR dashboard.
- On the dashboard, click on your username on the top right of the screen.
- Click Settings
- Click Reset Password on the left hand pane.
- Click the Reset Password button.
- Record the password somewhere as this is the only time you will ever see it on the Dashboard. If you lose it, you will need a new one!
Now you have the credentials you need, put them somewhere you can use them and find them!
Just run the shell script! Enter your password at the prompt. You need to do this each time you want to run swift...
You can check if they've been set with env
.
Once you have run the authentication shell script you can use swift.
Common commands are:
To get a list of folders in your object store.
swift list
To get a list of files in a folder
swift list <foldername>
To download a file or directory
swift download <foldername> <filename_or_directory>
To upload a file or directory (files are all < 4GB in size)
swift upload <foldername> <filename_or_directory>
To upload a file (some files are > 4GB in size)
If a file is > 4GB, you need to set swift to chunk the file. There is no automatic option for this. (Stupid swift..)
You need to use the -S option for uploads and specify a size in Bytes. :(
e.g. TO chunk a file into 2GB pieces, use -S 2000000000
swift upload -S <size_in_bytes> <foldername> <filename>
You can get help with swift --help
and swift <subcommand> --help