Class: Fog::OpenStack::Volume::V3::Volume

Inherits:
Fog::OpenStack::Volume::Volume show all
Defined in:
lib/fog/openstack/volume/v3/models/volume.rb

Instance Attribute Summary

Attributes inherited from Model

#project

Instance Method Summary collapse

Methods inherited from Fog::OpenStack::Volume::Volume

#create_metadata, #delete_metadata, #destroy, #extend, #ready?, #replace_metadata, #reset_status, #update_metadata

Methods inherited from Model

#create, #destroy, #initialize

Constructor Details

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

Instance Method Details

#saveObject



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

def save
  requires :name, :size
  data = if id.nil?
           service.create_volume(name, description, size, attributes)
         else
           service.update_volume(id, attributes.select { |key| %i(name description metadata).include?(key) })
         end
  merge_attributes(data.body['volume'])
  true
end

#update(attr = nil) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/fog/openstack/volume/v3/models/volume.rb', line 26

def update(attr = nil)
  requires :id
  merge_attributes(
    service.update_volume(id, attr || attributes).body['volume']
  )
  self
end