Access the Allas object storage from the CLI
- Summary
- This tutorial shows you how to activate CLI access to Allas.
- Internet
- https://github.com/CSCfi/allas-cli-utils
flowchart LR
A[Launch Terminal] --> B{Use<br>application<br>credentials}
B -->|No| C[source <code>allas_conf</code>]
B -->|Yes| D[source application credentials openrc file]
C --> E[Enter<br>CSC credentials]
E --> F[Choose project]
F --> G[Use Allas]
D --> G
Prerequisites
- An existing MyCSC project with Allas service enabled.
- CLI tools installed and possible Python virtual environment, where CLI tools are installed, activated.
Procedure
Open the terminal.
Type the command source allas_conf
. If your local username is different from the CSC username, use -u <csc-username>
parameter with the command.
source allas_conf -u <csc-username>
Type in your CSC account's password.
The script will list all projects that have the Allas service enabled. Select the project you want to use.
You will then have an active Allas connection for eight hours.
$ source allas_conf -u <csc-username>
Mode swift
Please enter CSC password for account <csc-user-name>:
Checking projects available for your account.
Please wait.
1) project_2001234 3) project_2009999 5) project_2007654
2) project_2009876 4) project_2000007 6) abort allas_conf
Please choose a project by giving an item number from the list above: 4
Configuration will be done for project: project_2000007
Protocols:
swift
allas connection configured successfully.
Connection stays active for eight hours.
$ ▁
Using application credentials
Alternatively, you can use application credentials to authenticate.
Info
You will need to have your application credentials created: Enable API access to cPouta from the CLI and create application credentials.
The following command assumes that your location is the same as the location of the downloaded file.
source <app-cred-project_200xxxx-openrc.sh>
Additional credentials are not requested as they are stored in the file.
Warning
Keep the file safe. It contains the access to your files in Allas.
Also there is no eight-hour time limit on access, but the file must be sourced again when the terminal session is closed.
Then let's create a bucket called cli-bucket-name
in the Allas:
Note
The name of the bucket (also known as a container) must be unique among all buckets in Allas. You cannot have a bucket with the same name as another user.
The bucket is created with a following command:
rclone mkdir allas:cli-bucket-name
You can check that the bucket has been created:
rclone ls allas:
Note
Make sure you include the colon after 'allas'.
Then let's create some test content to add to the bucket:
mkdir test
echo Hello > test/message
wget -P test https://a3s.fi/unique-bucket-name/less-unique-folder-name/cat-in-pool.png
And copy the freshly created content to Allas:
rclone sync test allas:cli-bucket-name
Check the changed content:
rclone ls allas:
Below is an example of the commands that have been executed so far.
$ mkdir test
$ echo Hello > test/message
$ wget -P test https://a3s.fi/unique-bucket-name/less-unique-folder-name/cat-in-pool.png
$ rclone mkdir allas:cli-bucket-name
$ rclone sync test allas:cli-bucket-name
$ rclone ls allas:
45817 cli-bucket-name/cat-in-pool.png
4 cli-bucket-name/file
$ _
Let's see how to check the object details and make the container (bucket) public.
Type in the following swift command to view details of an object:
swift stat cli-bucket-name cat-in-pool.png
And finally, make the bucket public:
swift post cli-bucket-name --read-acl ".r:*"
Here's the cat in a public pool.
The last thing to do is to clean the tracks:
rclone purge allas:cli-bucket-name
Note that from the command line, it is not necessary for the container to be empty before it is deleted.
That's it!
Now you can use the Allas service from the command line.
Further Learning
Here are some suggestions for what to read next: