1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

mocking modify_db_instance and reboot_db_instance

This commit is contained in:
Rodrigo Estebanez 2011-12-01 01:08:28 +01:00
parent 17885d5c82
commit d83ea87732
4 changed files with 50 additions and 4 deletions

View file

@ -73,7 +73,7 @@ module Fog
"PreferredMaintenanceWindow"=>"mon:04:30-mon:05:00",
"Engine"=> options["Engine"],
"EngineVersion"=> options["EngineVersion"] || "5.1.57",
"PendingModifiedValues"=>{},
"PendingModifiedValues"=>{"MasterUserPassword"=>"****"}, # This clears when is available
"MultiAZ"=>false,
"MasterUsername"=> options["MasterUsername"],
"DBInstanceClass"=> options["DBInstanceClass"],

View file

@ -53,8 +53,15 @@ module Fog
server["availability_zone"] = region + 'a'
server["Endpoint"] = {"Port"=>3306,
"Address"=> Fog::AWS::Mock.rds_address(server["DBInstanceIdentifier"],region) }
server["PendingModifiedValues"] = {"MasterUserPassword"=>"****"}
server["PendingModifiedValues"] = {}
end
when "rebooting"
# it applies pending modified values
if server["PendingModifiedValues"]
server.merge!(server["PendingModifiedValues"])
server["PendingModifiedValues"] = {}
server["DBInstanceStatus"] = 'available'
end
end
end

View file

@ -45,7 +45,30 @@ module Fog
class Mock
def modify_db_instance(db_name, apply_immediately, options={})
Fog::Mock.not_implemented
response = Excon::Response.new
if server = self.data[:servers][db_name]
if server["DBInstanceStatus"] != "available"
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
else
# TODO verify the params options
# if apply_immediately is false, all the options go to pending_modified_values and then apply and clear after either
# a reboot or the maintainance window
if apply_immediately
modified_server = server.merge(options)
else
modified_server = server["PendingModifiedValues"].merge!(options) # it appends
end
response.status = 200
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
"ModifyDBInstanceResult" => { "DBInstance" => modified_server }
}
response
end
else
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not found")
end
end
end

View file

@ -25,7 +25,23 @@ module Fog
class Mock
def reboot_db_instance(instance_identifier)
Fog::Mock.not_implemented
response = Excon::Response.new
if server = self.data[:servers][instance_identifier]
if server["DBInstanceStatus"] != "available"
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for rebooting")
else
server["DBInstanceStatus"] = 'rebooting'
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 #{db_name} not found")
end
end
end