OpenStack API Client Setup and Creating a Virtual Server

To connect to the OpenStack API, we need openstack-pythonclient installation and authenticate the user. I’ll explain below how to install the Python client for OpenStack. For the user, you can use any platform that provides OpenStack Cloud service.
Firstly, we must install Python Version 2.7 or later and PIP on the client that connects to the API. We’re lucky here because all the Python versions distributed after 2014 come with PIP installed. Current Linux distributions and macOS come with Python, so there’s not much left for us to do.
You can download Python 2.7 (or higher versions) from www.python.org for Windows Operating Systems and complete the setup by pressing OK and Next buttons several times.
Assuming you have installed Python and PIP, the OpenStack Python client setup steps are as follows according to different operating systems:
Windows
PIP, where Python is installed, is located under the Scripts folder. You can run the PIP or Python commands under any folder if you define the path in Windows properties under the PATH environment. I didn’t do so, so I need to run the command from where pip.exe is located.
# PS C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Scripts> .\pip.exe install python-openstackclient

macOS
# pip install python-openstackclient
If you are not the root, the below command does the trick:
# sudo -H pip install python-openstackclient
Ubuntu ve Debian
# apt install python-openstackclient
Red Hat Enterprise Linux, CentOS, or Fedora
# yum install python-openstackclient
SUSE Linux Enterprise Server
# zypper addrepo -f obs://Cloud:OpenStack:Liberty/SLE_12 Liberty
openSUSE
# zypper install python-devel python-pip
We need an RC (resource script) file for user authentication. After logging in via OpenStack Horizon, we need to go to Project > Compute > Access & Security and download the RC file we need.

In this example, we see two separate RC files as v2.0 and v3. Keystone, the OpenStack service responsible for identity, currently supports two versions. It changes in the future.

After hosting the RC file on any system where the OpenStack Python client is installed, we are granted remote access via the OpenStack API. The RC file contains the endpoint information of the OpenStack services, our user and project information, and prompt us for our password when we run it.

NOTE: A 3rd party free software is required to host the RC file in Windows operating systems. You can download the Source-OpenRC.ps1.
We can now perform any action in our OpenStack environment, within the limits of our user rights.
Example: Creating a new virtual server
For this, we need some information, such as a list of flavors and OS images available in the system.


After selecting a suitable image and flavor for our needs, we name and create our new server.

Shortly, our virtual server, named ISIM, must be created. Let’s check the status of it.

Well done!
Date Published: Oct 3, 2018