API Access¶
Requirements¶
For advanced use cases and automation it is necessary to use the Openstack API endpoints directly.
Install the Openstack command line client¶
We recommend installing the client in a Python virtual environment running on linux. If you do not run this locally we recommend setting up a virtual machine in the platform and perform the installation below there.
Then you will have a working host in the environment from which to run all API commands.
Linux¶
First install the necessary OS packages depending on what distribution you are using. If the python-virtualenvwrapper package is not available you might have to install epel-release first.
Fedora or CentOS
$ yum install python-devel python-pip python-virtualenvwrapper gcc
Ubuntu or Debian
$apt-get install python3-dev python3-pip virtualenvwrapper build-essential
Installing the client using virtualenvwrapper and pip Restart your shell. Create a virtualenv and install the client into it.
$ mkvirtualenv oscli
pip install --upgrade pip
pip install python-openstackclient python-neutronclient
$ # to activate it
workon oscli
# to exit, when finished
deactivate
Configuration credentials¶
Under "Application Credentials" in the portal create a set of credentials. You only need to set a name and if needed an expiration date. Leave all other settings untouched. When you have created credentials you will be asked to download an OpenStack rc file. If you have installed the API tools on a host running in the infrastructure copy the file to that host with scp:
$ # For an ubuntu API host
scp -i your-private-key.pem <downloaded-openstackrc> ubuntu@<IP of VM>:.
# For a Debian host
scp -i your-private-key.pem <downloaded-openstackrc> debian@<IP of VM>:.
# For a Fedora or CentOS host
scp -i your-private-key.pem <downloaded-openstackrc> cloud-user@<IP of VM>:.
$ workon oscli
source <downloaded-openstackrc>
openstack token issue