22.11.2023

How to Connect the SWIFT Object Storage with CLI on Ubuntu?

Introduction

Every routine, business day's in the company force us to find new solutions for every appear problems and tasks. Several of them still wait their time due to lack of needed specialist, resources and patient of manager stuff. Therefore we get unsuitable solution or in the worst way unworkable system with completed point on the paper. Haziness further plans, that's result of unstructured system. Automatization and outsource cloud platform can help to build fault-tolerance, horizontal scalable and comfortable for control system solution.

In that instruction we consider one of the services, which provide Serverspace: Object Storage — SWIFT. In contrast between usual file server's or cloud storage they represent well-structured system, that can help to contain data with their method or meta-data in the containers. Also, we will thoroughly answer on the question: How to connect with CLI to them?

Setup CLI

First of all steps we need to update our indexes and installation package's. For the Ubuntu we will use apt manager:

apt update && apt upgrade

Screenshot №1 — Update package

After that we have to install Python packet manager where we will search and download client utility for the control our storage:

apt install python3-pip

Screenshot №2 — Download pip

Go ahead and download client for our storage:

pip3 install python-swiftclient python-keystoneclient

Screenshot №3 — Download SWIFT client

Commonly, on the Linux distributes we have preinstalled all package which we described above, but update them is significant part!

If you have installed python package, but pip3 can't be installed, you can use command below, which enable packet manager for python:

python -m ensurepip --default-pip

If that can't help to fix the problem, then try to delete previous version if they exist or reinstall current package.

apt reinstall python3-pip

This have to help troubleshoot our problems and give access to the main utility for control!

Configuration and Usage

We will go to the Serverspace and order the Swift Storage, if you already have them skip that step! For that we should login into the account and search in the left menu Storage:

Screenshot №4 — Main page

At the center of the screen we have see Activate button, click on this and wait about minute to deploy process. Alright! In the picture below we can see the main panel of control our storage:

Screenshot №5 — Activated storage

Ofcourse we can manipulate data from suitable Web-interface for personal use, that can be the best way. But in the corporate network we need to automate that process, let's consider that. Press Add Container and name it! Then we can upload file for further test of working our connection:

Screenshot №6 — Upload file

Find tab Credentials on the screen and click on it, we can see Swift connection part:

Screenshot №7 — Credentials

Leave this data nearby for now and open our machine with downloaded client, fill your credentials in the command below from the table. That can allow build our connection with SWIFT storage and manipulate data:

swift \
--os-storage-url $(Endpoint)/v1/AUTH_$(UserID) \
--os-password $(Password) \
--os-username $(Username) \
--os-project-name $(Project) \
--os-project-domain-name $(Domain) \
--os-auth-url $(Endpoint) \
stat -v

For our case command will look like this:

swift --os-storage-url https://ru.serverspace.store:443/v1/AUTH_c7e61e55cca64d1f91d6a3b178a833f5 --os-password 6bfa1hdD2Dzr --os-username ssio6578_admin --os-project-name ssio6578 --os-project-domain-name default --os-auth-url https://ru.serverspace.store:443/ download STORE

Screenshot №8 — Connect and download

As you can notice that command represent request to the API of storage with your credentials and subcommand download at the end of request! For checking downloaded data we used command:

ls

For simplify authorization and control our storage we have to make alias record in user login script:

echo "alias swift_request='swift --os-storage-url https://ru.serverspace.store:443/v1/AUTH_c7e61e55cca64d1f91d6a3b178a833f5 --os-password 6bfa1hdD2Dzr --os-username ssio6578_admin --os-project-name ssio6578 --os-project-domain-name default --os-auth-url https://ru.serverspace.store:443/'" >> ~/.bashrc

Screenshot №9 — Make alias

You can identificate that request by any suitable name, we will use swift_request, if you changed credentials data due to reactivate storage or any else reason, just open .bashrc and changes credentials value by the command below:

nano ~/.bashrc

Necessarily! You have to save entering alias by the command:

source .bashrc

Make sure that work properly by deletion unused file with container:

swift_request delete STORE

Screenshot №10 — Check alias request

The alias swift_request execute command that we identify in the file and then add subcommand with attributes!

Conclusion

In conclusion, this guide delves into the essential steps of connecting Object Storage with SWIFT CLI on Ubuntu. By addressing the need for structured systems and highlighting the advantages of automation and outsourced cloud platforms, the tutorial provides a comprehensive walkthrough.