How to create and set property of flavor in OpenStack with examples


Written by - Deepak Prasad

In this article I will show you the steps to create and set property of flavor with examples. But before we start with the commands let us understand the important terminologies

 how to create and set property of flavor in openstack with examples

Introduction to Flavors

Flavors are hardware specification templates for instances. These specifications include the amount of RAM, disk size, and number of cores for each instance created with the flavor. Flavors can also specify the sizes for secondary ephemeral storage and a swap disk, metadata to restrict usage, or special project access.

The OpenStack compute service has five pre-configured flavors. These provide the most common configurations in terms of RAM and root disk size, and number of VCPUs. Below table consists the list of their specifications:

Name vCPUs RAM Root Disk Size
m1.tiny 1 512 MB 1 GB
m1.small 1 2048 MB 20 GB
m1.medium 2 4096 MB 40 GB
m1.large 4 8192 MB 80 GB
m1.xlarge 8 16384 MB 160 GB

Flavors can be managed with the Horizon dashboard or with the OpenStack unified CLI. The dashboard supports flavor management found in Admin > System > Flavors. Anyhow this functionality is only available to users with administrator privileges.

 

Defining Storage in Flavors

Flavors define what storage is available to an instance. There are several storage resources associated with an instance, including the root disk, ephemeral disk, and swap disk. All of this storage is ephemeral, so when the instance is terminated, the storage devices are removed and
data stored on those devices is no longer available. All of these disks are based on files located in the /var/lib/nova/instances/ directory of the compute node where the instance has been deployed. When the instance is created, a new directory is created in that location. The name
of this directory is the ID of the instance, and it contains the back-end image files for the root, ephemeral, and swap disks.

 

A flavor consists of the following parameters:

Arguments Details
Flavor ID Unique ID (integer or UUID) for the new flavor. If specifying 'auto', a UUID will be automatically generated.
Name Name for the new flavor
VCPUS Number of virtual CPUs to use
Memory (MB) Amount of RAM to use (in megabytes)
Root Disk (GB) Amount of disk space (in gigabytes) to use for the root (/) partition. This property is required.
Ephemeral Disk (GB) Amount of disk space (in gigabytes) to use for the ephemeral partition.
Swap Amount of swap space (in megabytes) to use
Is Public Boolean value defines whether the flavor is available to all users

 

List the existing flavors

Use below command to list all the available flavors

$ openstack flavor list
+--------------------------------------+---------------+------+------+-----------+-------+-----------+
| ID                                   | Name          |  RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+---------------+------+------+-----------+-------+-----------+
| 3cd8285a-7f9a-4176-91c5-6cc8d4b69d10 | compute       | 4096 |   20 |         0 |     1 | True      |
| 48c4e5fc-dba5-49e9-98a8-8fca11db781a | control       | 4096 |   20 |         0 |     1 | True      |
| c238e44a-d74e-4d08-91ae-33effb657005 | baremetal     | 4096 |   40 |         0 |     1 | True      |
| e3e95dfd-8a64-4cc0-a57f-bd8a133f5673 | block-storage | 4096 |   40 |         0 |     1 | True      |
| f95ea5d8-d776-4359-96ae-c5a099ddbdc1 | ceph-storage  | 4096 |   15 |         0 |     1 | True      |
| fd31fb4f-0ae5-47ce-a68f-3e5f412b503c | swift-storage | 4096 |   40 |         0 |     1 | True      |
+--------------------------------------+---------------+------+------+-----------+-------+-----------+

 

Creating flavors

NOTE:
Source the keystone credentials environment file to load the credentials for a user with administrator privileges.

To create a flavor, specify a name, ID, RAM size, disk size, and the number of VCPUs for the flavor, as follows:

$ openstack flavor create FLAVOR_NAME --id FLAVOR_ID --ram RAM_IN_MB --disk ROOT_DISK_IN_GB --vcpus NUMBER_OF_VCPUS

 

So here is an example that creates a public extra_tiny flavor which automatically gets an ID, with 4096 MB memory, 20 GB of disk space, and one vCPU.

$ openstack flavor create --public m1.extra_tiny --id auto   --ram 4096 --disk 20 --vcpus 1
+----------------------------+--------------------------------------+
| Field                      | Value                                |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled   | False                                |
| OS-FLV-EXT-DATA:ephemeral  | 0                                    |
| disk                       | 20                                   |
| id                         | e6e7c5c8-deb0-46a6-a8d2-1ff6561fa20c |
| name                       | m1.extra_tiny                        |
| os-flavor-access:is_public | True                                 |
| properties                 |                                      |
| ram                        | 4096                                 |
| rxtx_factor                | 1.0                                  |
| swap                       |                                      |
| vcpus                      | 1                                    |
+----------------------------+--------------------------------------+

 

Create and Set Property of Flavor

Similarly here in this example I am creating compute flavor with 20 GB root disk, 4 vCPUs, 4 GB RAM and some pre-defined custom properties

$ openstack flavor create --disk 20 --vcpus 4 --ram 4096 --property "capabilities:profile"="compute"  --property "capabilities:cpu_aes"="true"  --property "capabilities:cpu_hugepages"="true" --property "capabilities:boot_option"="local" compute
+----------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| Field                      | Value                                                                                                                            |
+----------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| OS-FLV-DISABLED:disabled   | False                                                                                                                            |
| OS-FLV-EXT-DATA:ephemeral  | 0                                                                                                                                |
| disk                       | 20                                                                                                                               |
| id                         | e5fae841-f9ef-46b9-a61b-6542a5a5edac                                                                                             |
| name                       | compute                                                                                                                          |
| os-flavor-access:is_public | True                                                                                                                             |
| properties                 | capabilities:boot_option='local', capabilities:cpu_aes='true', capabilities:cpu_hugepages='true', capabilities:profile='compute' |
| ram                        | 4096                                                                                                                             |
| rxtx_factor                | 1.0                                                                                                                              |
| swap                       |                                                                                                                                  |
| vcpus                      | 4                                                                                                                                |
+----------------------------+----------------------------------------------------------------------------------------------------------------------------------+

 

Modifying flavor to assign custom properties

You can also modify your existing flavors to add custom properties. For example in this command I am adding additional set of properties to my existing ceph-storage flavor

$ openstack flavor set --property "capabilities:profile"="ceph-storage"  --property "capabilities:cpu_aes"="true"  --property "capabilities:cpu_hugepages"="true" --property "capabilities:boot_option"="local"  ceph-storage

 

Delete Flavor

To delete a flavor use the below syntax

$ openstack flavor delete <FLAVOR_ID>

Here either you can use Flavor ID or Flavor Name (assuming you do not have multiple flavors with same name, in which case you will need to use ID)

$ openstack flavor delete m1.extra_tiny

 

Lastly I hope the steps from the article to create and set property of flavor with examples in OpenStack was helpful. So, let me know your suggestions and feedback using the comment section.

 

Views: 7

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment