Sha256: 8f00ec639bc3b5a749fb0419759e8c0303a3bf7f03346ed6f2e040bbb9775923

Contents?: true

Size: 1.6 KB

Versions: 39

Compression:

Stored size: 1.6 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

39 entries across 37 versions & 6 rubygems

Version Path
fog-rackspace-0.1.6 lib/fog/rackspace/requests/compute/get_flavor_details.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/requests/compute/get_flavor_details.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/requests/compute/get_flavor_details.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-rackspace-0.1.5 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-rackspace-0.1.4 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-rackspace-0.1.3 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-rackspace-0.1.2 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-rackspace-0.1.1 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-rackspace-0.1.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.37.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.36.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.35.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-2.0.0.pre.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.34.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.33.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.32.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
fog-1.31.0 lib/fog/rackspace/requests/compute/get_flavor_details.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/rackspace/requests/compute/get_flavor_details.rb