Getting started with managing volumes in the OpenStack API
Objective
You can use the OpenStack API to generate various scripts in order to automate your actions on the Public Cloud.
For example, you can create a new high-performance volume to attach to a Public Cloud instance.
This guide will help you manage your volumes using the OpenStack API and the Python client.
Requirements
- Preparing the environment to use the OpenStack API by installing python-cinderclient and python-novaclient
- Setting the OpenStack environment variables
Instructions
Cinder documentation
You can get a list of possible commands by reading the OpenStack client documentation:
Here is the list of the main commands:
| Command | Description |
|---|---|
| volume create | Create a new volume |
| volume delete | Delete a volume |
| list volume | List volumes |
| volume snapshot create | Create a snapshot of a volume |
You can also get information about a specific command by adding help to it:
You can also consult the OpenStack documentation available on the OpenStack website.
Basic operations
Creating a high-performance volume
- List the volume types:
- Create the 10GB high-speed volume named volume1:
You can install an image on a volume using the --image argument:
In this command, be66762f-b849-43e1-b57c-005d9fe28088 is the Debian 10 image ID.
Attaching a volume to an instance
- List the additional volumes:
The majority of subsequent commands will require the volume ID rather than the name.
- Mount the volume on an instance with the OpenStack client:
- Check that the volume has been properly attached to the instance with the OpenStack client:
Deleting a volume
- Detach volume from instance:
- Delete volume:
Go further
Join our community of users.