Sha256: bd45969b03dcf6bcabfcf4905321b6e1e35dbd2640aafe6d0c00c64b96190c4c

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

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

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

          attribute :display_name
          attribute :status
          attribute :display_description
          attribute :metadata
          attribute :force

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

          def create
            requires :display_name

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

            self
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/models/volume_v1/snapshot.rb
fog-openstack-0.1.9 lib/fog/openstack/models/volume_v1/snapshot.rb
fog-openstack-0.1.8 lib/fog/openstack/models/volume_v1/snapshot.rb
fog-openstack-0.1.7 lib/fog/openstack/models/volume_v1/snapshot.rb
fog-openstack-0.1.6 lib/fog/openstack/models/volume_v1/snapshot.rb