1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/openstack/requests/compute/get_flavor_details.rb
Dan Prince 41f09986f4 Implement fog support for the Openstack Compute API v1.1. Includes
support for legacy v1.0 style auth and v2.0 keystone auth.
2011-09-26 02:51:45 -04:00

43 lines
1.4 KiB
Ruby

module Fog
module Compute
class OpenStack
class Real
def get_flavor_details(flavor_ref)
request(
:expects => [200, 203],
:method => 'GET',
:path => "flavors/#{flavor_ref}.json"
)
end
end
class Mock
def get_flavor_details(flavor_ref)
response = Excon::Response.new
flavor = {
'1' => { 'id' => '1', 'name' => '256 server', 'ram' => 256, 'disk' => 10, 'links' => [] },
'2' => { 'id' => '2', 'name' => '512 server', 'ram' => 512, 'disk' => 20, 'links' => [] },
'3' => { 'id' => '3', 'name' => '1GB server', 'ram' => 1024, 'disk' => 40, 'links' => [] },
'4' => { 'id' => '4', 'name' => '2GB server', 'ram' => 2048, 'disk' => 80, 'links' => [] },
'5' => { 'id' => '5', 'name' => '4GB server', 'ram' => 4096, 'disk' => 160, 'links' => [] },
'6' => { 'id' => '6', 'name' => '8GB server', 'ram' => 8192, 'disk' => 320, 'links' => [] },
'7' => { 'id' => '7', 'name' => '15.5GB server', 'ram' => 15872, 'disk' => 620, 'links' => [] }
}[flavor_ref]
if flavor
response.status = 200
response.body = {
'flavor' => flavor
}
response
else
raise Fog::Compute::OpenStack::NotFound
end
end
end
end
end
end