3.2. Creating and configuring a volume type
You can create volume types so that you can apply associated settings to each volume type. For instance, you can create volume types to provide different levels of performance for your cloud users.
After creating a volume type, you can associate it with a Quality of Service specification that further configures volume performance. For more information, see Customizing Block Storage service (cinder) QoS specifications.
- Considerations
- Volume type visibility: By default, all volume types are public and accessible to all projects. If you need to create volume types with restricted access, create a private volume type. For more information, see Creating and using private volume types.
Deployment strategies: For smaller deployments that have a limited number of back ends, you can create volume types that target each back end by using the
volume_backend_nameproperty. In this case, volumes that use these volume types are scheduled on the specified back ends. For more information, see the example provided by Editing a volume type.For large deployments with large numbers of back ends, this strategy may not be viable. In this case, it is better that the Block Storage scheduler determines the best back end for a volume, based on the configured scheduler filters.
Prerequisites
- You must be a project administrator to create and configure volume types.
- Know the names of the keys and their required values for the back-end driver capabilities that you want to add to your volume types. For more information, see Listing back-end driver capabilities.
Procedure
Access the remote shell for the
openstackclientpod from your workstation:$ oc rsh -n openstack openstackclientCreate and configure a volume type.
$ openstack volume type create --property <key>=<value> <volume_type_name>Add the required properties to the volume type, by specifying a separate
--property <key>=<value>argument, as follows:-
Replace
<key>with the property key. Ensure that you spell the key correctly. Any incorrectly spelled keys are added but will not work. -
Replace
<value>with the required value of the<key>. Replace
<volume_type_name>with the name of your volume type.For example:
$ openstack volume type create \ --property thin_provisioning=true \ --property compression=false \ MyVolumeType +-------------+-----------------------------------------------+ | Field | Value | +-------------+-----------------------------------------------+ | description | None | | id | c244205c-fb22-4076-9780-edebe55889bc | | is_public | True | | name | MyVolumeType | | properties | compression='false', thin_provisioning='true' | +-------------+-----------------------------------------------+
-
Replace
Exit the
openstackclientpod:$ exit
3.2.1. Creating and using private volume types 复制链接链接已复制到粘贴板!
By default, all volume types are public and available to all projects (tenants). To control or to limit the access to a volume type, you can create a private volume type.
By default, private volume types are only accessible to their creators. But all administrative users can view private volume types.
Private volume types restrict access to volumes with certain attributes. Typically, these are settings that should only be usable by specific projects. For instance, new back ends or ultra-high performance configurations that are being tested.
Prerequisites
- You must be a project administrator to create and configure volume types.
Procedure
Access the remote shell for the
openstackclientpod from your workstation:$ oc rsh -n openstack openstackclientCreate a new private volume type.
$ openstack volume type create --private <volume_type_name>Replace
<volume_type_name>with the name for the new private volume type.You can confirm that this is a private volume because the
is_publicfield is set toFalse. For example:$ openstack volume type create --private MyVolType2 +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | 20659377-935d-4253-8b82-ae12c4710288 | | is_public | False | | name | MyVolType2 | +-------------+--------------------------------------+
Optional: View private and public volume types.
$ openstack volume type listThis provides a table of the volume types and the
Is Publiccolumn indicates whether a volume type is private (False) or public (True). For example:+--------------------------------------+-------------+-----------+ | ID | Name | Is Public | +--------------------------------------+-------------+-----------+ | 271f9b90-8186-4143-aaed-09e91820d852 | MyVolType3 | True | | 20659377-935d-4253-8b82-ae12c4710288 | MyVolType2 | False | | 28b5ca7f-0eb0-43ce-bf0a-898fab92d43b | MyVolType1 | True | | 0875116b-27d6-493c-aca6-f62de4d58614 | __DEFAULT__ | True | +--------------------------------------+-------------+-----------+This table also provides the name and ID of both public and private volume types, because you need the ID of the volume type to provide access to it.
Optional: List the projects to obtain the ID of the required project:
$ openstack project list(Optional) Allow a project to access a private volume type:
$ openstack volume type set <type_id> --project <project_id>-
Replace
<type_id>with the ID of the required private volume type. Replace
<project_id>with the ID of the project that should access this private volume type.注意Access to a private volume type is granted at the project level. If you only know the name of a user of this project, then run the
openstack user listcommand, which lists the name and tenant ID of all the configured users.
-
Replace
(Optional) View which projects have access to a private volume type:
$ openstack volume type show <type_id>The
access_project_idsfield of the resultant table provides the IDs of all the projects that can access this private volume type.(Optional) Remove project access from a private volume type:
$ openstack volume type unset <type_id> --project <project_id>You can confirm this by running
openstack volume type show <type_id>and ensuring this project is not specified in theaccess_project_idsfield.Exit the
openstackclientpod:$ exit