Access a project via CLI
Each OpenStack project has a related client project that includes Python API bindings and a CLI.
Prerequisites
- A project
- A user
- Python 2.7 or later installed
Overview
Requirements
To install all clients you will first need to install pip as follow:
# easy_install pip
# apt install python-dev python-pip
# easy_install pip
# yum install python-devel python-pip
Main clients
Openstack
# pip install python-openstackclient
Magnum
# pip install python-magnumclient
Octavia
# pip install python-octaviaclient
Extras
The link below is a collection of all other clients:
https://wiki.openstack.org/wiki/OpenStackClients
Create an API user
To access a project via CLI, you will need an API user which is not the CityCloud user you used to log into the Control Panel.
- Log into the Control Panel
- Click on Create ... + in the top right corner and then select "Openstack User"
- Fill in the form and select "_member_" and "swiftoperator" as roles for the project you want to create the Openstack User for
Download the user RC-file
To be able to connect to your project via the Openstack CLI, you need to download the RC-file for your project user:
- Log into the Control Panel
- Go to Users → Openstack Users and click on the meatballs menu ( ) right next to the user you would like to use to connect to your project.
- Select "Generate RC file"
- In the pop-up window, select the project you want to download the RC-file for
- Press Download
A RC-file will then be generated and downloaded to your default download directory with the following naming convention:
<USER>--<REGION>--<PROJECT>--rc
and content:
OS_REGION_NAME=*** OS_USER_DOMAIN_NAME=*** OS_PROJECT_NAME=*** OS_AUTH_VERSION=*** OS_IDENTITY_API_VERSION=*** OS_PASSWORD=*** OS_AUTH_URL=*** OS_USERNAME=*** OS_TENANT_NAME=*** OS_PROJECT_DOMAIN_NAME=***
The file contains full access credentials to a project! Store it in a safe place.
Source the file
Go to the directory where you store the RC file and run:
$ source <USER>--<REGION>--<PROJECT>--rc
You are now ready to access your project via the command-line.
Here is a list of common commands for reference:
https://docs.openstack.org/python-openstackclient/latest/cli/command-list.html
Test connectivity
Test you can successfully connect to the project by running:
$ openstack project list +---------------------------+-------------+ | ID | Name | +-----------------------------------------+ | ae048391b2654f.... | MyProject | +---------------------------+-------------+