Class: Fog::HP::BlockStorage::Snapshot

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/hp/models/block_storage/snapshot.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Snapshot

attribute :metadata



17
18
19
20
21
# File 'lib/fog/hp/models/block_storage/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

Instance Method Details

#destroyObject



23
24
25
26
27
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 23

def destroy
  requires :id
  service.delete_snapshot(id)
  true
end

#force=(new_force) ⇒ Object



29
30
31
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 29

def force=(new_force)
  @force = new_force
end

#ready?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 33

def ready?
  self.status == 'available'
end

#saveObject

Raises:

  • (Fog::Errors::Error)


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 37

def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  requires :name, :volume_id
  options = {
    #'metadata'        => metadata,      # TODO: Add metadata when snapshots support it
    'force'           => @force
  }
  options = options.reject {|key, value| value.nil?}
  data = service.create_snapshot(name, description, volume_id, options)
  merge_attributes(data.body['snapshot'])
  true
end