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_image'
|
|
|
|
|
|
|
|
# Copy an image to a different region
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * source_image_id<~String> - The ID of the AMI to copy
|
2015-01-02 12:34:40 -05:00
|
|
|
# * source_region<~String> - The name of the AWS region that contains the AMI to be copied
|
2014-12-30 17:25:09 -05:00
|
|
|
# * name<~String> - The name of the new AMI in the destination region
|
|
|
|
# * description<~String> - The description to set on the new AMI in the destination region
|
|
|
|
# * client_token<~String> - Unique, case-sensitive identifier you provide to ensure idempotency of the request
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - id of request
|
|
|
|
# * 'imageId'<~String> - id of image
|
|
|
|
#
|
2015-01-02 12:34:40 -05:00
|
|
|
# {Amazon API Reference}[http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CopyImage.html]
|
2014-12-30 17:25:09 -05:00
|
|
|
def copy_image(source_image_id, source_region, name = nil, description = nil, client_token = nil)
|
|
|
|
request(
|
|
|
|
'Action' => 'CopyImage',
|
|
|
|
'SourceImageId' => source_image_id,
|
|
|
|
'SourceRegion' => source_region,
|
|
|
|
'Name' => name,
|
|
|
|
'Description' => description,
|
|
|
|
'ClientToken' => client_token,
|
|
|
|
:parser => Fog::Parsers::Compute::AWS::CopyImage.new
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
#
|
|
|
|
# Usage
|
|
|
|
#
|
2015-01-02 12:34:40 -05:00
|
|
|
# Fog::AWS[:compute].copy_image("ami-1aad5273", 'us-east-1')
|
2014-12-30 17:25:09 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
def copy_image(source_image_id, source_region, name = nil, description = nil, client_token = nil)
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
image_id = Fog::AWS::Mock.image_id
|
|
|
|
data = {
|
|
|
|
'imageId' => image_id,
|
|
|
|
}
|
|
|
|
self.data[:images][image_id] = data
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id
|
|
|
|
}.merge!(data)
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|