Sha256: 6aa3d2c9fa473b7c9562f12c21945d7a84ba7672c14b6b4a40c6d51888d6902e

Contents?: true

Size: 1.61 KB

Versions: 111

Compression:

Stored size: 1.61 KB

Contents

module Fog
  module Compute
    class Rackspace
      class Real

        # Get details for flavor by id
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'id'<~Integer> - Id of the flavor
        #     * 'name'<~String> - Name of the flavor
        #     * 'ram'<~Integer> - Amount of ram for the flavor
        #     * 'disk'<~Integer> - Amount of diskspace for the flavor
        def get_flavor_details(flavor_id)
          request(
            :expects  => [200, 203],
            :method   => 'GET',
            :path     => "flavors/#{flavor_id}.json"
          )
        end

      end

      class Mock

        def get_flavor_details(flavor_id)
          response = Excon::Response.new
          flavor = {
            1 => { 'name' => '256 server',    'ram' => 256,    'disk' => 10   },
            2 => { 'name' => '512 server',    'ram' => 512,    'disk' => 20   },
            3 => { 'name' => '1GB server',    'ram' => 1024,   'disk' => 40   },
            4 => { 'name' => '2GB server',    'ram' => 2048,   'disk' => 80   },
            5 => { 'name' => '4GB server',    'ram' => 4096,   'disk' => 160  },
            6 => { 'name' => '8GB server',    'ram' => 8192,   'disk' => 320  },
            7 => { 'name' => '15.5GB server', 'ram' => 15872,  'disk' => 620  }
          }[flavor_id]
          if flavor
            response.status = 200
            response.body = {
              'flavor' => flavor
            }
            response
          else
            raise Fog::Compute::Rackspace::NotFound
          end
        end

      end
    end
  end
end

Version data entries

111 entries across 111 versions & 19 rubygems

Version Path
fog-1.22.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.21.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.20.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.19.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/rackspace/requests/compute/get_flavor_details.rb