Chapter 3. Performing basic operations with the Block Storage service (cinder)
Chapter 3. Performing basic operations with the Block Storage service (cinder) Create and configure Block Storage volumes as the primary form of persistent storage for Compute instances in your overcloud. Create volumes, attach your volumes to instances, edit and resize your volumes, and modify volume ownership. 3.1. Creating Block Storage volumes Create volumes to provide persistent storage for instances that you launch with the Compute service (nova) in the overcloud. To create an encrypted volume, you must first have a volume type configured specifically for volume encryption. In addition, you must configure both Compute and Block Storage services to use the same static key. For information about how to set up the requirements for volume encryption, see Block Storage service (cinder) volume encryption . Important The default maximum number of volumes you can create for a project is 10. Prerequisites Access to the Red Hat OpenStack Platform (RHOSP) Dashboard (horizon). For more information, see Introduction to the OpenStack Dashboard . Procedure Log into the dashboard. Select Project > Compute > Volumes . Click Create Volume , and edit the following fields: Field Description Volume name Name of the volume. Description Optional, short description of the volume. Type Optional volume type. For more information, see Group volume configuration with volume types . If you create a volume and do not specify a volume type, then Block Storage uses the default volume type. For more information on defining default volume types, see Defining a project-specific default volume type . If you do not specify a back end, the Block Storage scheduler will try to select a suitable back end for you. For more information, see Volume allocation on multiple back ends . Note If there is no suitable back end then the volume will not be created. You can also change the volume type after the volume has been created. For more information, see Block Storage volume retyping . Size (GB) Volume size (in gigabytes). If you want to create an encrypted volume from an unencrypted image, you must ensure that the volume size is larger than the image size so that the encryption data does not truncate the volume data. Availability Zone Availability zones (logical server groups), along with host aggregates, are a common method for segregating resources within OpenStack. Availability zones are defined during installation. For more information about availability zones and host aggregates, see Creating and managing host aggregates in the Configuring the Compute Service for Instance Creation guide. Specify a Volume Source : Source Description No source, empty volume The volume is empty and does not contain a file system or partition table. Snapshot Use an existing snapshot as a volume source. If you select this option, a new Use snapshot as a source list opens; you can then choose a snapshot from the list. If you want to create a new volume from a snapshot of an encrypted volume, you must ensure that the new volume is at least 1GB larger than the old volume. For more information about volume snapshots, see Creating new volumes from snapshots . Image Use an existing image as a volume source. If you select this option, a new Use snapshot as a source list opens; you can then choose an image from the list. Volume Use an existing volume as a volume source. If you select this option, a new Use snapshot as a source list opens; you can then choose a volume from the list. Click Create Volume . After the volume is created, its name appears in the Volumes table. 3.2. Editing a volume name or description You can change the names and descriptions of your volumes in the dashboard. Prerequisites Access to the Red Hat OpenStack Platform (RHOSP) Dashboard (horizon). For more information, see Introduction to the OpenStack Dashboard . Procedure Log into the dashboard. Select Project > Compute > Volumes . Select the volume's Edit Volume button. Edit the volume name or description as required. Click Edit Volume to save your changes. 3.3. Resizing (extending) a Block Storage service volume Resize volumes to increase the storage capacity of the volumes. Note The ability to resize a volume in use is supported but is driver dependent. RBD is supported. You cannot extend in-use multi-attach volumes. For more information about support for this feature, contact Red Hat Support. Procedure Source your credentials file. List the volumes to retrieve the ID of the volume you want to extend: Increase the size of the volume: Replace <volume_id> with the ID of the volume you want to extend. Replace <size> with the required size of this volume, in gigabytes. Note Ensure that the specified size is greater than the existing size of this volume. For example: 3.4. Deleting a Block Storage service volume You can delete volumes that you no longer require. Note You cannot delete a volume if it has existing snapshots. For more information about deleting snapshots, see Deleting volume snapshots . Prerequisites Access to the Red Hat OpenStack Platform (RHOSP) Dashboard (horizon). For more information, see Introduction to the OpenStack Dashboard . Procedure Log into the dashboard. Select Project > Compute > Volumes . In the Volumes table, select the volume to delete. Click Delete Volumes . 3.5. Volume allocation on multiple back ends When you create a volume, you can select the volume type for the required back end from the Type list. For more information, see Creating Block Storage volumes . Note If the Block Storage service (cinder) is configured to use multiple back ends, then a volume type must be created for each back end. If you do not specify a back end when creating the volume, the Block Storage scheduler will try to select a suitable back end for you. The scheduler uses filters, for the following default associated settings of the volume, to select suitable back ends: AvailabilityZoneFilter Filters out all back ends that do not meet the availability zone requirements of the requested volume. CapacityFilter Selects only back ends with enough space to accommodate the volume. CapabilitiesFilter Selects only back ends that can support any specified settings in the volume. InstanceLocality Configures clusters to use volumes local to the same node. If there is more than one suitable back end, then the scheduler uses a weighting method to pick the best back end. By default, the CapacityWeigher method is used, so that the filtered back end with the most available free space is selected. Note If there is no suitable back end then the volume will not be created. Additional resources Creating and configuring a volume type Block Storage volume retyping Configuring the default Block Storage scheduler filters 3.6. Attaching a volume to an instance When you close an instance all the data is lost. You can attach a volume for persistent storage. You can attach a volume to only one instance at a time, unless it has a multi-attach volume type. For more information about creating multi-attach volumes, see Volumes that can be attached to multiple instances . Prerequisites Access to the Red Hat OpenStack Platform (RHOSP) Dashboard (horizon). For more information, see Introduction to the OpenStack Dashboard . Procedure Log into the dashboard. Select Project > Compute > Volumes . Select the Edit Attachments action. If the volume is not attached to an instance, the Attach To Instance drop-down list is visible. From the Attach To Instance list, select the instance to which you want to attach the volume. Click Attach Volume . 3.7. Detaching a volume from an instance You must detach a volume from an instance when you want to attach this volume to another instance, unless it has a multi-attach volume type. You must also detach a volume to change the access permissions to the volume or to delete the volume. Prerequisites Access to the Red Hat OpenStack Platform (RHOSP) Dashboard (horizon). For more information, see Introduction to the OpenStack Dashboard . Procedure Log into the dashboard. Select Project > Compute > Volumes . Select the volume's Manage Attachments action. If the volume is attached to an instance, the instance's name is displayed in the Attachments table. Click Detach Volume in this and the dialog screen. steps Attaching a volume to an instance 3.8. Configuring the access rights to a volume The default state of a volume is read-write to allow data to be written to and read from it. You can mark a volume as read-only to protect its data from being accidentally overwritten or deleted. Note After changing a volume to be read-only you can change it back to read-write again. Prerequisites If the volume is already attached to an instance, then detach this volume. For more information, see Detaching a volume from an instance . Procedure Source your credentials file. List the volumes to retrieve the ID of the volume you want to configure: Set the required access rights for this volume: To set the access rights of a volume to read-only: Replace <volume_id> with the ID of the required volume. To set the access rights of a volume to read-write: If you detached this volume from an instance to change the access rights, then re-attach the volume. For more information, see Attaching a volume to an instance . 3.9. Changing a volume owner with the Dashboard To change a volume's owner, you will have to perform a volume transfer. A volume transfer is initiated by the volume's owner, and the volume's change in ownership is complete after the transfer is accepted by the volume's new owner. Prerequisites Access to the Red Hat OpenStack Platform (RHOSP) Dashboard (horizon). For more information, see Introduction to the OpenStack Dashboard . Procedure Log into the dashboard as the volume owner. Select Projects > Volumes . In the Actions column of the volume to transfer, select Create Transfer . In the Create Transfer dialog box, enter a name for the transfer and click Create Volume Transfer . The volume transfer is created, and in the Volume Transfer screen you can capture the transfer ID and the authorization key to send to the recipient project. Click the Download transfer credentials button to download a .txt file containing the transfer name , transfer ID , and authorization key . Note The authorization key is available only in the Volume Transfer screen. If you lose the authorization key, you must cancel the transfer and create another transfer to generate a new authorization key. Close the Volume Transfer screen to return to the volume list. The volume status changes to awaiting-transfer until the recipient project accepts the transfer Accept a volume transfer from the dashboard Log into the dashboard as the recipient project owner. Select Projects > Volumes . Click Accept Transfer . In the Accept Volume Transfer dialog box, enter the transfer ID and the authorization key that you received from the volume owner and click Accept Volume Transfer . The volume now appears in the volume list for the active project. 3.10. Changing a volume owner with the CLI To change a volume's owner, you will have to perform a volume transfer. A volume transfer is initiated by the volume's owner, and the volume's change in ownership is complete after the transfer is accepted by the volume's new owner. Procedure Log in as the volume's current owner. List the available volumes: Initiate the volume transfer: Replace <volume> with the name or ID of the volume you wish to transfer. For example: The cinder transfer-create command clears the ownership of the volume and creates an id and auth_key for the transfer. These values can be given to, and used by, another user to accept the transfer and become the new owner of the volume. The new user can now claim ownership of the volume. To do so, the user should first log in from the command line and run: Replace <transfer_id> with the id value returned by the cinder transfer-create command. Replace <transfer_key> with the auth_key value returned by the cinder transfer-create command. For example: Note You can view all available volume transfers using:
cinder list cinder extend <volume_id> <size> cinder extend 573e024d-5235-49ce-8332-be1576d323f8 10 cinder list cinder readonly-mode-update <volume_id> true cinder readonly-mode-update <volume_id> false cinder list cinder transfer-create <volume> +------------+--------------------------------------+ | Property | Value | +------------+--------------------------------------+ | auth_key | f03bf51ce7ead189 | | created_at | 2014-12-08T03:46:31.884066 | | id | 3f5dc551-c675-4205-a13a-d30f88527490 | | name | None | | volume_id | bcf7d015-4843-464c-880d-7376851ca728 | +------------+--------------------------------------+ cinder transfer-accept <transfer_id> <transfer_key> cinder transfer-accept 3f5dc551-c675-4205-a13a-d30f88527490 f03bf51ce7ead189 cinder transfer-list