Sha256: 18afdd5fd9fe2ac76141b61146e13454661ebfa38914158aca4f22c1b9b24adc

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

# coding: utf-8

module Fog
  module Volume
    class SakuraCloud
      class Real
        def create_disk( name, plan, options = {} )
          body = { "Disk" => { "Name" => name, "Plan" => { "ID" => plan.to_i } } }

          if !options[:source_archive].nil?
            body["Disk"]["SourceArchive"] = { "ID"=>options[:source_archive].to_s }
          end

          if !options[:size_mb].nil?
            body["Disk"]["SizeMB"] = options[:size_mb].to_i
          end

          request(
            :headers => {
              'Authorization' => "Basic #{@auth_encode}"
            },
            :expects  => [201, 202],
            :method => 'POST',
            :path => "#{Fog::SakuraCloud.build_endpoint(@api_zone)}/disk",
            :body => Fog::JSON.encode(body)
          )
        end
      end # Real

      class Mock
        def create_disk( name, plan, options = {} )
          response = Excon::Response.new
          response.status = 202
          response.body = {
          }
          response
        end
      end
    end # SakuraCloud
  end # Volume
end # Fog

Version data entries

13 entries across 11 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-sakuracloud-1.7.5/lib/fog/sakuracloud/requests/volume/create_disk.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-sakuracloud-1.7.5/lib/fog/sakuracloud/requests/volume/create_disk.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-sakuracloud-1.7.5/lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.7.5 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.7.4 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.7.3 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.7.2 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.7.1 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.7.0 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.6.0 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.5.2 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.5.1 lib/fog/sakuracloud/requests/volume/create_disk.rb
fog-sakuracloud-1.5.0 lib/fog/sakuracloud/requests/volume/create_disk.rb