Method: OpenStack::Compute::Connection#list_flavors
- Defined in:
- lib/openstack/compute/connection.rb
#list_flavors(options = {}) ⇒ Object Also known as: flavors
Returns an array of hashes listing all available server flavors. The :id key in the hash can be used when flavorRef is required.
You can also provide :limit and :offset parameters to handle pagination.
>> cs.list_flavors
=> [{:name=>"256 server", :id=>1, :ram=>256, :disk=>10},
{:name=>"512 server", :id=>2, :ram=>512, :disk=>20},...
>> cs.list_flavors(:limit => 3, :offset => 2)
=> [{:ram=>1024, :disk=>40, :name=>"1GB server", :id=>3},
{:ram=>2048, :disk=>80, :name=>"2GB server", :id=>4},
{:ram=>4096, :disk=>160, :name=>"4GB server", :id=>5}]
169 170 171 172 173 174 |
# File 'lib/openstack/compute/connection.rb', line 169 def list_flavors( = {}) path = OpenStack.paginate().empty? ? "#{@connection.service_path}/flavors/detail" : "#{@connection.service_path}/flavors/detail?#{OpenStack.paginate()}" response = @connection.csreq("GET",@connection.service_host,path,@connection.service_port,@connection.service_scheme) OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/) OpenStack.symbolize_keys(JSON.parse(response.body)['flavors']) end |