2014-12-30 17:25:09 -05:00
|
|
|
module Fog
|
|
|
|
module Compute
|
2015-01-02 12:34:40 -05:00
|
|
|
class AWS
|
2014-12-30 17:25:09 -05:00
|
|
|
class Real
|
|
|
|
require 'fog/aws/parsers/compute/copy_snapshot'
|
|
|
|
|
|
|
|
# Copy a snapshot to a different region
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * source_snapshot_id<~String> - Id of snapshot
|
|
|
|
# * source_region<~String> - Region to move it from
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - id of request
|
|
|
|
# * 'snapshotId'<~String> - id of snapshot
|
|
|
|
#
|
2015-01-02 12:34:40 -05:00
|
|
|
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CopySnapshot.html]
|
2014-12-30 17:25:09 -05:00
|
|
|
def copy_snapshot(source_snapshot_id, source_region, description = nil)
|
|
|
|
request(
|
|
|
|
'Action' => 'CopySnapshot',
|
|
|
|
'SourceSnapshotId'=> source_snapshot_id,
|
|
|
|
'SourceRegion' => source_region,
|
|
|
|
'Description' => description,
|
|
|
|
:parser => Fog::Parsers::Compute::AWS::CopySnapshot.new
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
#
|
|
|
|
# Usage
|
|
|
|
#
|
2015-01-02 12:34:40 -05:00
|
|
|
# Fog::AWS[:compute].copy_snapshot("snap-1db0a957", 'us-east-1')
|
2014-12-30 17:25:09 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
def copy_snapshot(source_snapshot_id, source_region, description = nil)
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
snapshot_id = Fog::AWS::Mock.snapshot_id
|
|
|
|
data = {
|
|
|
|
'snapshotId' => snapshot_id,
|
|
|
|
}
|
|
|
|
self.data[:snapshots][snapshot_id] = data
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id
|
|
|
|
}.merge!(data)
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|