Class: Fog::Compute::ProfitBricks::Volume

Inherits:
Models::ProfitBricks::Base show all
Defined in:
lib/fog/profitbricks/models/compute/volume.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Models::ProfitBricks::Base

#wait_for

Constructor Details

#initialize(attributes = {}) ⇒ Volume

Returns a new instance of Volume.



22
23
24
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 22

def initialize(attributes = {})
  super
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



20
21
22
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 20

def options
  @options
end

Instance Method Details

#attach(server_id, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 42

def attach(server_id, options = {})
  requires :id
  
  options = {
    "busType"    => options[:bus_type],
    "deviceNumber" => options[:device_number]
  }

  data = service.connect_storage_to_server(id, server_id, options)
  reload
end

#destroyObject



61
62
63
64
65
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 61

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

#detach(server_id) ⇒ Object



54
55
56
57
58
59
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 54

def detach(server_id)
  requires :id

  data = service.disconnect_storage_from_server(id, server_id)
  reload
end

#failed?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 71

def failed?
  state == "ERROR"
end

#ready?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 67

def ready?
  state == "AVAILABLE"
end

#saveObject



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

def save
  requires :data_center_id, :size

  data = service.create_storage(data_center_id, size, options)
  merge_attributes(data.body["createStorageResponse"])
  true
end

#updateObject



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

def update
  requires :id

  data = service.update_storage(id, options)
  merge_attributes(data.body["updateStorageResponse"])
  true
end