Class: Fog::OpenStack::Compute::Volume

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/compute/models/volume.rb

Instance Attribute Summary

Attributes inherited from Model

#project

Instance Method Summary collapse

Methods inherited from Model

#create, #initialize, #update

Constructor Details

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

Instance Method Details

#attach(server_id, name) ⇒ Object



33
34
35
36
37
38
# File 'lib/fog/openstack/compute/models/volume.rb', line 33

def attach(server_id, name)
  requires :id
  data = service.attach_volume(id, server_id, name)
  merge_attributes(:attachments => attachments << data.body['volumeAttachment'])
  true
end

#destroyObject



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

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

#detach(server_id, attachment_id) ⇒ Object



40
41
42
43
44
# File 'lib/fog/openstack/compute/models/volume.rb', line 40

def detach(server_id, attachment_id)
  requires :id
  service.detach_volume(server_id, attachment_id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/fog/openstack/compute/models/volume.rb', line 46

def ready?
  status == "available"
end

#saveObject



20
21
22
23
24
25
# File 'lib/fog/openstack/compute/models/volume.rb', line 20

def save
  requires :name, :description, :size
  data = service.create_volume(name, description, size, attributes)
  merge_attributes(data.body['volume'])
  true
end