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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

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 Fog::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) ⇒ Volume

Returns a new instance of Volume.



23
24
25
26
27
# File 'lib/fog/openstack/models/compute/volume.rb', line 23

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Method Details

#attach(server_id, name) ⇒ Object



42
43
44
45
46
47
# File 'lib/fog/openstack/models/compute/volume.rb', line 42

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



36
37
38
39
40
# File 'lib/fog/openstack/models/compute/volume.rb', line 36

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

#detach(server_id, attachment_id) ⇒ Object



49
50
51
52
53
# File 'lib/fog/openstack/models/compute/volume.rb', line 49

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

#saveObject



29
30
31
32
33
34
# File 'lib/fog/openstack/models/compute/volume.rb', line 29

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