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.
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)]$Use the rhel8 image to create a 10 GB volume named finance-vol-rhel8. Verify that the volume has a status of available.
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 | +---------------------+---------------------------------------+
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 | +-------------------+-----------+
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.
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 | | +-----------------------------+--------------------------------------+
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 | +------------------+--------+
Create a 1 GB data volume named finance-volume1 using the CLI. Attach finance-volume1 to finance-server10.
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 | +---------------------+---------------------------------------------+
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.
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)]$
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 | +------------------------------+-----------------------------------------------+
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... +--------------------------------------+------------------+
Use the Dashboard to perform the following steps.
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 and then choose the project.
Discover the device where finance-volume1 is attached. Connect to the console of the finance-server10 instance.
Navigate to → → .
Click finance-server10.
On the Overview page, scroll to the bottom. In the section, note the device where finance-volume1 is attached.
Scroll back to the top of the Overview page and click .
Click the link.
Log in to the finance-server10 instance console using root as the user name and redhat as the password.
Partition and mount finance-volume1 on the /volume1 directory on the finance-server10 instance.
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...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...
Create an XFS file system on partition /dev/vdb1.
[root@finance-server10 ~]# mkfs.xfs /dev/vdb1
...output omitted...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
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)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/sUnmount the volume1 volume from finance-server10.
Unmount the /dev/vdb1 device from /volume1.
[root@finance-server10 ~]# umount /volume1Verify that the /dev/vdb1 device has been correctly unmounted. No mount point should be returned for the /volume1 directory.
[root@finance-server10 ~]# mount | grep /volume1Click the back button in the browser.
As developer1, use the Dashboard to create a 2 GB volume named finance-volume2.
Navigate to → → and then click .
Enter finance-volume2 in the field. Select 2 in the field. Click to create the volume.
Attach finance-volume2 to finance-server2, and verify that the device status is In-use.
Select in the menu for finance-volume2.
Select finance-server2 in the field, and then click .
Watch as the status transitions from Attaching to in-use. Verify that the field sets the finance-volume2 mapping to /dev/vdb on finance-server2.
In the Dashboard, detach finance-volume2 from the finance-server2 instance.
Navigate to → → and click in the menu for the finance-volume2 volume.
Click for finance-server2. Click again in the window to confirm.
Watch as the status transitions from Detaching to Available for the volume.
This concludes the guided exercise.