Sha256: a3eaffa91ac82b7609b929e51a96a16d55f6d76bb199b4408089c179875cea13

Contents?: true

Size: 1.48 KB

Versions: 44

Compression:

Stored size: 1.48 KB

Contents

module Fog
  module Compute
    class OpenStack
      class Real
        def create_snapshot(volume_id, name, description, force = false)
          data = {
            'snapshot' => {
              'volume_id'           => volume_id,
              'display_name'        => name,
              'display_description' => description,
              'force'               => force
            }
          }

          request(
            :body    => Fog::JSON.encode(data),
            :expects => [200, 202],
            :method  => 'POST',
            :path    => "os-snapshots"
          )
        end
      end

      class Mock
        def create_snapshot(volume_id, name, description, _force = false)
          volume_response = get_volume_details(volume_id)
          volume = volume_response.data[:body]['volume']
          if volume.nil?
            raise Fog::Compute::OpenStack::NotFound
          else
            response = Excon::Response.new
            data = {
              "status"      => "availble",
              "name"        => name,
              "created_at"  => Time.now,
              "description" => description,
              "volume_id"   => volume_id,
              "id"          => Fog::Mock.random_numbers(2),
              "size"        => volume['size']
            }

            self.data[:snapshots][data['id']] = data
            response.body = {"snapshot" => data}
            response.status = 202
            response
          end
        end
      end
    end
  end
end

Version data entries

44 entries across 42 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.10 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.1.30 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.1.29 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.9 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.1.28 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.8 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.7 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.6 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.5 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.4 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.3 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.2 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.3.0 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.2.4 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.2.3 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.2.2 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.2.1 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-openstack-0.2.0 lib/fog/compute/openstack/requests/create_snapshot.rb
fog-zj-0.1.28 lib/fog/compute/openstack/requests/create_snapshot.rb