Creating an instance on OpenStack (with Neutron) using LibCloud

In my opinion, at least one of the two following statements should be true to some extent:

  1. LibCloud is poorly documented.
  2. Google ranks as more important those pages where the information about LibCloud is a total mishmash.

In any case, I struggled for quite some time to do a very basic thing, such as creating a VM in OpenStack through LibCloud, therefore, I wanted to share the outcome with the rest of the wold.

What the following code is about:

In a few words, the following code creates a VM within a particular network and associates to it a floating IP address.
The main two issues that are addressed here are:

  1. Dealing with the fact that Neutron does not support auto-assignment of floating IP addresses.
  2. Allowing the user to specify either the ID or the name of attributes (image, size, network, etc).

What the following code is NOT:

This is not supposed to be production code. In this gist, I put together some parts of my actual code just to give the idea of how I am dealing with these two problems. I don’t claim this is the only or the best way.


One thought on “Creating an instance on OpenStack (with Neutron) using LibCloud

Leave a Reply

Your email address will not be published. Required fields are marked *