Class: Fog::Compute::Cloudstack::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Cloudstack::Volume
- Defined in:
- lib/fog/cloudstack/models/compute/volume.rb
Instance Attribute Summary collapse
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#snapshot_id ⇒ Object
Returns the value of attribute snapshot_id.
Instance Method Summary collapse
- #attach(instance_or_id, mountpoint = nil) ⇒ Object
- #destroy ⇒ Object
- #detach ⇒ Object
- #flavor ⇒ Object (also: #disk_offering)
- #ready? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
- #server ⇒ Object
- #snapshots ⇒ Object
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
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 85 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 = { 'id' => id, 'virtualmachineid' => instance_id, } .merge!('deviceid' => mountpoint) if mountpoint data = service.attach_volume() service.jobs.new(data["attachvolumeresponse"]) end |
#destroy ⇒ Object
111 112 113 114 115 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 111 def destroy requires :id service.delete_volume('id' => id) true end |
#detach ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 103 def detach requires :id data = service.detach_volume('id' => id) service.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 service.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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 66 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 = { 'size' => size, 'name' => name, 'diskofferingid' => disk_offering_id, 'zoneid' => zone_id, 'snapshotid' => snapshot_id, 'projectid' => project_id } data = service.create_volume() 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 service.servers.get(server_id) end end |
#snapshots ⇒ Object
61 62 63 64 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 61 def snapshots requires :id service.snapshots.all('volumeid' => id) end |