+++ date = "2015-09-30" draft = false weight = 12 title = "Lab 12 - Cinder" +++
The objective of this lab is to create a block storage volume with Cinder and then attach it to a VM instance. This is the virtual equivalent of plugging a new drive into a computer. Just like a physical drive, volumes can be attached, detached, reattached, and moved between VM instances.
-
Log into Horizon as
chestercopperpot
//fa5tpa55w0rd
-
Navigate to Project > Compute > Volumes
-
Click on the button +Create Volume (Look in the upper right corner)
-
Fill out the pop-up window as follows:
Name: cargo-bay Description: new volume for vt2 Volume Source: No source, empty volume Type: iscsi Size (GB): 1 Availability Zone: Any Availability Zone
- Click the button
-
Let's attach this volume to our VM instance (vt2)
-
Under Actions click the drop down menu, and then select Manage Attachments
-
In the pop-up window, select (vt2) from the drop down menu
-
Click the Attach Volume button
The volume will now be attached and mounted by our instance (vt2). It will take 20 to 30 seconds to attach.
-
Answer the following questions:
-
Is the volume being actively used by the instance (is it in-use)?
-
Where is the volume attached on vt2?
-
Is this a bootable volume?
-
Could you detach this volume from instance vt2, and attach it to a different instance? Why might you want to do this?
-
-
We'll replicate the same steps at the CLI that we just performed in Horizon. If you get the idea, and not particularly strong at the CLI, it is alright to skip this section.
-
Issue the following commands
[root@controller ~]#
source keystonerc_chestercopperpot
[root@controller ~(keystone_chestercopperpot)]#
cinder create --display_name NASferatu 1
- The above command says, "Cinder, I want you to create a volume named NASferatu that is 1 GB in size"
-
Based on the output, answer the following questions:
-
Is this a bootable volume?
-
Is this volume encrypted?
-
What is the status?
-
-
Issue the following command to retrieve a list of cinder volumes available to the current users chestercopperpot:
[root@controller ~(keystone_chestercopperpot)]#
cinder list
-
Note the ID of the volume for NASferatu
-
Has the status changed? What is it now?
-
-
Issue the following command to retrive a list of the instances currently in operation
[root@controller ~(keystone_chestercopperpot)]#
nova list
- Note the ID of the instance vt2
-
Issue the following commnad to attach the new volume (NASferatu) to a VM instance (vt2)
[root@controller ~(keystone_chestercopperpot)]#
nova volume-attach <replace_with_ID_of_instance_vt2> <replace_with_ID_of_volume_NASferatu> auto
-
The above commands says attached NASferatu to the instance vt2, and auto assign it (alternatively you could specify /dev/vdb, /dev/vdc/, etc.)
-
The output should look similar to the following:
+----------+--------------------------------------+ | Property | Value | +----------+--------------------------------------+ | device | /dev/vdc | | id | d43ff424-684e-4aa4-953d-eb119e0c6a0d | | serverId | 5eb02b66-0e74-429a-a4d1-6c70fe18d178 | | volumeId | d43ff424-684e-4aa4-953d-eb119e0c6a0d | +----------+--------------------------------------+
-
-
Check on the status of the volume (NASferatu)
[root@controller ~(keystone_chestercopperpot)]#
cinder list
- What is the status of NASferatu?
-
Issue the following command to detach the volume from vt2
[root@controller ~(keystone_chestercopperpot)]#
nova volume-detach <replace_with_ID_of_instance_vt2> <replace_with_ID_of_volume_NASferatu>
-
Check on the status of the volume (NASferatu)
[root@controller ~(keystone_admin)]#
cinder list
- What is the status of NASferatu?
-
Now that the volume is detached, let's remove it
[root@controller ~(keystone_admin)]#
cinder delete NASferatu
-
Confirm that the volume has been deleted
[root@controller ~(keystone_admin)]#
cinder list
-
What is the state of NASferatu?
-
If it hasn't yet deleted, continue to issue the command until it is removed.
-
This section ONLY for students that finish early and are looking for a challenge. Try this out...
-
SSH into vt2
-
Create a text-file on the volume cargo-bay (Hello World! is fine)
-
Log out of the instance and then disconnect the volume from vt2
-
Start a new instance (vt3... whatever you want). Use the same security-group (http-ssh) and network as vt2
-
Attach the volume cargo-bay to the new instance vt3
-
SSH into vt3
-
Look at the new volume on vt3 and confirm it contains the file (Hello World!) that you created in step 2