Sha256: 03c8b589e695023e9714e60a8f7603a4f010566c8cb0b88ad2b09c33b3d2ab8a

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'fog/volume/openstack/models/snapshot'

module Fog
  module Volume
    class OpenStack
      class V2
        class Snapshot < Fog::Volume::OpenStack::Snapshot
          identity :id

          attribute :name
          attribute :status
          attribute :description
          attribute :metadata
          attribute :force

          def save
            requires :name
            data = if id.nil?
                     service.create_snapshot(attributes[:volume_id], name, description, force)
                   else
                     service.update_snapshot(id, attributes.reject { |k, _v| k == :id })
                   end
            merge_attributes(data.body['snapshot'])
            true
          end

          def create
            requires :name

            # volume_id, name, description, force=false
            response = service.create_snapshot(attributes[:volume_id],
                                               attributes[:name],
                                               attributes[:description],
                                               attributes[:force])
            merge_attributes(response.body['snapshot'])

            self
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fog-openstack-0.1.18 lib/fog/volume/openstack/v2/models/snapshot.rb
fog-openstack-0.1.17 lib/fog/volume/openstack/v2/models/snapshot.rb
fog-openstack-0.1.15 lib/fog/volume/openstack/v2/models/snapshot.rb
fog-openstack-0.1.14 lib/fog/volume/openstack/v2/models/snapshot.rb
fog-openstack-0.1.13 lib/fog/volume/openstack/v2/models/snapshot.rb
fog-openstack-0.1.12 lib/fog/volume/openstack/v2/models/snapshot.rb
fog-openstack-0.1.11 lib/fog/volume/openstack/v2/models/snapshot.rb