Sha256: 91af79b92ca35dd299e5234b2d0d1b81e5e5d555ba73df8cea472b474b44af64

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

module Fog
  module Compute
    class OpenStack
      class Real
        def create_volume(name, description, size, options={})
          data = {
            'volume' => {
              'display_name'        => name,
              'display_description' => description,
              'size'                => size
            }
          }

          vanilla_options = ['snapshot_id', 'availability_zone']
          vanilla_options.select{|o| options[o]}.each do |key|
            data['volume'][key] = options[key]
          end
          request(
            :body     => Fog::JSON.encode(data),
            :expects  => [200, 202],
            :method   => 'POST',
            :path     => "os-volumes"
          )
        end
      end

      class Mock
        def create_volume(name, description, size, options={})
          response = Excon::Response.new
          response.status = 202
          data = {
            'id'                  => Fog::Mock.random_numbers(2),
            'displayName'         => name,
            'displayDescription'  => description,
            'size'                => size,
            'status'              => 'creating',
            'snapshotId'          => nil,
            'volumeType'          => 'None',
            'availabilityZone'    => 'nova',
            'createdAt'           => Time.now.strftime('%FT%T.%6N'),
            'attachments'         => [],
            'metadata'            => {}
          }
          self.data[:volumes][data['id']] = data
          response.body = { 'volume' => data }
          response
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
fog-1.37.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.36.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.35.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-2.0.0.pre.0 lib/fog/openstack/requests/compute/create_volume.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/openstack/requests/compute/create_volume.rb
fog-1.34.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.33.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.32.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.31.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.30.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.29.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.28.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.27.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.26.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.25.0 lib/fog/openstack/requests/compute/create_volume.rb
nsidc-fog-1.24.1 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.24.0 lib/fog/openstack/requests/compute/create_volume.rb
fog-1.23.0 lib/fog/openstack/requests/compute/create_volume.rb