2010-03-16 18:46:21 -04:00
|
|
|
require 'fog/model'
|
|
|
|
|
2009-09-06 13:48:12 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-03-16 18:46:21 -04:00
|
|
|
module EC2
|
2009-09-06 13:48:12 -04:00
|
|
|
|
|
|
|
class Snapshot < Fog::Model
|
2010-04-23 18:21:17 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate(:status, :state)
|
2009-09-06 13:48:12 -04:00
|
|
|
|
2009-12-05 17:53:42 -05:00
|
|
|
identity :id, 'snapshotId'
|
2009-10-24 01:23:55 -04:00
|
|
|
|
2010-05-08 21:22:43 -04:00
|
|
|
attribute :description
|
2009-09-06 13:48:12 -04:00
|
|
|
attribute :progress
|
2010-01-08 18:05:29 -05:00
|
|
|
attribute :created_at, 'startTime'
|
2010-05-08 21:22:43 -04:00
|
|
|
attribute :owner_id, 'ownerId'
|
2010-04-23 18:21:17 -04:00
|
|
|
attribute :state, 'status'
|
2010-01-08 18:05:29 -05:00
|
|
|
attribute :volume_id, 'volumeId'
|
2010-05-08 21:22:43 -04:00
|
|
|
attribute :volume_size, 'volumeSize'
|
2009-09-06 13:48:12 -04:00
|
|
|
|
2009-09-20 12:21:03 -04:00
|
|
|
def destroy
|
2009-12-05 17:53:42 -05:00
|
|
|
requires :id
|
2009-11-21 16:56:39 -05:00
|
|
|
|
2009-12-05 17:53:42 -05:00
|
|
|
connection.delete_snapshot(@id)
|
2009-09-06 13:48:12 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2010-04-23 17:07:49 -04:00
|
|
|
def ready?
|
2010-04-26 15:25:21 -04:00
|
|
|
state == 'completed'
|
2010-04-23 17:07:49 -04:00
|
|
|
end
|
|
|
|
|
2009-09-06 13:48:12 -04:00
|
|
|
def save
|
2009-11-21 16:56:39 -05:00
|
|
|
requires :volume_id
|
|
|
|
|
2010-08-20 19:14:40 -04:00
|
|
|
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
|
2009-12-05 17:53:42 -05:00
|
|
|
requires :id
|
2009-11-21 16:56:39 -05:00
|
|
|
|
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
|