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.
30 31 32 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 30 def project_id @project_id end |
#snapshot_id ⇒ Object
Returns the value of attribute snapshot_id.
30 31 32 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 30 def snapshot_id @snapshot_id end |
Instance Method Details
#attach(instance_or_id, mountpoint = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 87 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
113 114 115 116 117 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 113 def destroy requires :id service.delete_volume('id' => id) true end |
#detach ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 105 def detach requires :id data = service.detach_volume('id' => id) service.jobs.new(data["detachvolumeresponse"]) end |
#flavor ⇒ Object Also known as: disk_offering
52 53 54 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 52 def flavor service.disk_offerings.get(self.disk_offering_id) end |
#ready? ⇒ Boolean
48 49 50 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 48 def ready? state == 'Allocated' || state == 'Ready' end |
#reload ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 68 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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 32 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
57 58 59 60 61 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 57 def server if server_id service.servers.get(server_id) end end |
#snapshots ⇒ Object
63 64 65 66 |
# File 'lib/fog/cloudstack/models/compute/volume.rb', line 63 def snapshots requires :id service.snapshots.all('volumeid' => id) end |