Class: Fog::Volume::OpenStack::V2::Volume

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

Instance Attribute Summary

Attributes inherited from OpenStack::Model

#project

Instance Method Summary collapse

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

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

Methods inherited from OpenStack::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/volume/openstack/v2/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.reject { |k, _v| k == :id })
         end
  merge_attributes(data.body['volume'])
  true
end

#update(attr = nil) ⇒ Object


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

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