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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Volume

Returns a new instance of Volume.



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

def initialize(attributes={})
    super
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



17
18
19
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 17

def options
  @options
end

Instance Method Details

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



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 39

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



58
59
60
61
62
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 58

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

#detach(server_id) ⇒ Object



51
52
53
54
55
56
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 51

def detach(server_id)
    requires :id

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

#failed?Boolean

Returns:

  • (Boolean)


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

def failed?
    self.state == 'ERROR'
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
    self.state == 'AVAILABLE'
end

#saveObject



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

def save
    requires :data_center_id, :size

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

#updateObject



31
32
33
34
35
36
37
# File 'lib/fog/profitbricks/models/compute/volume.rb', line 31

def update
    requires :id

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