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/compute/requests/aws/stop_instances.rb
John Ferlito 5b3b1888ad Add force stop functionality to AWS Instance
AWS allows you to add a force option to the stop request. This performs
the equivalent of a power off, rather thank asking the OS to shutdown.
2011-08-08 17:32:25 +10:00

33 lines
1,009 B
Ruby

module Fog
module Compute
class AWS
class Real
require 'fog/compute/parsers/aws/start_stop_instances'
# Stop specified instance
#
# ==== Parameters
# * instance_id<~Array> - Id of instance to start
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * TODO: fill in the blanks
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-StopInstances.html]
def stop_instances(instance_id, force = false)
params = Fog::AWS.indexed_param('InstanceId', instance_id)
params.merge!('Force' => 'true') if force
request({
'Action' => 'StopInstances',
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::StartStopInstances.new
}.merge!(params))
end
end
end
end
end