Bookmark this page

Guided Exercise: Managing Volumes and Snapshots

In this exercise, you will deploy an instance with persistent bootable storage, create a blank volume, attach the volume to the instance, detach it, and attach it to another instance. You will deploy a new instance from a volume snapshot. Also, you will delete the created volumes and volume snapshots.

Outcomes

You should be able to:

  • Deploy an instance with persistent storage.

  • Create a blank volume, and attach and detach it.

  • Create a volume snapshot, and deploy a new instance with it.

  • Delete the volume and volume snapshot.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command ensures that all resources required for the exercise are present.

[student@workstation ~]$ lab vmdisks-volumes start

Procedure 5.3. Instructions

This guided exercise is in two parts. In part 1 you use the CLI, and in part 2 you use the Dashboard.

  1. As the developer1 user in the finance project, create a new instance with a persistent volume, and then verify the resources. Use the values in the following table:

    SettingInstance
    Instance name finance-server1
    Image rhel8
    Flavor default
    Network (private) finance-network3
    Disk Size10
    1. On workstation, source the identity environment file for the developer1 user in the finance project.

      [student@workstation ~]$ source ~/developer1-finance-rc
    2. Use the openstack server create command to create the finance-server1 instance using the information in the previous table. Add the --boot-from-volume option to create the instance with a persistent volume.

      [student@workstation ~(developer1-finance)]$ openstack server create \
      > --image rhel8 \
      > --flavor default \
      > --boot-from-volume 10 \
      > --nic net-id=finance-network3 \
      > --wait \
      > finance-server1
      
      +-----------------------------+--------------------------------------------------+
      | Field                       | Value                                            |
      +-----------------------------+--------------------------------------------------+
      | OS-DCF:diskConfig           | MANUAL                                           |
      | OS-EXT-AZ:availability_zone | nova                                             |
      | OS-EXT-STS:power_state      | Running                                          |
      | OS-EXT-STS:task_state       | None                                             |
      | OS-EXT-STS:vm_state         | active                                           |
      | OS-SRV-USG:launched_at      | 2020-06-22T00:24:52.000000                       |
      | OS-SRV-USG:terminated_at    | None                                             |
      | accessIPv4                  |                                                  |
      | accessIPv6                  |                                                  |
      | addresses                   | finance-network3=192.168.3.205                   |
      | adminPass                   | UmEXRdzRexm4                                     |
      | config_drive                |                                                  |
      | created                     | 2020-06-22T00:24:15Z                             |
      | flavor                      | default (8ff1eecb-15b4-4f32-bb99-4dec999a78c7)   |
      | hostId                      | a0de1ca783d5960886a0be1d0a8112c23618837b11244c94 |
      |                             | 17240de7                                         |
      | id                          | 758d7485-e2dc-4998-8a6d-adb9cda9fcd1             |
      | image                       |                                                  |
      | key_name                    | None                                             |
      | name                        | finance-server1                                  |
      | progress                    | 0                                                |
      | project_id                  | 3fe4ec06f5654a4d906a640d7f1a0457                 |
      | properties                  |                                                  |
      | security_groups             | name='default'                                   |
      | status                      | ACTIVE                                           |
      | updated                     | 2020-06-22T00:24:52Z                             |
      | user_id                     | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a1470b |
      |                             | ce0adcce1a5c3570                                 |
      | volumes_attached            | id='960ca587-357b-44d3-844f-b713b4be1059'        |
      +-----------------------------+--------------------------------------------------+
    3. Verify that a volume has been created and used for the finance-server1 instance. Notice the value of server_id in the output; it has the same value as the finance-server1 server ID.

      [student@workstation ~(developer1-finance)]$ openstack volume list -f json
      [
        {
          "ID": "960ca587-357b-44d3-844f-b713b4be1059",
          "Name": "",
          "Status": "in-use",
          "Size": 10,
          "Attached to": [
            {
              "id": "960ca587-357b-44d3-844f-b713b4be1059",
              "attachment_id": "a7d414c7-1ea5-4109-bec8-b9dcc505400d",
              "volume_id": "960ca587-357b-44d3-844f-b713b4be1059",
              "server_id": "758d7485-e2dc-4998-8a6d-adb9cda9fcd1",
              "host_name": null,
              "device": "/dev/vda",
              "attached_at": "2020-06-22T00:24:49.000000"
            }
          ]
        }
      ]
  2. Create a 1 GB blank volume named finance-volume2, attach it to the finance-server1 server, and verify the resources.

    1. Create a blank volume named finance-volume2. Configure the size of this volume to be 1 GB.

      [student@workstation ~(developer1-finance)]$ openstack volume create \
      > --size 1 finance-volume2
      +---------------------+----------------------------------------------------------+
      | Field               | Value                                                    |
      +---------------------+----------------------------------------------------------+
      | attachments         | []                                                       |
      | availability_zone   | nova                                                     |
      | bootable            | false                                                    |
      | consistencygroup_id | None                                                     |
      | created_at          | 2020-06-22T00:52:48.000000                               |
      | description         | None                                                     |
      | encrypted           | False                                                    |
      | id                  | dcd7baf1-d091-4c91-a305-8b547dee88e5                     |
      | multiattach         | False                                                    |
      | name                | finance-volume2                                          |
      | properties          |                                                          |
      | replication_status  | None                                                     |
      | size                | 1                                                        |
      | snapshot_id         | None                                                     |
      | source_volid        | None                                                     |
      | status              | creating                                                 |
      | type                | tripleo                                                  |
      | updated_at          | None                                                     |
      | user_id             | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a1470bce0adcce |
      |                     | 1a5c3570                                                 |
      +---------------------+----------------------------------------------------------+
    2. Verify that the finance-volume2 volume has been correctly created. Verify that the value for the status field is available.

      [student@workstation ~(developer1-finance)]$ openstack volume show \
      > -c name -c status finance-volume2
      +--------+-----------------+
      | Field  | Value           |
      +--------+-----------------+
      | name   | finance-volume2 |
      | status | available       |
      +--------+-----------------+
    3. Attach the finance-volume2 volume to the finance-server1 instance.

      [student@workstation ~(developer1-finance)]$ openstack server add volume \
      > finance-server1 finance-volume2
    4. Verify that finance-volume2 has been correctly attached to the finance-server1 instance as the /dev/vdb device.

      [student@workstation ~(developer1-finance)]$ openstack volume list \
      > -c Name -c "Attached to"
      +-----------------+------------------------------------------+
      | Name            | Attached to                              |
      +-----------------+------------------------------------------+
      | finance-volume2 | Attached to finance-server1 on /dev/vdb  |
      |                 | Attached to finance-server1 on /dev/vda  |
      +-----------------+------------------------------------------+
  3. Modify the /etc/motd file to create a message of the day. Create an XFS file system on the finance-volume2 volume, create the /volume2 directory, mount it, and create a file on it.

    1. Retrieve the console URL for the finance-server1 instance.

      [student@workstation ~(developer1-finance)]$ openstack console url show \
      > finance-server1
      +-------+------------------------------------------------------------------------+
      | Field | Value                                                                  |
      +-------+------------------------------------------------------------------------+
      | type  | novnc                                                                  |
      | url   | http://172.25.250.50:6080/vnc_auto.html?path=%3Ftoken%3Dd2ba4452-2337- |
      |       | 4052-8cf2-182e63cd06f9                                                 |
      +-------+------------------------------------------------------------------------+
    2. Open Firefox and navigate to the console URL previously obtained.

    3. Log in to finance-server1 using root as the user name and redhat as the password.

    4. Add the following lines to the /etc/motd file.

      [root@finance-server1 ~]# cat << EOF > /etc/motd
      >
      > WELCOME TO THE IMAGE FROM A SNAPSHOT
      >
      > EOF
    5. Verify in the finance-server1 instance that the finance-volume2 volume is mapped to the /dev/vdb device.

      [root@finance-server1 ~]# lsblk
      NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      vda    253:0    0  10G  0 disk
      └─vda1 253:1    0  10G  0 part /
      vdb    253:16   0   1G  0 disk
    6. Create a new partition in the /dev/vdb device.

      [root@finance-server1 ~]# parted /dev/vdb \
      > mklabel msdos \
      > mkpart primary xfs 0% 100%
      Information: You may need to update /etc/fstab.
      
      [root@finance-server1 ~]#
    7. Create an XFS file system on the /dev/vdb1 partition.

      [root@finance-server1 ~]# mkfs.xfs /dev/vdb1
      ...output omitted...
    8. Create the /volume2 directory. Mount the /dev/vdb1 partition on the /volume2 directory. Verify that the /dev/vdb1 partition has been correctly mounted.

      [root@finance-server1 ~]# mkdir /volume2
      [root@finance-server1 ~]# mount -t xfs /dev/vdb1 /volume2/
      [root@finance-server1 ~]# mount | grep /volume2
      /dev/vdb1 on /volume2 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
    9. Create the /volume2/file file.

      [root@finance-server1 ~]# echo "This is my file" > /volume2/file
    10. Verify the /volume2/file file has been created.

      [root@finance-server1 ~]# cat /volume2/file
      This is my file
    11. Unmount the /dev/vdb1 partition from the /volume2 directory.

      [root@finance-server1 ~]# umount /volume2
  4. Detach the finance-volume2 volume from the finance-server1 instance, and verify it.

    1. In the workstation terminal window, use the openstack server remove volume command to detach the volume from finance-server1.

      [student@workstation ~(developer1-finance)]$ openstack server remove volume \
      > finance-server1 finance-volume2
    2. Verify that the finance-volume2 volume has been correctly detached. Verify that the status for the finance-volume2 volume is available.

      [student@workstation ~(developer1-finance)]$ openstack volume show \
      > -c name -c status finance-volume2
      +--------+-----------------+
      | Field  | Value           |
      +--------+-----------------+
      | name   | finance-volume2 |
      | status | available       |
      +--------+-----------------+
  5. Create an image from a volume snapshot. Name it finance-server1-snapshot and verify the resources.

    1. Use the openstack server image create command to create both the snapshot and an image.

      [student@workstation ~(developer1-finance)]$ openstack server image create \
      > --name finance-server1-snapshot \
      > --wait finance-server1
      
      +------------------+-------------------------------------------------------------+
      | Field            | Value                                                       |
      +------------------+-------------------------------------------------------------+
      | checksum         | d41d8cd98f00b204e9800998ecf8427e                            |
      | container_format | bare                                                        |
      | created_at       | 2020-06-22T02:53:24Z                                        |
      | disk_format      | qcow2                                                       |
      | file             | /v2/images/205b421d-8497-45e9-8155-9c7165e0b115/file        |
      | id               | 205b421d-8497-45e9-8155-9c7165e0b115                        |
      | min_disk         | 10                                                          |
      | min_ram          | 2048                                                        |
      | name             | finance-server1-snapshot                                    |
      ...output omitted...
      | status           | active                                                      |
      | tags             |                                                             |
      | updated_at       | 2020-06-22T02:53:25Z                                        |
      | virtual_size     | None                                                        |
      | visibility       | private                                                     |
      +------------------+-------------------------------------------------------------+
    2. Verify that the finance-server1-snapshot snapshot has been created.

      [student@workstation ~(developer1-finance)]$ openstack volume snapshot list \
      > -c Name -c Status
      +---------------------------------------+-----------+
      | Name                                  | Status    |
      +---------------------------------------+-----------+
      | snapshot for finance-server1-snapshot | available |
      +---------------------------------------+-----------+
  6. Create a new instance with the finance-server1-snapshot image, and then verify the resources. Use the values in the following table:

    SettingInstance
    Instance name finance-server2
    Image finance-server1-snapshot
    Flavor default
    Network (private) finance-network3
    1. Use the openstack server create command to create the finance-server2 instance using the information in the previous table.

      [student@workstation ~(developer1-finance)]$ openstack server create \
      > --image finance-server1-snapshot \
      > --flavor default \
      > --nic net-id=finance-network3 \
      > --wait \
      > finance-server2
      
      +-----------------------------+--------------------------------------------------+
      | Field                       | Value                                            |
      +-----------------------------+--------------------------------------------------+
      | OS-DCF:diskConfig           | MANUAL                                           |
      | OS-EXT-AZ:availability_zone | nova                                             |
      | OS-EXT-STS:power_state      | Running                                          |
      | OS-EXT-STS:task_state       | None                                             |
      | OS-EXT-STS:vm_state         | active                                           |
      | OS-SRV-USG:launched_at      | 2020-06-22T03:26:36.000000                       |
      | OS-SRV-USG:terminated_at    | None                                             |
      | accessIPv4                  |                                                  |
      | accessIPv6                  |                                                  |
      | addresses                   | finance-network3=192.168.3.167                   |
      | adminPass                   | uvR2QtcT4ZuC                                     |
      | config_drive                |                                                  |
      | created                     | 2020-06-22T03:26:26Z                             |
      | flavor                      | default (8ff1eecb-15b4-4f32-bb99-4dec999a78c7)   |
      | hostId                      | 270d29f8ba5e76c1fd80c56d592882a1138b5d12ad0f35a1 |
      |                             | 7eac7546                                         |
      | id                          | 253ff506-7d33-4269-8d29-49d897c2602c             |
      | image                       | finance-server1-snapshot                         |
      |                             | (205b421d-8497-45e9-8155-9c7165e0b115)           |
      | key_name                    | None                                             |
      | name                        | finance-server2                                  |
      | progress                    | 0                                                |
      | project_id                  | 3fe4ec06f5654a4d906a640d7f1a0457                 |
      | properties                  |                                                  |
      | security_groups             | name='default'                                   |
      | status                      | ACTIVE                                           |
      | updated                     | 2020-06-22T03:26:37Z                             |
      | user_id                     | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a1470b |
      |                             | ce0adcce1a5c3570                                 |
      | volumes_attached            | id='4053e1de-62bb-470a-8fc3-b6bbdaaa2590'        |
      +-----------------------------+--------------------------------------------------+
    2. Verify that the finance-server2 instance uses /dev/vda for its persistent storage. Notice in the output the value of server_id; it is the same as the ID for finance-server2.

      [student@workstation ~(developer1-finance)]$ openstack volume list -f json
      [
        {
          "ID": "4053e1de-62bb-470a-8fc3-b6bbdaaa2590",
          "Name": "",
          "Status": "in-use",
          "Size": 10,
          "Attached to": [
            {
              "id": "4053e1de-62bb-470a-8fc3-b6bbdaaa2590",
              "attachment_id": "63c115a7-7d5b-48ab-8f4c-f1d545a1e209",
              "volume_id": "4053e1de-62bb-470a-8fc3-b6bbdaaa2590",
              "server_id": "253ff506-7d33-4269-8d29-49d897c2602c",
              "host_name": null,
              "device": "/dev/vda",
              "attached_at": "2020-06-22T03:26:33.000000"
            }
          ]
        },
      ...output omitted...
      ]
  7. Verify the message of the day in the /etc/motd file on the finance-server2 instance. Attach the finance-volume2 volume to the finance-server2 instance and verify the file on it.

    1. Attach the finance-volume2 volume to the finance-server2 instance.

      [student@workstation ~(developer1-finance)]$ openstack server add volume \
      > finance-server2 finance-volume2
    2. Verify that finance-volume2 has been correctly attached to the finance-server2 instance as the /dev/vdb device.

      [student@workstation ~(developer1-finance)]$ openstack volume list \
      > -c Name -c "Attached to"
      +-----------------+------------------------------------------+
      | Name            | Attached to                              |
      +-----------------+------------------------------------------+
      |                 | Attached to finance-server2 on /dev/vda  |
      | finance-volume2 | Attached to finance-server2 on /dev/vdb  |
      |                 | Attached to finance-server1 on /dev/vda  |
      +-----------------+------------------------------------------+
    3. Retrieve the console URL for the finance-server2 instance.

      [student@workstation ~(developer1-finance)]$ openstack console url show \
      > finance-server2
      +-------+------------------------------------------------------------------------+
      | Field | Value                                                                  |
      +-------+------------------------------------------------------------------------+
      | type  | novnc                                                                  |
      | url   | http://172.25.250.50:6080/vnc_auto.html?path=%3Ftoken%3Db57c1498-5b5a- |
      |       | 4093-9234-a5f30bb8cfd3                                                 |
      +-------+------------------------------------------------------------------------+
    4. Open Firefox and navigate to the console URL previously obtained.

    5. Log in to finance-server2 using root as the user name and redhat as the password.

    6. Notice the message after you have logged in.

      finance-server2 login: root
      Password:
      Last login: Mon Jun 22 15:25:58 on tty1
      
      WELCOME TO THE IMAGE FROM A SNAPSHOT
      
      [root@finance-server2 ~]#
    7. Verify in the finance-server2 instance that the finance-volume2 volume is mapped to the /dev/vdb device.

      [root@finance-server2 ~]# lsblk
      NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
      vda    253:0    0   10G  0 disk
      └─vda1 253:1    0   10G  0 part /
      vdb    253:16   0    1G  0 disk
      └─vdb1 253:17   0 1023M  0 part
    8. Mount the /dev/vdb1 partition on the /volume2 directory. The directory /volume2 must be created.

      [root@finance-server1 ~]# mount -t xfs /dev/vdb1 /volume2/
    9. Display the contents of the /volume2/file file.

      [root@finance-server2 ~]# cat /volume2/file
      This is my file
  8. Delete the finance-server2 instance with its volume, and finance-server1-snapshot snapshot.

    1. In the terminal window on workstation, review the volumes and where they are mounted. Determine which volume ID is attached as /dev/vda/ in the finance-server2 instance.

      [student@workstation ~(developer1-finance)]$ openstack volume list \
      > -c ID -c "Attached to"
      +--------------------------------------+-----------------------------------------+
      | ID                                   | Attached to                             |
      +--------------------------------------+-----------------------------------------+
      | 83d6a764-c41c-4569-9fe7-03be4cccb0b6 | Attached to finance-server2 on /dev/vda |
      | 4439d1b9-a428-41ad-8dad-cbebc3dfccf3 | Attached to finance-server2 on /dev/vdb |
      | 71cb3ed1-8ed2-494f-bca8-61fdf7b24daf | Attached to finance-server1 on /dev/vda |
      +--------------------------------------+-----------------------------------------+
    2. Delete the finance-server2 instance.

      [student@workstation ~(developer1-finance)]$ openstack server delete \
      > finance-server2
    3. Delete the finance-server2 volume.

      [student@workstation ~(developer1-finance)]$ openstack volume delete \
      > 83d6a764-c41c-4569-9fe7-03be4cccb0b6
    4. Verify that the finance-server2 volume has been deleted.

      [student@workstation ~(developer1-finance)]$ openstack volume list \
      > -c Name -c "Attached to"
      +-----------------+------------------------------------------+
      | Name            | Attached to                              |
      +-----------------+------------------------------------------+
      | finance-volume2 |                                          |
      |                 | Attached to finance-server1 on /dev/vda  |
      +-----------------+------------------------------------------+
    5. List the volume snapshot.

      [student@workstation ~(developer1-finance)]$ openstack volume snapshot list
      +-----------------------+-----------------------+-------------+-----------+------+
      | ID                    | Name                  | Description | Status    | Size |
      +-----------------------+-----------------------+-------------+-----------+------+
      | 53b88d27-2c10-4578-bf | snapshot for finance- |             | available |   10 |
      | ba-94f59bc04bb0       | server1-snapshot      |             |           |      |
      +-----------------------+-----------------------+-------------+-----------+------+
    6. Delete the finance-server1-snapshot volume snapshot.

      [student@workstation ~(developer1-finance)]$ openstack volume snapshot delete \
      > 53b88d27-2c10-4578-bfba-94f59bc04bb0

      Note

      Use the Dashboard to perform the following steps.

  9. In the Dashboard, as developer1, create an instance with a persistent volume.

    1. Log in to the Dashboard at http://dashboard.overcloud.example.com as developer1, using Example as the domain and redhat as the password. Confirm that the selected project is finance.

    2. Navigate to ProjectComputeInstances and then click Launch Instance.

      On the Details tab, enter finance-server3 in the Instance Name field.

      On the Source tab, select Image from the SelectBoot Source list. Set the Create New Volume to Yes. Click to select rhel8 as the image.

      On the Flavor tab, click to select default as the flavor.

      On the Networks tab, ensure that the finance-network3 network has been allocated.

    3. Click Launch Instance to launch the finance-server3 instance.

    4. Verify that a volume has been created and used for the finance-server3 instance.

      Navigate to ProjectVolumesVolumes.

  10. Create a 1 GB blank volume named finance-volume4 and attach it to the finance-server3 instance.

    1. Navigate to ProjectVolumesVolumes and click Create Volume.

      Enter finance-volume4 in the Volume Name field. Select 1 in the Size (GiB) field. Click Create Volume to create the volume.

    2. Select Manage Attachments in the Actions menu for finance-volume4.

    3. Select finance-server3 in the Attach to Instance field, and then click Attach Volume.

    4. Verify that the Attached To field sets the finance-volume4 mapping to /dev/vdb on finance-server3.

  11. Detach the finance-volume4 volume from the finance-server3 instance.

    1. Navigate to ProjectVolumesVolumes and then click Manage Attachments in the menu for the finance-volume4 volume.

    2. Click Detach Volume for finance-server3. Click Detach Volume again in the window to confirm.

    3. Verify that the finance-volume4 volume status is Available.

  12. Create an image from the finance-server3 volume snapshot.

    1. Navigate to ProjectComputeInstances and then click Create Snapshot for finance-server3.

    2. Enter finance-server3-snapshot in the Snapshot Name field. Click Create Snapshot to create the volume snapshot.

    3. Verify that the finance-server3-snapshot snapshot has been created.

      Navigate to ProjectVolumesSnapshots.

  13. Create an instance with the finance-server3-snapshot volume snapshot.

    1. Navigate to ProjectComputeInstances and then click Launch Instance.

      On the Details tab, enter finance-server4 in the Instance Name field.

      On the Source tab, select Volume Snapshot from the Select Boot Source list. Set the Delete Volume on Instance Delete to Yes. Click to select finance-server3-snapshot as the volume snapshot.

      On the Flavor tab, click to select default as the flavor.

      On the Networks tab, ensure that the finance-network3 network has been allocated.

    2. Click Launch Instance to launch the finance-server4 instance.

    3. In the Power State column, verify that the status is Running.

  14. Delete the finance-server4 instance and the finance-server3-snapshot snapshot.

    1. Navigate to ProjectComputeInstances.

    2. Delete finance-server4 instance by selecting Delete Instance from the actions menu.

      Click Delete Instance again in the window to confirm.

    3. Navigate to ProjectVolumesSnapshots.

    4. Delete the finance-server3-snapshot volume snapshot by selecting Delete Volume Snapshot from the actions menu.

      Click Delete Volume Snapshot again in the window to confirm.

Finish

On the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab vmdisks-volumes finish

This concludes the guided exercise.

Revision: cl110-16.1-4c76154