Class: Fog::Volume::OpenStack::V1::Snapshot

Inherits:
Snapshot show all
Defined in:
lib/fog/volume/openstack/v1/models/snapshot.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Model

#project

Instance Method Summary collapse

Methods inherited from Snapshot

#delete_metadata, #destroy, #update, #update_metadata

Methods inherited from OpenStack::Model

#destroy, #initialize, #update

Constructor Details

This class inherits a constructor from Fog::OpenStack::Model

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/volume/openstack/v1/models/snapshot.rb', line 27

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

#saveObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/volume/openstack/v1/models/snapshot.rb', line 16

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