Launching our first Cloud instance - Openstack

  • (4.0)
  • | 717 Ratings

Instances are virtual machines that within the cloud. Now that we have a running OpenStack Compute environment and a machine image to use, it’s now time to spin up our first cloud instance! This section explains how to use the information from the nova image-list commands to refer this on the command line to launch the instance that we want.

Learn how to use OpenStack, from beginner basics to advanced techniques, with online video tutorials taught by industry experts. Enroll for Free OpenStack Training Demo!

The instance can be launched from the following sources:

1. Images uploaded to the image service
2. Instance snapshot that you took
3. An image that has been copied to a persistent volume.

Getting started

These steps are to be carried out on our Ubuntu machine under the user that has access to our OpenStack Compute credentials (as created in the Installation of command-line tools on Ubuntu recipe).
Before we spin up for our first instance, we must create the default security settings that define the access rights. We do this only once (or when we need to adjust) using the nova sec group-add -rule command under Nova client. The following set of commands gives us SSH access (Port 22) from any IP address and also allows us to ping the instance to help with troubleshooting. Note that the default group and its rules are always applied if no security group is mentioned on the command line.

1. With the Nova client installed, we use it by configuring our environment with the appropriate environment variables. We do this as follows:
export OS_TENANT_NAME=cookbook
export OS_USERNAME=demo
export OS_PASSWORD=openstack
export OS_NO_CACHE=1


Add these to a file called novarc in your home area. We can then source these credentials at each time by simply executing . novarc.

2. Using Nova Client, we can simply add the appropriate rules using the following commands:
nova sec group-add-rule default
tcp 22 22 /0
nova sec group-add-rule default
icmp -1 -1 /0

If there are no images available yet, follow the steps of the recipe Managing images with OpenStack Image Service in Chapter 2, Starting OpenStack Image Service.

Perfect guide for getting started to applied OpenStack. Access to freeOpenStack Tutorials

How to achieve it…

To launch our first instance, our environment must set up correctly, then carry out the following set of commands:

1. We first list the images available by executing the following command:
nova image-list

This should produce output like the following screenshot:

2. To launch our instance, we need this information and we specify this on the command line. For launching an instance using Nova client tools, we issue the following by using the UUID of our image that is named Ubuntu 12.04 x86_64
nova boot myInstance
–image 1d8f15b2-ddd8-4816-8610-486bf8fd0eb8 –flavor 2
–key_name demo

3. You should see output like the following screenshot when you launch an instance:
4. This will take a few brief moments to spin up. To check the status of your instances, issue the following commands:
nova list
nova show 67438c9f-4733-4fa5-92fc-7f6712da4fc5

5. This brings back output, which is similar to the output of the previous command lines, yet this time it has created the instance and is now running with a certain IP addresses assigned to it:

After a short while, you will be able to connect to this instance from our host or client where we launched our instance, using SSH, and specifying your private key to gain access:
ssh -i demo.pem ubuntu@


The default user that ships with the Ubuntu cloud images is Ubuntu.
Congratulations! We have successfully launched and connected to our first OpenStack Cloud instance.

Frequently Asked OpenStack Interview Questions

How it works…

After creating the default security settings, we made a note of our machine image identifier, UUID value, and then called a tool from Nova Client to launch our instance. Part of that command line refers to the key pair to use. We then connect to the instance using the private key as part of that key pair generated.
How does the cloud instance know what key to use? As part of the boot scripts for this image, it makes a call back to the meta- server, which is a function of the nova-api and nova-api-metadata services. The meta-server provides a go-between that bridges, our instance and the real world that the Cloud in it boot process can call . In this case, it downloads a script to inject our private key into the Ubuntu user’s

.ssh/authorized_keys file.

We can modify scripts that are called during the boot process.
When a cloud instance is launched, it generates a number of useful metrics and details about that instance. This is presented by the nova list and nova show commands. The nova list command shows a convenient short version listing the ID, name, status and IP addresses of our instance.
The type of the instance we chose is specified as an ID of 2 when using the nova boot command. The instance types supported can be listed by running the following command:

nova flavor-list

These flavors (specification of instances) are summarized as follows:


Explore OpenStack Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings. Protection Status