2011-02-27 16:09:12 -05:00
|
|
|
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)
|
2011-11-30 19:08:28 -05:00
|
|
|
response = Excon::Response.new
|
2012-08-03 14:18:52 -04:00
|
|
|
if server = self.data[:servers][instance_identifier]
|
|
|
|
if server["DBInstanceStatus"] != "available"
|
2011-12-22 15:49:27 -05:00
|
|
|
raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not available for rebooting")
|
2011-11-30 19:08:28 -05:00
|
|
|
else
|
2012-08-03 14:18:52 -04:00
|
|
|
server["DBInstanceStatus"] = 'rebooting'
|
|
|
|
self.data[:reboot_time] = Time.now
|
2011-11-30 19:08:28 -05:00
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
|
2012-08-03 14:18:52 -04:00
|
|
|
"RebootDBInstanceResult" => { "DBInstance" => server }
|
2011-11-30 19:08:28 -05:00
|
|
|
}
|
|
|
|
response
|
2012-08-03 14:18:52 -04:00
|
|
|
|
2011-11-30 19:08:28 -05:00
|
|
|
end
|
|
|
|
else
|
2011-12-22 15:49:27 -05:00
|
|
|
raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not found")
|
2011-11-30 19:08:28 -05:00
|
|
|
end
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|