class Fog::HP::BlockStorageV2::Snapshot

Public Class Methods

new(attributes = {}) click to toggle source
Calls superclass method
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 17
def initialize(attributes = {})
  # assign these attributes first to prevent race condition with persisted?
  self.force = attributes.delete(:force)   # force snapshotting of attached volumes
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 23
def destroy
  requires :id
  service.delete_snapshot(id)
  true
end
force=(new_force) click to toggle source
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 29
def force=(new_force)
  @force = new_force
end
ready?() click to toggle source
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 33
def ready?
  self.status == 'available'
end
save() click to toggle source
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 37
def save
  identity ? update : create
end

Private Instance Methods

create() click to toggle source
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 43
def create
  requires :volume_id
  options = {
    'display_name'        => name,
    'display_description' => description,
    'force'               => @force,
    'metadata'            => metadata
  }
  options = options.reject {|_, value| value.nil?}
  data = service.create_snapshot(volume_id, options)
  merge_attributes(data.body['snapshot'])
  true
end
update() click to toggle source
# File lib/fog/hp/models/block_storage_v2/snapshot.rb, line 57
def update
  requires :id
  options = {
    'display_name'        => name,
    'display_description' => description,
    'metadata'            => metadata
  }
  options = options.reject {|_, value| value.nil?}
  data = service.update_snapshot(id, options)
  merge_attributes(data.body['snapshot'])
  true
end