Sha256: 9769fdb47d434af6eb41a4dd1c7e579d10cf7c3a6a1fa715f4f7eaf8050561bb

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

module Fog
  module Compute
    class Ecloud
      module Shared
        def validate_upload_file_options(options)
          required_opts = [:file, :path, :credentials]
          unless required_opts.all? { |opt| options.key?(opt) }
            raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(', ')}")
          end
        end
      end

      class Real
        def virtual_machine_upload_file(vm_uri, options)
          validate_upload_file_options(options)
          request(
            :expects => 204,
            :method => "POST",
            :headers => { "Content-Type" => "application/octet-stream", "X-Guest-User" => options[:credentials][:user], "X-Guest-Password" => options[:credentials][:password], "Content-Range" => "0-#{options[:file].bytesize - 1}/#{options[:file].bytesize}" },
            :body => options[:file],
            :uri => vm_uri + "?path=#{options[:path]}",
            :parse => true
          )
        end
      end
    end
  end
end

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
fog-ecloud-0.3.0 lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
fog-ecloud-0.2.0 lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
fog-ecloud-0.1.1 lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb
fog-ecloud-0.1.0 lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb