Class: Fog::HP::BlockStorage::Snapshot
- Defined in:
- lib/fog/hp/models/block_storage/snapshot.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
- #force=(new_force) ⇒ Object
-
#initialize(attributes = {}) ⇒ Snapshot
constructor
attribute :metadata.
- #ready? ⇒ Boolean
- #save ⇒ Object
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Snapshot
attribute :metadata
19 20 21 22 23 |
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 19 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
#destroy ⇒ Object
25 26 27 28 29 |
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 25 def destroy requires :id service.delete_snapshot(id) true end |
#force=(new_force) ⇒ Object
31 32 33 |
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 31 def force=(new_force) @force = new_force end |
#ready? ⇒ Boolean
35 36 37 |
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 35 def ready? self.status == 'available' end |
#save ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/hp/models/block_storage/snapshot.rb', line 39 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :name, :volume_id = { #'metadata' => metadata, # TODO: Add metadata when snapshots support it 'force' => @force } = .reject {|key, value| value.nil?} data = service.create_snapshot(name, description, volume_id, ) merge_attributes(data.body['snapshot']) true end |