Sha256: 236e0b81cefcdd40bbf4aa1ddf856a7d83a7269ada41768391cdef2dececa0bc

Contents?: true

Size: 1.56 KB

Versions: 27

Compression:

Stored size: 1.56 KB

Contents

module Fog
  module Compute
    class Linode
      class Real
        # Get available kernels
        #
        # ==== Parameters
        # * kernelId<~Integer>: id to limit results to
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Array>:
        # TODO: docs
        def avail_kernels(kernel_id=nil)
          options = {}
          if kernel_id
            options.merge!(:kernelId => kernel_id)
          end
          request(
            :expects  => 200,
            :method   => 'GET',
            :query    => { :api_action => 'avail.kernels' }.merge!(options)
          )
        end
      end

      class Mock
        def avail_kernels(kernel_id=nil)
          response = Excon::Response.new
          response.status = 200

          body = {
            "ERRORARRAY" => [],
            "ACTION" => "avail.kernels"
          }
          if kernel_id
            mock_kernel = create_mock_kernel(kernel_id)
            response.body = body.merge("DATA" => [mock_kernel])
          else
            mock_kernels = []
            10.times do
              kernel_id = rand(1..200)
              mock_kernels << create_mock_kernel(kernel_id)
            end
            response.body = body.merge("DATA" => mock_kernels)
          end
          response
        end

        private

        def create_mock_kernel(kernel_id)
          {
            "ISPVOPS"  => 1,
            "ISXEN"    => 1,
            "KERNELID" => kernel_id,
            "LABEL"    => "Latest 3.0 (3.0.18-linode43)"
          }
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
fog-1.35.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-2.0.0.pre.0 lib/fog/linode/requests/compute/avail_kernels.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.34.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.33.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.32.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.31.0 lib/fog/linode/requests/compute/avail_kernels.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.30.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.29.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.28.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.27.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.26.0 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.25.0 lib/fog/linode/requests/compute/avail_kernels.rb
nsidc-fog-1.24.1 lib/fog/linode/requests/compute/avail_kernels.rb
fog-1.24.0 lib/fog/linode/requests/compute/avail_kernels.rb
ns-fog-1.22.11 lib/fog/linode/requests/compute/avail_kernels.rb
ns-fog-1.22.10 lib/fog/linode/requests/compute/avail_kernels.rb
ns-fog-1.22.9 lib/fog/linode/requests/compute/avail_kernels.rb
ns-fog-1.22.8 lib/fog/linode/requests/compute/avail_kernels.rb