Skip to content

Access the compute service API

Requirements

For advanced use cases and automation it is neccessary to use the Openstack API endpoints directly.

To do this, contact support to make sure you get an API-enabled user account created for you. A federated user account from e.g SWAMID or Dataporten can't be used directly in this case.

Install the Openstack command line client

Openstack.org instructions on how to install the client can be found here. We recommend installing the client in a Python virtual environment.

Linux

First install the neccessary 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.

yum install python-devel python-pip python-virtualenvwrapper gcc
apt-get install python-dev python-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 stop or start using this virtual Python environment, type

# to activate it
workon oscli
# to exit, when finished
deactivate

Windows

Note

These instructions aren't well tested or perhaps even incomplete. Please let us know if you need help or know how to improve them!

To be able to use the Openstack client from Windows you need Python 2.7. After the installation is finished, open a command prompt:

C:
cd C:\Python27\Scripts

Use easy_install to install pip

C:\Python27\Scripts>easy_install pip

Then install python-openstackclient using pip

C:\Python27\Scripts>pip install python-openstackclient

Configuration and credentials

Create a openstackrc file with your environment information and API account credentials. On Linux, you could do it like this:

# create a config file
$ cat - >> openstackrc << EOF
<paste of rc-file from template below>
EOF
# edit it to include real credentials
vi openstackrc
# then activate it
source openstackrc

Run a command to see if it works , this command tests authentication only

openstack token issue

Terraform

Terraform is a tool to provision infrastructure on cloud platforms. It is built to be an agnostic tool which uses the same templates regardless of the underlying cloud provider.

Safespring has developed a number of Terraform modules for different kind of instances and comes with an examples directory which describes how to use them. The modules can be found at: Safespring terraform modules