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
- STATES =
{
0 => 'New',
1 => 'Creating',
2 => 'Deleting',
3 => 'Deleted',
4 => 'Detached',
5 => 'Attached',
6 => 'Failed',
7 => 'Deletion pending',
8 => 'Being cloned',
9 => 'Cloning',
10 => 'Attaching',
11 => 'Detaching',
12 => 'Copying',
13 => 'Importing',
14 => '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
47
48
49
50
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 47
def attach(instance_id)
requires :id
connection.attach_volume(instance_id, id).body['success']
end
|
#attached? ⇒ Boolean
43
44
45
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 43
def attached?
state == "Attached"
end
|
#created_at ⇒ Object
57
58
59
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 57
def created_at
Time.at(attributes[:created_at].to_f / 1000)
end
|
#destroy ⇒ Object
61
62
63
64
65
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 61
def destroy
requires :id
connection.delete_volume(id)
true
end
|
#detach(instance_id) ⇒ Object
52
53
54
55
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 52
def detach(instance_id)
requires :id
connection.detach_volume(instance_id, id).body['success']
end
|
#instance ⇒ Object
67
68
69
70
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 67
def instance
return nil if instance_id.nil? || instance_id == "0" || instance_id == ""
Fog::Compute[:ibm].servers.get(instance_id)
end
|
#location ⇒ Object
72
73
74
75
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 72
def location
requires :location_id
Fog::Compute[:ibm].locations.get(location_id)
end
|
#ready? ⇒ Boolean
Are we ready to be attached to an instance?
78
79
80
81
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 78
def ready?
state == "Detached"
end
|
#save ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 83
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
|
#state ⇒ Object
91
92
93
|
# File 'lib/fog/ibm/models/storage/volume.rb', line 91
def state
STATES[attributes[:state]]
end
|