Logo: Relish

  1. Sign in

Project: Behave-relish

List server flavors (ruby)

The following code example shows how to list flavors for the ruby SDK.
See also Listing Flavors in the OpenStack documentation.

  • @ruby
List flavors (ruby)
I am setup to run example code for ruby
I execute the following code:
#!/usr/bin/env ruby

# This example demonstrates creating a server with the Rackpace Open Cloud

require 'rubygems' #required for Ruby 1.8.x
require 'fog'
require "base64" #required to encode files for personality functionality

# create Next Generation Cloud Server service
service = Fog::Compute.new({
  :provider             => 'rackspace',
  :rackspace_username   => Fog.credentials[:rackspace_username],
  :rackspace_api_key    => Fog.credentials[:rackspace_api_key],
  :version => :v2,  # Use Next Gen Cloud Servers
  :rackspace_region => :ord #Use Chicago Region

# pick the first flavor
flavors = service.flavors
flavors.each do |flv|
  puts "Name: #{flv.name}"
  puts "  ID: #{flv.id}"
  puts "  RAM: #{flv.ram}"
  puts "  Disk: #{flv.disk}"
  puts "  VCPUs: #{flv.vcpus}"
the output should match

Name: 512MB Standard Instance
  ID: 2
  RAM: 512
  Disk: 20
  VCPUs: 1

Name: 1GB Standard Instance
  ID: 3
  RAM: 1024
  Disk: 40
  VCPUs: 1

Name: 2GB Standard Instance
  ID: 4
  RAM: 2048
  Disk: 80
  VCPUs: 2

Name: 4GB Standard Instance
  ID: 5
  RAM: 4096
  Disk: 160
  VCPUs: 2

Name: 8GB Standard Instance
  ID: 6
  RAM: 8192
  Disk: 320
  VCPUs: 4

Name: 15GB Standard Instance
  ID: 7
  RAM: 15360
  Disk: 620
  VCPUs: 6

Name: 30GB Standard Instance
  ID: 8
  RAM: 30720
  Disk: 1200
  VCPUs: 8

Last published over 7 years ago by Max Lincoln.