Class: Fog::Compute::Cloudstack::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Cloudstack::Volume
show all
- Defined in:
- lib/fog/cloudstack/models/compute/volume.rb
Instance Attribute Summary collapse
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #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 Attribute Details
#project_id ⇒ Object
Returns the value of attribute project_id.
29
30
31
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 29
def project_id
@project_id
end
|
#snapshot_id ⇒ Object
Returns the value of attribute snapshot_id.
29
30
31
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 29
def snapshot_id
@snapshot_id
end
|
Instance Method Details
#attach(instance_or_id, mountpoint = nil) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 81
def attach(instance_or_id, mountpoint=nil)
requires :id
instance_id = instance_or_id.is_a?(Server) ? instance_or_id.id : instance_or_id
unless instance_id
raise ArgumentError, "Missing required argument: instance_or_id"
end
options = {
'id' => id,
'virtualmachineid' => instance_id,
}
options.merge!('deviceid' => mountpoint) if mountpoint
data = connection.attach_volume(options)
connection.jobs.new(data["attachvolumeresponse"])
end
|
#destroy ⇒ Object
107
108
109
110
111
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 107
def destroy
requires :id
connection.delete_volume('id' => id)
true
end
|
#detach ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 99
def detach
requires :id
data = connection.detach_volume('id' => id)
connection.jobs.new(data["detachvolumeresponse"])
end
|
#flavor ⇒ Object
Also known as:
disk_offering
50
51
52
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 50
def flavor
connection.disk_offerings.get(self.disk_offering_id)
end
|
#ready? ⇒ Boolean
46
47
48
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 46
def ready?
state == 'Allocated' || state == 'Ready'
end
|
#reload ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 61
def reload
requires :identity
return unless data = begin
collection.get(identity)
rescue Excon::Errors::SocketError
nil
end
new_attributes = {
'virtualmachineid' => nil,
'vmname' => nil,
'vmdisplayname' => nil
}.merge(data.attributes)
merge_attributes(new_attributes)
self
end
|
#save ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 31
def save
requires :name, :disk_offering_id, :zone_id
options = {
'size' => size,
'name' => name,
'diskofferingid' => disk_offering_id,
'zoneid' => zone_id,
'snapshotid' => snapshot_id,
'projectid' => project_id
}
data = connection.create_volume(options)
merge_attributes(data['createvolumeresponse'])
end
|
#server ⇒ Object
55
56
57
58
59
|
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 55
def server
if server_id
connection.servers.get(server_id)
end
end
|