How to create flavor in openstack using CLI

Dear Friend’s, Today we will see how to create flavor in openstack using CLI. we will also discuss about all parameters of flavors which we can use at the flavor creation time. so let’s start step by step.

Before flavor creation we should know what is flavor and why we need it in openstack?

What is flavor in openstack?

Flavor is an available hardware configuration for a server where we can define the size of a virtual server like (How many RAM, how many Disk and How many CPU) which can be used to launch a virtual server.

For more details about openstack flavor you can Click Here

We can use these parameters in flavor

Flavor ID: – Flavor ID can be define as an integer or UUID format for the new flavor. If specifying auto, then a UUID will be automatically generated.

Name: – We can also define name for the new flavor.

VCPUs: – Number of virtual CPUs use in new virtual server.

Memory (RAM): – Amount of RAM used in new virtual server and RAM should be define in megabytes format.

Root Disk GB: – Amount of disk space to be use for the root (/) partition and disk space should be define in gigabytes GB.

Ephemeral Disk GB: – Amount of disk space (in gigabytes) to use for the ephemeral partition. If unspecified, then the value will be 0 by default. Ephemeral disks offer machine local disk storage linked to the lifecycle of a VM instance. When a VM is terminated, all data on the ephemeral disk is lost. Ephemeral disks are not included in any snapshots.

These parameters are also available which can be use to create flavor.

Swap: – We can also define amount of swap space (in megabytes) for new virtual server. If unspecified, then the value will be 0 by default.

RXTX Factor: – Optional property that allows servers with a different bandwidth be created with the RXTX Factor. The default value is 1.0. That is, the new bandwidth is the same as that of the attached network. The RXTX Factor is available only for Xen or NSX based systems.

Is Public: – We can set flavor availability for the all users or only for project related users. Boolean value defines whether the flavor is available to all users. Defaults will be True.

Extra Specs: – Key and value pairs that define on which compute nodes a flavor can run. These pairs must match corresponding pairs on the compute nodes. It can be used to implement special resources, such as flavors that run on only compute nodes with GPU hardware.

Now we will see how to create flavor in openstack using CLI

In the below output you can see I have created one flavor where flavor name is Test, ID will be auto, RAM will be 1024 (1GB), VCPU will be 2 and RXTX-Factor will be 1. Test flavor will be available for all users.

Create flavor

In the above output you can see, we have successfully created flavor with these basic options.

List down created flavor using (openstack flavor list) like below: –

[stack@urclouds (urcloudsrc) ~]$ openstack flavor list
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
| 10dbc5a5-3061-461e-aadd-9784db9ce579 | Test | 1024 | 0 | 0 | 2 | True |

To get a list of optional parameters we can also run this command (openstack help flavor create). Like below: –

[stack@urclouds (urcloudsrc) ~]$ openstack help flavor create
usage: openstack flavor create [-h] [-f {json,shell,table,value,yaml}]
[-c COLUMN] [--max-width ]
[--fit-width] [--print-empty] [--noindent]
[--prefix PREFIX] [--id ] [--ram ]
[--disk ] [--ephemeral ]
[--swap ] [--vcpus ]
[--rxtx-factor ] [--public | --private]
[--property ] [--project ]
[--project-domain ]

Create new flavor
positional arguments:
New flavor name
optional arguments:
-h, --help show this help message and exit
--id Unique flavor ID; 'auto' creates a UUID (default:
--ram Memory size in MB (default 256M)
--disk Disk size in GB (default 0G)
Ephemeral disk size in GB (default 0G)
--swap Additional swap space size in MB (default 0M)
--vcpus Number of vcpus (default 1)
RX/TX factor (default 1.0)
--public Flavor is available to other projects (default)
--private Flavor is not available to other projects
Property to add for this flavor (repeat option to set
multiple properties)
--project Allow to access private flavor (name or ID)
(Must be used with --private option)
Domain the project belongs to (name or ID). This can
be used in case collisions between project names
output formatters:
output formatter options
-f {json,shell,table,value,yaml}, --format {json,shell,table,value,yaml}
the output format, defaults to table
-c COLUMN, --column COLUMN
specify the column(s) to include, can be repeated
table formatter:
Maximum display width, <1 to disable. You can also use
the CLIFF_MAX_TERM_WIDTH environment variable, but the
parameter takes precedence.
--fit-width Fit the table to the display width. Implied if --max-
width greater than 0. Set the environment variable
CLIFF_FIT_WIDTH=1 to always enable
--print-empty Print empty table if there is no data to show.
json formatter:
--noindent whether to disable indenting the JSON
shell formatter:
a format a UNIX shell can parse (variable="value")
--prefix PREFIX add a prefix to all variable names
[stack@undercloud (urcloudsrc) ~]$

How to Delete a Flavor in openstack using CLI

We can delete the flavor using (openstack flavor delete flavor_ID). Like below.

[stack@urclouds (urcloudsrc) ~]$ openstack flavor delete 10dbc5a5-3061-461e-aadd-9784db9ce579
[stack@urclouds (urcloudsrc) ~]$

You can see in about output we have successfully flavor deleted. You can also verify deleted flavor using (openstack flavor list) and you will get this Flavor ID= 10dbc5a5-3061-461e-aadd-9784db9ce579 in not in list. Like below: –

[stack@urclouds (urcloudsrc) ~]$ openstack flavor list
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |

Thant’s all, in this tutorial we we see how to create flavor in openstack using CLI. In the next tutorial we will see how to set Extra Specs in openstack flavor.

Extra Specs set in openstack flavor using CLI

Leave a Reply