mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
39 lines
1 KiB
Ruby
39 lines
1 KiB
Ruby
module Fog
|
|
module AWS
|
|
class EC2
|
|
|
|
class Volume < Fog::Model
|
|
|
|
attribute :attachment_time, 'attachmentTime'
|
|
attribute :availability_zone, 'availabilityZone'
|
|
attribute :device, 'createTime'
|
|
attribute :instance_id, 'instanceId'
|
|
attribute :size
|
|
attribute :snapshot_id, 'snapshotId'
|
|
attribute :status, 'status'
|
|
attribute :volume_id, 'volumeId'
|
|
|
|
def initialize(attributes = {})
|
|
if attributes['attachmentSet']
|
|
attributes.merge!(attributes.delete('attachmentSet'))
|
|
end
|
|
super
|
|
end
|
|
|
|
def delete
|
|
connection.delete_volume(@volume_id)
|
|
true
|
|
end
|
|
|
|
def save
|
|
data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
|
|
new_attributes = data.reject {|key,value| key == 'requestId'}
|
|
update_attributes(new_attributes)
|
|
true
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|