2010-07-24 13:25:29 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-08 17:40:02 -04:00
|
|
|
class Compute
|
2010-07-24 13:25:29 -04:00
|
|
|
class Real
|
|
|
|
|
2011-01-07 19:52:09 -05:00
|
|
|
require 'fog/compute/parsers/aws/create_image'
|
2010-07-24 13:25:29 -04:00
|
|
|
|
|
|
|
# Create a bootable EBS volume AMI
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * instance_id<~String> - Instance used to create image.
|
|
|
|
# * name<~Name> - Name to give image.
|
|
|
|
# * description<~Name> - Description of image.
|
|
|
|
# * no_reboot<~Boolean> - Optional, whether or not to reboot the image when making the snapshot
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'imageId'<~String> - The ID of the created AMI.
|
|
|
|
# * 'requestId'<~String> - Id of request.
|
2011-05-19 12:31:56 -04:00
|
|
|
#
|
|
|
|
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html]
|
2010-07-24 13:25:29 -04:00
|
|
|
def create_image(instance_id, name, description, no_reboot = false)
|
|
|
|
request(
|
|
|
|
'Action' => 'CreateImage',
|
|
|
|
'InstanceId' => instance_id,
|
|
|
|
'Name' => name,
|
|
|
|
'Description' => description,
|
|
|
|
'NoReboot' => no_reboot.to_s,
|
2010-09-08 17:40:02 -04:00
|
|
|
:parser => Fog::Parsers::AWS::Compute::CreateImage.new
|
2010-07-24 13:25:29 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
2010-11-29 18:44:44 -05:00
|
|
|
|
|
|
|
# Usage
|
|
|
|
#
|
|
|
|
# AWS[:compute].create_image("i-ac65ee8c", "test", "something")
|
|
|
|
#
|
|
|
|
|
2010-07-24 13:25:29 -04:00
|
|
|
def create_image(instance_id, name, description, no_reboot = false)
|
|
|
|
response = Excon::Response.new
|
|
|
|
if instance_id && !name.empty?
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'imageId' => Fog::AWS::Mock.image_id
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response.status = 400
|
|
|
|
response.body = {
|
|
|
|
'Code' => 'InvalidParameterValue'
|
|
|
|
}
|
|
|
|
if name.empty?
|
|
|
|
response.body['Message'] = "Invalid value '' for name. Must be specified."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|