Class: Fog::Storage::IBM::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::IBM::Volume
show all
- Defined in:
- lib/fog/ibm/models/storage/volume.rb
Constant Summary
collapse
- STATUS =
[
"New", "Creating", "Deleting", "Deleted", "Detached", "Attached", "Failed", "Deletion pending", "Being cloned", "Cloning", "Attaching", "Detaching", "Copying", "Importing", "Transfer retrying" ]
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#attach(instance_id) ⇒ Object
44
45
46
47
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 44
def attach(instance_id)
requires :id
connection.attach_volume(instance_id, id).body['success']
end
|
#attached? ⇒ Boolean
40
41
42
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 40
def attached?
status == "Attached"
end
|
#created_at ⇒ Object
54
55
56
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 54
def created_at
Time.at(attributes[:created_at].to_f / 1000)
end
|
#destroy ⇒ Object
58
59
60
61
62
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 58
def destroy
requires :id
connection.delete_volume(id)
true
end
|
#detach(instance_id) ⇒ Object
49
50
51
52
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 49
def detach(instance_id)
requires :id
connection.detach_volume(instance_id, id).body['success']
end
|
#instance ⇒ Object
64
65
66
67
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 64
def instance
return nil if instance_id.nil? || instance_id == "0" || instance_id == ""
Fog::Compute[:ibm].servers.get(instance_id)
end
|
#location ⇒ Object
69
70
71
72
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 69
def location
requires :location_id
Fog::Compute[:ibm].locations.get(location_id)
end
|
#ready? ⇒ Boolean
Are we ready to be attached to an instance?
75
76
77
78
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 75
def ready?
status == "Detached"
end
|
#save ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 80
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
requires :name, :offering_id, :format, :location_id, :size
data = connection.create_volume(name, offering_id, format, location_id, size)
merge_attributes(data.body)
true
end
|
#status ⇒ Object
88
89
90
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 88
def status
STATUS[attributes[:state].to_i]
end
|