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/aws/requests/rds/reboot_db_instance.rb
Aaron Suggs 3faa90219e [aws|rds] Mocking better supports reboot state
Also cleanup some whitespace
2012-08-03 14:18:52 -04:00

51 lines
1.6 KiB
Ruby

module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/reboot_db_instance'
# reboots a database instance
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_RebootDBInstance.html
# ==== Parameters
# * DBInstanceIdentifier <~String> - name of the db instance to reboot
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
def reboot_db_instance(instance_identifier)
request({
'Action' => 'RebootDBInstance',
'DBInstanceIdentifier' => instance_identifier,
:parser => Fog::Parsers::AWS::RDS::RebootDBInstance.new,
})
end
end
class Mock
def reboot_db_instance(instance_identifier)
response = Excon::Response.new
if server = self.data[:servers][instance_identifier]
if server["DBInstanceStatus"] != "available"
raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not available for rebooting")
else
server["DBInstanceStatus"] = 'rebooting'
self.data[:reboot_time] = Time.now
response.status = 200
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
"RebootDBInstanceResult" => { "DBInstance" => server }
}
response
end
else
raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not found")
end
end
end
end
end
end