How to make OpenStack accessible through CLI?

Overview

OpenStack offers an integrated command-line client, allowing you to use simple commands to access the project API (collection of settings, credentials, and metadata about the application(s) you're working on). Additionally, the majority of OpenStack projects include a command-line client for each service. For instance, a nova command-line client is offered by the Compute service. The commands can be used to automate processes directly from the command line or by incorporating them into the code scripts. You can execute these commands on any computer by just entering your OpenStack credentials.

In this tutorial, we'll help you to create your own resources as a cloud user via CLI.

Get Started

Step 1: Log in to OpenStack.

Step 2: Download the rc file

An OpenStack rc file, also known as an openrc.sh file is a type of environment file that must be created in order to specify the necessary environment variables for the OpenStack command-line clients. You may download the file from your OpenStack console. The login information for all OpenStack services is stored in this project-specific environment file. The variables allow communication between OpenStack services running in the cloud and OpenStack client commands.

Download the file in your computer, as shown in the figure below:

Step 3: Working on the terminal

Open the code editor of your choice that allows SSH key authentication because it is the only way to access OpenStack instances. Here we are using MobaXterm, which you may download from here.

After setting up, run the following commands:

1. Enter into the root user:

sudo - i  

2. Install pip for python 3 with all the required dependencies and python modules:

apt install python3-pip 

3. Execute the following command to install the OpenStack client in a virtual environment.

apt install python3-openstackclient -y 

Step 4: Uploading the rc file

You may directly upload the already downloaded rc file in your code editor.

Note: If the upload option is not available, then you may create a file using the text editor and copy the data of the downloaded OpenStack rc file into the newly created file.

Step 5: Copying rc file

  1. As we are performing all the functions in the root user, you need to copy your rc file from /home/ubuntu to root, using the following command:

cp /home/ubuntu/<rc.sh file name here> /root 

2. Use the following command to list all the files in the root user directory. Below screenshot highlights the copied rc.sh file.

ls 

Step 6: Execute the rc file

  1. Source the Linux shell, on which you want to run the OpenStack commands, using the command below:

source <rc file name> 

2. Enter your Openstack console password.

Note: The entered password will not be visible on the CLI.

Step 7: Access OpenStack with CLI

The OpenStack is now ready to work directly through CLI. Now, you can access and manage your servers, instances, volumes, networks, IPs, security groups etc with the suitable commands. You can refer to the official OpenStack documentation for the same.

Last updated