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

58 lines
1.2 KiB
Ruby
Raw Normal View History

2010-03-16 18:46:21 -04:00
require 'fog/model'
2009-09-06 13:48:12 -04:00
module Fog
module AWS
class EC2
2009-09-06 13:48:12 -04:00
class Snapshot < Fog::Model
extend Fog::Deprecation
deprecate(:status, :state)
2009-09-06 13:48:12 -04:00
identity :id, :aliases => 'snapshotId'
attribute :description
2009-09-06 13:48:12 -04:00
attribute :progress
attribute :created_at, :aliases => 'startTime'
attribute :owner_id, :aliases => 'ownerId'
attribute :state, :aliases => 'status'
attribute :volume_id, :aliases => 'volumeId'
attribute :volume_size, :aliases => 'volumeSize'
2009-09-06 13:48:12 -04:00
2009-09-20 12:21:03 -04:00
def destroy
requires :id
connection.delete_snapshot(@id)
2009-09-06 13:48:12 -04:00
true
end
def ready?
2010-04-26 15:25:21 -04:00
state == 'completed'
end
2009-09-06 13:48:12 -04:00
def save
requires :volume_id
data = connection.create_snapshot(@volume_id, @description).body
2009-09-06 13:48:12 -04:00
new_attributes = data.reject {|key,value| key == 'requestId'}
2009-09-30 01:02:33 -04:00
merge_attributes(new_attributes)
2009-09-06 13:48:12 -04:00
true
end
def volume
requires :id
2009-09-18 11:56:27 -04:00
connection.describe_volumes(@volume_id)
2009-09-06 13:48:12 -04:00
end
private
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