In my last post I went over over-subscription, quality of service (QoS), and compression. If you would like to see that blog article again click here. This time around I will be going over the basic operations that you can carry out using the VMAX drivers for OpenStack Cinder. The operations I will be looking at are:
- Create, list, delete, attach, and detach volumes
- Copying images to/from volumes
- Clone a volume
- Extend a volume
When going through each of the operations, I will include examples of performing that operation using the OpenStack Cinder CLI and at the end of the article there will be a video going over all functionality using the Horizon dashboard. The hope is that by the end you will be fully familiar with each operation and confident to carry them out on your own! With the formalities out of the way, lets begin…
Note: At this point it is assumed that you have fully configured your OpenStack environment for your VMAX and created a VMAX back-end with one or more volume types to provision volumes with.
1. Create, list, delete, attach, and detach volumes
Provisioning volumes and managing them in OpenStack couldn’t be easier using the Cinder CLI or dashboard, it is intuitive and at no point are you left guessing what to do next. The first operation we will look at is creating a volume.
Creating & deleting volumes
When creating a volume there are only a few things you need to know in advance:
- The size of the volume (in GB)
- The name of the volume
- The volume type
If you want to list the volume types you have created in OpenStack use the command cinder type-list. To view your volume types using the dashboard, navigate to Admin>Volume>Volume Types.
To then create a volume, use the following CLI command:
# cinder create –name <volume_name> –volume-type <vmax_vol_type> <size>
# cinder create –name vmax_vol1 –volume-type VMAX_ISCSI_DIAMOND 10
To view the details of your newly created volume, use the command:
# cinder show <volume_id>/<volume_name>
# cinder show vmax_vol1
To view all of the volumes you have created use the command cinder list. If you want to delete any of the volumes you have created the CLI command is as follows:
# cinder delete <volume_id>/<volume_name> [<volume_id>/<volume_name>…]
# cinder delete vmax_vol1
You will notice that in the cinder delete command there is the option to add another volume name or ID, if you want to delete more than one volume at a time you only need list the volumes in the one command, separating each with a space.
# cinder delete vmax_vol1 vmax_vol2 vmax_vol3
Attaching & detaching volumes
When you have created a volume for use in OpenStack, it is likely that you will want to then attach it to a compute instance for later use. It is assumed here that you already have a running Nova compute instance, it is that instance we will be attaching our VMAX volume to. In advance of this operation you need only to know the instance ID that you would like to attach the volume to, and the volume ID to be attached. If no device mount-point is specified, or the value is set to auto, OpenStack will automatically pick the next available mount-point to attach the volume to.
The required IDs can be obtained using the Nova & Cinder commands # nova list and # cinder list
Taking these IDs, you can attach a volume to the instance using the below Nova command:
# nova volume-attach <instance_id> <volume_id> [<device>/auto]
# nova volume-attach ee356911-3855-4197-a1ef-aba3437f6571 28021528-e641-4af6-8984-a6ea0815df7f /dev/vdb
To detach a volume you need only replace ‘attach’ in the command above with ‘detach, there is no need to specify the device mount-point as it is already attached to a mount-point and so not required for detach operations:
# nova volume-detach <instance_id> <volume_name/volume_id>
# nova volume-detach aaaa-bbbb-cccc-dddd vmax_vol1
2. Copying images to/from volume
Images in OpenStack are pre-configured virtual-machine images which can be used to provision volumes. This is especially useful in production environments, where you can create a master image of a volume, and use that image to provision multiple identical volumes, saving you countless time setting up each.
For this operation it is assumed that you have an image already in OpenStack Glance (image service), any image will do but for this example we are going to use a lightweight CirrOS image. The process is almost identical to provisioning a blank volume, the only difference is the addition of the –image parameter where we can specify the image name we would like to use.
# cinder create –name <volume_name> –volume-type <vmax_vol_type> –image <image_name>/<image_id> <size>
# cinder create –name vmax_cirros –volume-type VMAX_ISCSI_DIAMOND –image cirros-0.3.5-x86_64-disk 10
The outcome of the above command will be a new 10GB VMAX volume called ‘vmax_cirros’, volume type VMAX_ISCSI_DIAMOND, with the CirrOS system image copied to it. When this volume is attached to a Nova compute instance, it can be powered on to run a CirrOS virtual machine.
After setting up this virtual machine with all the necessary packages and environment configuration, it is in a state which can be used for whatever purposes the user has. To avoid having to go through the process of copying the system image to the volume each time, and configuring it as necessary, it is possible to take the configured virtual-machine and turn its present state into an image to be used to provision new virtual machines. To copy a volume to a Glance image, use the command:
# cinder upload-to-image <volume> <image-name>
# cinder upload-to-image vmax_cirros cirros_full_config
3. Cloning a volume
Cloning a volume does exactly what it says on the tin, it take a volume and copies it to make a new volume. The new volume is an exact replica of the volume at that point in time and can be used straight away to perform operations on such as attaching to a compute instance. Just like creating a volume from an image, creating a cloned volume is very similar to the create volume command. The command is the same but this time the additional parameter is –source-volid which lets us specify the source volume that we would like to create a clone from. To create a cloned volume, the command is as follows:
# cinder create –name <volume_name> –volume-type <vmax_vol_type> –source-volid <volume_id> <size>
# cinder create –name vmax_cirros_clone –volume-type VMAX_ISCSI_DIAMOND –source-volid 54249fab-3629-4017-becf-1134c7e56cf0 20
The example above will take the CirrOS volume from part 2 of this guide, and creates a bigger volume (20GB) called ‘vmax_cirros_clone’ with the same volume type as before.
4. Extending a volume
Extending a volume takes a pre-existing volume and increases its size to a size of your choosing. It is only possible to increase the size of a volume, it is not possible to make a volume smaller than its current size. Extending a volume is really straight forward using the CLI, you only have to specify the volume ID and the size you want to increase it to.
# cinder extend <volume_id> <new_size>
# cinder extend 54249fab-3629-4017-becf-1134c7e56cf0 30
To show all of the above operations using the Horizon dashboard, I have created a short demo video. Full-screen viewing of the embedded video is not possible from the DECN website, to view the video full-screen click here or click on the YouTube logo on the video controls to redirect to the video on the YouTube website.
Whats coming up in part 4 of ‘VMAX & OpenStack Ocata: An Inside Look’…
Now you can create and manage basic operations, we can start to look at some of the advanced functionality, next on the list is volume snapshots. We will be taking a look at what snapshots are, the advantages of having SnapVX backed snapshots, and how to work with them using the same methods we covered in this article.