wave
Uncategorized

How To Get Started with Apache libcloud & OpenStack.

Mohammed Naser

Mohammed Naser

Libcloud is a Python library that provides an abstract API to interact with many popular cloud service providers. It allows you to write code once in a unified API and have it work with all the different providers that it supports.

Currently, there is an OpenStack driver for the compute component of Libcloud. It allows you to create, manage and delete all of your existing cloud servers in an OpenStack cloud. In this short tutorial, we will explain on how to get started with it on our cloud computing platform as an example.

Installation

The first step to using libcloud is to install the library on your machine. In this tutorial, we are going to assume you have a basic Python installation which you can install modules to using pip.

# pip install apache-libcloud

pip should take care of installing all the necessary dependencies for you and it will let you know once it’s installed. You can now start using it in your projects, however, you will likely need a cloud computing account somewhere to use this account.

API Credentials

Please note that this part is provider specific. We are going to demonstrate on how to get your API credentials from our cloud service, however, we are going to discuss the case of general Vanilla OpenStack clouds (such as private clouds) and what fields you need.

In order to get started with it, you will be needing the Keystone API endpoint, username, tenant name and password. Typically, you can acquire this information from Horizon if you’re running a vanilla OpenStack cloud. It will be available under “Access & Security”.

If you are using our service, you an simply login to your own control panel by logging to your customer centre and clicking on “CloudConsole”. From there, you can click on “API credentials” and you will see all your API credentials displayed there.

Getting Started

We will go over the basics of getting libcloud configured with your OpenStack cloud. The sample code below should allow you to authenticate to your private OpenStack Cloud or to our cloud computing service. In the example, we’ll be connecting to our cloud platform.

You will need to make sure that the ex_force_service_name, ex_force_service_region and other arguments are matching the ones that you are using from your cloud. If you’re not sure of those, you should be able to list them from Keystone or ask for assistance from your cloud operator.

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

import libcloud.security

# This assumes you don't have SSL set up.
# Note: Code like this poses a security risk (MITM attack) and
# that's the reason why you should never use it for anything else
# besides testing. You have been warned.
libcloud.security.VERIFY_SSL_CERT = False

OpenStack = get_driver(Provider.OPENSTACK)
driver = OpenStack('**insert_tenant_username**',
                   '**insert_tenant_password**',
                   ex_force_auth_version='2.0_password',
                   ex_force_auth_url='http://auth.api.thenebulacloud.com:5000',
                   ex_tenant_name='**insert_tenant_name**',
                   ex_force_service_name='nova',
                   ex_force_service_region='na-yul-nhs1')

Once you have that in place, you should be able to use the Compute driver like any other driver in libcloud. The documentation is very detailed and explains many different examples of using it, you can refer to the examples page for more information. You can now use libcloud to speak with your cloud service provider of choice, hopefully, us!

Would you like to know about Zuul, a CI/CD project gating tool? Download our white paper and get reading!

How to up your DevOps game with Project Gating

Share on Social Media:

OpenStack

Cluster API driver for OpenStack Magnum

Mohammed Naser

Public Cloud

9000 MTUs (jumbo frames) in all Public Cloud Regions

Mohammed Naser

Uncategorized

OpenInfra Summit Berlin 2022 VEXXHOST Recap

Mohammed Naser

Go to Top