
Common OpenStack storage tasks
This section outlines a number of common tasks using the OpenStack Block and Object Storage service. For more information on storage, refer to Chapter 7, Cinder – OpenStack Block Storage and Chapter 8, Swift – OpenStack Object Storage.
Getting ready
Ensure that you have the OpenStack clients installed, as described in the first recipes of this chapter.
How to do it…
Carry out the following steps to create and modify users and projects in OpenStack:
To create a new Cinder block storage volume, carry out the following command. The size is in gigabytes:
openstack volume create --size 5 my5GVolume
To attach a volume to a running instance, carry out the following command. The running instance UUID is used and can be found by listing the running instances:
openstack server add volume my5GVolume 58ea640b-16ba-447c-85db-952174d70f7c
To detach a volume, first unmount it from the running instance as you would normally, then carry out the following command:
openstack server remove volume my5GVolume 58ea640b-16ba-447c-85db-952174d70f7c
To make a snapshot of a volume, carry out the following steps. First, you must detach the volume from the running instance to ensure data consistency. The action is described in the previous task.
Now once detached, issue the following
openstack snapshot create --name myVolumeSnapshot myVolume
Listing Object Storage statistics
To display information about Object Storage containers, carry out the following command:
openstack object store account show
To list contents of an object store, issue the following command:
openstack object store list openstack object store list myContainer
To create an Object Storage container, issue the following command:
openstack object create myContainer
To upload files to an Object Storage container, issue the following command:
openstack object create myContainer myFile