1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/ec2/snapshot.rb

53 lines
1.1 KiB
Ruby
Raw Normal View History

2009-09-06 10:48:12 -07:00
module Fog
module AWS
class EC2
class Snapshot < Fog::Model
attribute :progress
attribute :snapshot_id, 'snapshotId'
attribute :start_time, 'startTime'
attribute :status
2009-09-18 08:56:27 -07:00
attribute :volume_id, 'volumeId'
2009-09-06 10:48:12 -07:00
2009-09-20 09:21:03 -07:00
def destroy
2009-09-06 10:48:12 -07:00
connection.delete_snapshot(@snapshot_id)
true
end
2009-09-19 12:31:15 -07:00
def reload
2009-09-24 19:18:41 -07:00
new_attributes = snapshots.get(@snapshot_id).attributes
2009-09-19 12:31:15 -07:00
merge_attributes(new_attributes)
end
2009-09-06 10:48:12 -07:00
def save
2009-09-24 19:18:41 -07:00
data = connection.create_snapshot(volume_id).body
2009-09-06 10:48:12 -07:00
new_attributes = data.reject {|key,value| key == 'requestId'}
update_attributes(new_attributes)
true
end
def snapshots
2009-09-19 12:31:15 -07:00
@snapshots
2009-09-06 10:48:12 -07:00
end
def volume
2009-09-18 08:56:27 -07:00
connection.describe_volumes(@volume_id)
2009-09-06 10:48:12 -07:00
end
private
def snapshots=(new_snapshots)
@snapshots = new_snapshots
end
def volume=(new_volume)
2009-09-18 08:56:27 -07:00
@volume_id = new_volume.volume_id
2009-09-06 10:48:12 -07:00
end
end
end
end
end