Creating volumes

Now that we have created a Cinder volume service, we can create volumes for use by our instances. We do this under our Ubuntu client using one of the Cinder client tools, python-cinderclient, so we are creating volumes specific to our tenancy (project).

Getting ready

To begin with, ensure you are logged in to your Ubuntu client that has access to the Cinder client tools. If using the Vagrant environment that accompanies the book, you can access these tools from the cinder node:

vagrant ssh cinder

This recipe assumes you have created an openrc file. To create an openrc file on each node where you need it, open a text file named openrc and add the following contents:

export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/
export OS_KEY=/path/to/cakey.pem
export OS_CACERT=/path/to/ca.pem

These packages can be installed using the following command:

sudo apt-get update
sudo apt-get install python-cinderclient

How to do it...

Carry out the following steps to create a volume using Cinder client:

  1. First create the volume that we will attach to our instance by running the following command:
    source openrc
    cinder create --display-name cookbook 1
    
  2. On completion, the command returns the following output:
    How to do it...

How it works...

Creating Cinder volumes for use within our project, cookbook, is very straightforward.

With the Cinder client, we use the create option with the following syntax:

cinder create --display_name volume_name size_Gb

Here, volume_name can be any arbitrary name with no spaces. We can see the actual LVM volumes on cinder-volumes, using the usual LVM tools, as follows:

sudo lvdisplay cinder-volumes

You will get the following output:

How it works...

Notice the LV name matches the ID of the volume created with Cinder.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset