Sha256: 11bb1efd6b7810f31f3318f5647de4449d11542204519c1722cac1d1313bfa0e

Contents?: true

Size: 1.59 KB

Versions: 79

Compression:

Stored size: 1.59 KB

Contents

module Fog
  module Compute
    class Linode
      class Real

        def linode_disk_list(linode_id, disk_id=nil)
          options = {}
          if disk_id
            options.merge!(:diskId => disk_id)
          end
          request(
            :expects  => 200,
            :method   => 'GET',
            :query    => { :api_action => 'linode.disk.list', :linodeId => linode_id }.merge!(options)
          )
        end

      end

      class Mock
        def linode_disk_list(linode_id, disk_id=nil)
          response = Excon::Response.new
          response.status = 200
          body = {
            "ERRORARRAY" => [],
            "ACTION" => "linode.disk.list"
          }
          if disk_id
            mock_disk = create_mock_disk(linode_id, disk_id)
            response.body = body.merge("DATA" => [mock_disk])
          else
            mock_disks = []
            2.times do
              disk_id = rand(10000..99999)
              mock_disks << create_mock_disk(linode_id, disk_id)
            end
            response.body = body.merge("DATA" => mock_disks)
          end
          response
        end

        private

        def create_mock_disk(linode_id, disk_id)
          {
            "CREATE_DT"  => "2012-02-29 12:55:29.0",
            "DISKID"     => disk_id,
            "ISREADONLY" => 0,
            "LABEL"      => "test_#{linode_id}_main",
            "LINODEID"   => linode_id,
            "SIZE"       => 39936,
            "STATUS"     => 1,
            "TYPE"       => "ext3",
            "UPDATE_DT"  => "2012-02-29 12:55:53.0"
          }
        end
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 12 rubygems

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