Bookmark this page

Guided Exercise: Configuring Persistent Disks

In this exercise, you will configure persistent disks and verify a persistent disk's life cycle and storage location.

Outcomes

You should be able to:

  • Create a volume from an image.

  • Create an instance from a volume.

  • Create a data volume, attach it to an instance, and use it.

  • Delete a volume.

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-persistent start

Procedure 5.2. Instructions

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

  1. On workstation, source the identity environment file for the developer1 user in the finance project.

    [student@workstation ~]$ source ~/developer1-finance-rc
    [student@workstation ~(developer1-finance)]$
  2. Use the rhel8 image to create a 10 GB volume named finance-vol-rhel8. Verify that the volume has a status of available.

    1. Use the rhel8 image to create a 10 GB volume named finance-vol-rhel8.

      [student@workstation ~(developer1-finance)]$ openstack volume create \
      > --size 10 \
      > --image rhel8 \
      > finance-vol-rhel8
      +---------------------+---------------------------------------+
      | Field               | Value                                 |
      +---------------------+---------------------------------------+
      | attachments         | []                                    |
      | availability_zone   | nova                                  |
      | bootable            | false                                 |
      | consistencygroup_id | None                                  |
      | created_at          | 2020-05-29T05:23:12.000000            |
      | description         | None                                  |
      | encrypted           | False                                 |
      | id                  | b013db6e-78b1-4378-81aa-ca36203cef79  |
      | multiattach         | False                                 |
      | name                | finance-vol-rhel8                     |
      | properties          |                                       |
      | replication_status  | None                                  |
      | size                | 10                                    |
      | snapshot_id         | None                                  |
      | source_volid        | None                                  |
      | status              | creating                              |
      | type                | tripleo                               |
      | updated_at          | None                                  |
      | user_id             | b3bf...77638121e0abd2a5e89fa85f663570 |
      +---------------------+---------------------------------------+
    2. Verify that the finance-vol-rhel8 volume has been created correctly. Verify that the value for the Status field is available. It may take some time for the volume to change from downloading to available.

      [student@workstation ~(developer1-finance)]$ openstack volume list \
      > -c Name -c Status
      +-------------------+-----------+
      | Name              | Status    |
      +-------------------+-----------+
      | finance-vol-rhel8 | available |
      +-------------------+-----------+
  3. Launch an instance named finance-server10 using the finance-vol-rhel8 volume, the default flavor, and the finance-network1 network. Verify the status of finance-server10.

    1. Use the openstack server create command to launch an instance named finance-server10 using the finance-vol-rhel8 volume.

      [student@workstation ~(developer1-finance)]$ openstack server create \
      > --flavor default \
      > --nic net-id=finance-network1 \
      > --volume finance-vol-rhel8 \
      > finance-server10
      +-----------------------------+--------------------------------------+
      | Field                       | Value                                |
      +-----------------------------+--------------------------------------+
      | OS-DCF:diskConfig           | MANUAL                               |
      | OS-EXT-AZ:availability_zone |                                      |
      | OS-EXT-STS:power_state      | NOSTATE                              |
      | OS-EXT-STS:task_state       | scheduling                           |
      | OS-EXT-STS:vm_state         | building                             |
      | OS-SRV-USG:launched_at      | None                                 |
      | OS-SRV-USG:terminated_at    | None                                 |
      | accessIPv4                  |                                      |
      | accessIPv6                  |                                      |
      | addresses                   |                                      |
      | adminPass                   | rmcovAvLK8QK                         |
      | config_drive                |                                      |
      | created                     | 2020-05-29T05:30:26Z                 |
      | flavor                      | default (8ff1eecb...ec999a78c7)      |
      | hostId                      |                                      |
      | id                          | a992dd57-3b36-40ea-8b2f-8d2c3286e48b |
      | image                       |                                      |
      | key_name                    | None                                 |
      | name                        | finance-server10                     |
      | progress                    | 0                                    |
      | project_id                  | 4a08af8fda6a4609ad293613e0e637e3     |
      | properties                  |                                      |
      | security_groups             | name='default'                       |
      | status                      | BUILD                                |
      | updated                     | 2020-05-29T05:30:26Z                 |
      | user_id                     | b3bf...e89fa85f6649e76fd45d45a1470bce|
      | volumes_attached            |                                      |
      +-----------------------------+--------------------------------------+
    2. Verify that the status of the finance-server10 instance is ACTIVE. It may take some time for the status to become ACTIVE.

      [student@workstation ~(developer1-finance)]$ openstack server list \
      > -c Name -c Status
      +------------------+--------+
      | Name             | Status |
      +------------------+--------+
      | finance-server10 | ACTIVE |
      | finance-server2  | ACTIVE |
      +------------------+--------+
  4. Create a 1 GB data volume named finance-volume1 using the CLI. Attach finance-volume1 to finance-server10.

    1. Use the openstack volume create command to create finance-volume1.

      [student@workstation ~ (developer1-finance)]$ openstack volume create \
      > --size 1 finance-volume1
      +---------------------+---------------------------------------------+
      | Field               | Value                                       |
      +---------------------+---------------------------------------------+
      | attachments         | []                                          |
      | availability_zone   | nova                                        |
      | bootable            | false                                       |
      | consistencygroup_id | None                                        |
      | created_at          | 2020-05-28T07:58:34.000000                  |
      | description         | None                                        |
      | encrypted           | False                                       |
      | id                  | b017a769-9dbf-484d-8d04-74723445ffc7        |
      | multiattach         | False                                       |
      | name                | finance-volume1                             |
      | properties          |                                             |
      | replication_status  | None                                        |
      | size                | 1                                           |
      | snapshot_id         | None                                        |
      | source_volid        | None                                        |
      | status              | creating                                    |
      | type                | tripleo                                     |
      | updated_at          | None                                        |
      | user_id             | b3bf...6649e76fd45d45a1470bce0adcce1a5c3570 |
      +---------------------+---------------------------------------------+
    2. Verify that the status of finance-volume1 is available. It may take some time for the status to be available.

      [student@workstation ~(developer1-finance)]$ openstack volume list \
      > -c Name -c Status
      +-------------------+-----------+
      | Name              | Status    |
      +-------------------+-----------+
      | finance-volume1   | available |
      | finance-vol-rhel8 | in-use    |
      +-------------------+-----------+

      Note that the status of finance-vol-rhel8 is in-use. This is because the volume was used to launch finance-server10.

    3. Use the openstack server add command to attach the volume to finance-server10.

      [student@workstation ~ (developer1-finance)]$ openstack server add volume \
      > finance-server10 finance-volume1
      [student@workstation ~(developer1-finance)]$
    4. Use the openstack volume show command to show that the volume is attached and the status is in use. Note the ID in the attachments server_id field.

      [student@workstation ~ (developer1-finance)]$ openstack volume show \
      > finance-volume1 --max-width 80
      +------------------------------+-----------------------------------------------+
      | Field                        | Value                                         |
      +------------------------------+-----------------------------------------------+
      | attachments                  | [{'id':                                       |
      |                              | '02953368-5c25-4226-9720-2f8d68089814',       |
      |                              | 'attachment_id':                              |
      |                              | '1dce3f14-4fd0-45d9-99de-4d644bb9aa47',       |
      |                              | 'volume_id':                                  |
      |                              | '02953368-5c25-4226-9720-2f8d68089814',       |
      |                              | 'server_id':                                  |
      |                              | 'a992dd57-3b36-40ea-8b2f-8d2c3286e48b',       |
      |                              | 'host_name':                                  |
      |                              | 'compute1.overcloud.example.com', 'device':   |
      |                              | '/dev/vdb', 'attached_at':                    |
      |                              | '2020-05-29T05:49:03.000000'}]                |
      | availability_zone            | nova                                          |
      | bootable                     | false                                         |
      | consistencygroup_id          | None                                          |
      | created_at                   | 2020-05-29T05:43:38.000000                    |
      | description                  | None                                          |
      | encrypted                    | False                                         |
      | id                           | 02953368-5c25-4226-9720-2f8d68089814          |
      | multiattach                  | False                                         |
      | name                         | finance-volume1                               |
      | os-vol-tenant-attr:tenant_id | 4a08af8fda6a4609ad293613e0e637e3              |
      | properties                   |                                               |
      | replication_status           | None                                          |
      | size                         | 1                                             |
      | snapshot_id                  | None                                          |
      | source_volid                 | None                                          |
      | status                       | in-use                                        |
      | type                         | tripleo                                       |
      | updated_at                   | 2020-05-29T05:49:03.000000                    |
      | user_id                      | b3bf77638121e0abd2a5e89fa85f6649e76fd45d45a14 |
      |                              | 70bce0adcce1a5c3570                           |
      +------------------------------+-----------------------------------------------+
    5. Use the openstack server list command to list all available servers. Confirm that the ID of finance-server10 corresponds to the ID noted in the previous step. Limit the output to ID and Name.

      [student@workstation ~(developer1-finance)]$ openstack server list -c ID -c Name
      +--------------------------------------+------------------+
      | ID                                   | Name             |
      +--------------------------------------+------------------+
      | a992dd57-3b36-40ea-8b2f-8d2c3286e48b | finance-server10 |
      ...output omitted...
      +--------------------------------------+------------------+

      Note

      Use the Dashboard to perform the following steps.

  5. On workstation, open Firefox and navigate to http://dashboard.overcloud.example.com. Log in to the Dashboard as developer1, using Example as the domain and redhat as the password.

    Click Project and then choose the finance project.

  6. Discover the device where finance-volume1 is attached. Connect to the console of the finance-server10 instance.

    1. Navigate to ProjectComputeInstances.

    2. Click finance-server10.

      On the Overview page, scroll to the bottom. In the Volumes Attached section, note the device where finance-volume1 is attached.

      Scroll back to the top of the Overview page and click Console.

    3. Click the Click here to show only console link.

    4. Log in to the finance-server10 instance console using root as the user name and redhat as the password.

  7. Partition and mount finance-volume1 on the /volume1 directory on the finance-server10 instance.

    1. Verify that the device associated with the volume1 volume is available at /dev/vdb.

      [root@finance-server10 ~]# parted /dev/vdb print
      ...output omitted...
      Model: Virtio Block Device (virtblk)
      Disk /dev/vdb: 1074MB
      ...output omitted...
    2. Create a new 1 GB partition on device /dev/vdb.

      [root@finance-server10 ~]# parted /dev/vdb \
      > mklabel msdos \
      > mkpart primary xfs 1M 1G
      ...output omitted...
    3. Create an XFS file system on partition /dev/vdb1.

      [root@finance-server10 ~]# mkfs.xfs /dev/vdb1
      ...output omitted...
    4. Create the /volume1 directory. Mount the /dev/vdb1 partition on the /volume1 directory.

      [root@finance-server10 ~]# mkdir /volume1
      [root@finance-server10 ~]# mount -t xfs /dev/vdb1 /volume1
    5. Verify that the /dev/vdb1 partition has been correctly mounted.

      [root@finance-server10 ~]# mount | grep /volume1
      /dev/vdb1 on /volume1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
    6. Create a 10 MB file named /volume1/testfile

      [root@finance-server10 ~]# dd if=/dev/zero of=/volume1/testfile bs=1024k count=10
      10+0 records in
      10+0 records out
      10485760 bytes (10 MB) copied, 0.0486917 s, 215 MB/s
  8. Unmount the volume1 volume from finance-server10.

    1. Unmount the /dev/vdb1 device from /volume1.

      [root@finance-server10 ~]# umount /volume1
    2. Verify that the /dev/vdb1 device has been correctly unmounted. No mount point should be returned for the /volume1 directory.

      [root@finance-server10 ~]# mount | grep /volume1

      Click the back button in the browser.

  9. As developer1, use the Dashboard to create a 2 GB volume named finance-volume2.

    1. Navigate to ProjectVolumesVolumes and then click Create Volume.

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

  10. Attach finance-volume2 to finance-server2, and verify that the device status is In-use.

    1. Select Manage Attachments in the Actions menu for finance-volume2.

    2. Select finance-server2 in the Attach to Instance field, and then click Attach Volume.

    3. Watch as the status transitions from Attaching to in-use. Verify that the Attached To field sets the finance-volume2 mapping to /dev/vdb on finance-server2.

  11. In the Dashboard, detach finance-volume2 from the finance-server2 instance.

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

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

    3. Watch as the status transitions from Detaching to Available for the volume.

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-persistent finish

This concludes the guided exercise.

Revision: cl110-16.1-4c76154