Skip to main content

Flavor

The Flavor class provides an interface to interact with OpenStack flavors, allowing you to retrieve information about compute resource templates including CPU, RAM, and disk configurations.

Constructor

Flavor(flavor_id=None, name=None, cloud=Cloud())
Initialize a Flavor instance.
flavor_id
str
The unique identifier of the flavor. Either flavor_id or name should be provided.
name
str
The name of the flavor. Either flavor_id or name should be provided.
cloud
Cloud
default:"Cloud()"
The Cloud instance to use for OpenStack operations. Defaults to a new Cloud instance.

Properties

name

@property
def name(self) -> str
name
str
Returns the name associated to this Flavor.

id

@property
def id(self) -> str
id
str
Returns the flavor_id associated to this Flavor.

disk

@property
def disk(self) -> int
disk
int
Returns the Disk associated to this Flavor (in GB).

ram

@property
def ram(self) -> int
ram
int
Returns the RAM associated to this Flavor (in MB).

cpu

@property
def cpu(self) -> int
cpu
int
Returns the vcpu associated to this Flavor.

servers

@property
def servers(self) -> EntityList
servers
EntityList
Returns all Servers using this Flavor.

Usage Example

from myos.flavor import Flavor

# Initialize flavor by name
flavor = Flavor(name="l3.micro")

# Access flavor properties
print(flavor.name)  # Get flavor name
print(flavor.id)    # Get flavor ID
print(flavor.disk)  # Get disk size (GB)
print(flavor.ram)   # Get RAM size (MB)
print(flavor.cpu)   # Get vCPU count

# List servers using this flavor
for server in flavor.servers:
    print(server.id)

Build docs developers (and LLMs) love