Class: Fog::Compute::Aliyun::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Aliyun::Volume
- Defined in:
- lib/fog/aliyun/models/compute/volume.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #image ⇒ Object
- #ready? ⇒ Boolean
- #save(options = {}) ⇒ Object
- #snapshots ⇒ Object
- #source ⇒ Object
Instance Method Details
#destroy ⇒ Object
47 48 49 50 51 52 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 47 def destroy requires :id service.delete_disk(id) true end |
#image ⇒ Object
76 77 78 79 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 76 def image requires :image_id Fog::Compute::Aliyun::Images.new(:service=>service).all(:imageId=>image_id)[0] end |
#ready? ⇒ Boolean
54 55 56 57 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 54 def ready? requires :state state == 'Available' end |
#save(options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 59 def save(={}) # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? # requires :availability_zone requires_one :size, :snapshot_id [:name] = name if name [:description]=description if description if snapshot_id data=Fog::JSON.decode(service.create_disk_by_snapshot(snapshot_id,).body) merge_attributes(data) elsif size data = Fog::JSON.decode(service.create_disk(size,).body) merge_attributes(data) end true end |
#snapshots ⇒ Object
81 82 83 84 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 81 def snapshots requires :id Fog::Compute::Aliyun::Snapshots.new(:service=>service).all(:volume_id=>id) end |
#source ⇒ Object
86 87 88 89 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 86 def source requires :snapshot_id Fog::Compute::Aliyun::Snapshots.new(:service=>service).all(:snapshotIds => [snapshot_id])[0] end |