Configurable Instance Types For OpenStack Nova

Posted on 03 Mar 2011 in openstack

Over the past three weeks, new Nova core developer Josh Kearney (congrats @jk0) and I have been working on adding runtime configuration of instance types (read the full specification) to the OpenStack Nova compute service.  Instance types (or "flavors" as Rackspace calls them) are resources granted to virtual machines ("instances") in the Nova cloud. In more specific terms, this is the size of the instance (vCPUs, RAM, Storage, etc.) that you will be launching. You may recognize these by the names "m1.large" or "m1.tiny" in AWS EC2 parlance. The Rackspace's API (PDF) calls these "flavors" and they tend to have names like "256 MB Server" and such.

In the released version of OpenStack Nova (Bexar), instance types are defined statically in the nova/instance_types.py file (which corresponds to the initial Amazon EC2 instance types) before run-time. This change, which will be part of the upcoming version of Nova (Cactus), instance types can be created by the Nova administrator during run-time through the nova-manage command. If you are following the Nova trunk (or just impatient), you can find this merged in at revision number 757.

Basic Management

Instance types / flavor are managed through the nova-manage binary with the instance_type command and an appropriate subcommand. As we are using the nova-manage command, we need to be on the Nova database server to configure instance types. Right now, instance type manipulation isn't exposed through the APIs nor the adminclient.

Note that you can also use the flavor command as a synonym for instance_types for any of these examples.

To see all currently active instance types, use the list subcommand:

$ nova-manage instance_type list
m1.medium: Memory: 4096MB, VCPUS: 2, Storage: 40GB, FlavorID: 3, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.large: Memory: 8192MB, VCPUS: 4, Storage: 80GB, FlavorID: 4, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.tiny: Memory: 512MB, VCPUS: 1, Storage: 0GB, FlavorID: 1, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.xlarge: Memory: 16384MB, VCPUS: 8, Storage: 160GB, FlavorID: 5, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.small: Memory: 2048MB, VCPUS: 1, Storage: 20GB, FlavorID: 2, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB

Again, and just for emphasis, you could just have easily used the flavor subcommand to get the exact same output:

$ nova-manage flavor list
m1.medium: Memory: 4096MB, VCPUS: 2, Storage: 40GB, FlavorID: 3, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.large: Memory: 8192MB, VCPUS: 4, Storage: 80GB, FlavorID: 4, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.tiny: Memory: 512MB, VCPUS: 1, Storage: 0GB, FlavorID: 1, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.xlarge: Memory: 16384MB, VCPUS: 8, Storage: 160GB, FlavorID: 5, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
m1.small: Memory: 2048MB, VCPUS: 1, Storage: 20GB, FlavorID: 2, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB

To create an instance type, use the create subcommand with the following positional arguments:

  • memory (expressed in megabytes)
  • vcpu(s) (integer)
  • local storage (expressed in gigabytes)
  • flavorid (unique integer)
  • swap space (expressed in megabytes, defaults to zero, optional)
  • RXTX quotas (expressed in gigabytes, defaults to zero, optional)
  • RXTX cap (expressed in gigabytes, defaults to zero, optional)

The following example creates an instance type named "m1.xxlarge":

$ nova-manage instance_type create m1.xxlarge 32768 16 320 0 0 0
m1.xxlarge created

To delete an instance type, use the delete subcommand and specify the name:

$ nova-manage instance_type delete m1.xxlarge
m1.xxlarge deleted

Please note that the delete command only marks the instance type as inactive in the database; it does not actually remove the instance type. This is done to preserve the instance type definition for long running instances (which may not terminate for months or years). If you are sure that you want to delete this instance type from the database, pass the --purge flag after the name:

$ nova-manage instance_type delete m1.xxlarge --purge
m1.xxlarge purged

Be careful with deleting instance types, you might need this information later. Unless you truly need to prune the size of your instance_types table you are much safer to just delete the instance type.

Implementation

This feature is implemented with an additional database table (instance_types), which has rows for each instance type/flavor. The nova-manage command allows you to manipulate this table. At installation time (actually when the nova-manage db sync command is run), the database table is seeded with instance type values for the five default types: m1.small, m1.tiny, m1.medium, m1.large and m1.xlarge.