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 13:48:12 -04: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 11:56:27 -04:00
attribute :volume_id, 'volumeId'
2009-09-06 13:48:12 -04:00
def delete
connection.delete_snapshot(@snapshot_id)
true
end
2009-09-19 15:31:15 -04:00
def reload
new_attributes = snapshots.all(@snapshot_id).first.attributes
merge_attributes(new_attributes)
end
2009-09-06 13:48:12 -04:00
def save
data = connection.create_snapshot(@volume.volume_id).body
new_attributes = data.reject {|key,value| key == 'requestId'}
update_attributes(new_attributes)
true
end
def snapshots
2009-09-19 15:31:15 -04:00
@snapshots
2009-09-06 13:48:12 -04:00
end
def volume
2009-09-18 11:56:27 -04:00
connection.describe_volumes(@volume_id)
2009-09-06 13:48:12 -04:00
end
private
def snapshots=(new_snapshots)
@snapshots = new_snapshots
end
def volume=(new_volume)
2009-09-18 11:56:27 -04:00
@volume_id = new_volume.volume_id
2009-09-06 13:48:12 -04:00
end
end
end
end
end