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

Merge pull request #220 from engineyard/default_engine_parameters

rds enhancements
This commit is contained in:
Wesley Beary 2016-01-25 13:46:25 -06:00
commit 57290fc5da
10 changed files with 169 additions and 6 deletions

View file

@ -29,6 +29,12 @@ module Fog
end
load(result) # data is an array of attribute hashes
end
def defaults(family)
data = service.describe_engine_default_parameters(family).body['DescribeEngineDefaultParametersResult']['Parameters']
load(data)
end
end
end
end

View file

@ -0,0 +1,30 @@
module Fog
module Parsers
module AWS
module RDS
class DBParameterParser < Fog::Parsers::Base
def reset
@db_parameter = new_db_parameter
end
def new_db_parameter
{}
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'IsModifiable'
@value == "true" ? true : false
else
@db_parameter[name] = @value.strip
end
end
end
end
end
end
end

View file

@ -0,0 +1,34 @@
module Fog
module Parsers
module AWS
module RDS
require 'fog/aws/parsers/rds/db_parameter_parser'
class DescribeEngineDefaultParameters < Fog::Parsers::AWS::RDS::DBParameterParser
def reset
@response = {'DescribeEngineDefaultParametersResult' => {'Parameters' => []}, 'ResponseMetadata' => {}}
super
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'Parameter'
@response['DescribeEngineDefaultParametersResult']['Parameters'] << @db_parameter
@db_parameter = new_db_parameter
when 'Marker'
@response['DescribeEngineDefaultParametersResult']['Marker'] = @value
when 'RequestId'
@response['ResponseMetadata'][name] = @value
else
super
end
end
end
end
end
end
end

View file

@ -62,6 +62,8 @@ module Fog
request :create_event_subscription
request :delete_event_subscription
request :describe_engine_default_parameters
model_path 'fog/aws/models/rds'
model :server
collection :servers
@ -100,6 +102,18 @@ module Fog
:subnet_groups => {},
:snapshots => {},
:event_subscriptions => {},
:default_parameters => {
"mysql5.5" => [
{
"DataType" => "integer",
"Source" => "engine-default",
"Description" => "Intended for use with master-to-master replication, and can be used to control the operation of AUTO_INCREMENT columns",
"ApplyType" => "dynamic",
"AllowedValues" => "1-65535",
"ParameterName" => "auto_increment_increment"
}
],
},
:db_engine_versions => [
{
'Engine' => "mysql",

View file

@ -84,6 +84,16 @@ module Fog
ec2 = Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id]
db_parameter_groups = if pg_name = options.delete("DBParameterGroupName")
group = self.data[:parameter_groups][pg_name]
if group
[{"DBParameterGroupName" => pg_name, "ParameterApplyStatus" => "in-sync" }]
else
raise Fog::AWS::RDS::NotFound.new("Parameter group does not exist")
end
else
[{ "DBParameterGroupName" => "default.mysql5.5", "ParameterApplyStatus" => "in-sync" }]
end
db_security_group_names = Array(options.delete("DBSecurityGroups"))
rds_security_groups = self.data[:security_groups].values
ec2_security_groups = ec2[:security_groups].values
@ -119,7 +129,7 @@ module Fog
"DBInstanceIdentifier" => db_name,
"DBInstanceStatus" =>"creating",
"DBName" => options["DBName"],
"DBParameterGroups" => [{ "DBParameterGroupName" => "default.mysql5.5", "ParameterApplyStatus" => "in-sync" }],
"DBParameterGroups" => db_parameter_groups,
"DBSecurityGroups" => db_security_groups,
"DBSubnetGroupName" => options["DBSubnetGroupName"],
"Endpoint" =>{},

View file

@ -34,7 +34,21 @@ module Fog
class Mock
def describe_db_parameters(name, opts={})
Fog::Mock.not_implemented
group = self.data[:parameter_groups][name]
unless group
raise Fog::AWS::RDS::NotFound.new("parameter group does not exist")
end
parameters = group[:parameters]
response = Excon::Response.new
response.body = {
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
"DescribeDBParametersResult" => { "Parameters" => parameters }
}
response.status = 200
response
end
end
end

View file

@ -0,0 +1,30 @@
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/describe_engine_default_parameters'
def describe_engine_default_parameters(family, opts={})
request({
'Action' => 'DescribeEngineDefaultParameters',
'DBParameterGroupFamily' => family,
:parser => Fog::Parsers::AWS::RDS::DescribeEngineDefaultParameters.new,
}.merge(opts))
end
end
class Mock
def describe_engine_default_parameters(family, opts={})
response = Excon::Response.new
response.status = 200
response.body = {
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
"DescribeEngineDefaultParametersResult" => { "Parameters" => self.data[:default_parameters][family]}
}
response
end
end
end
end
end

View file

@ -42,7 +42,34 @@ module Fog
class Mock
def modify_db_parameter_group(group_name, parameters)
Fog::Mock.not_implemented
group = self.data[:parameter_groups][group_name]
unless group
raise Fog::AWS::RDS::NotFound.new("Parameter group not found")
end
parameters.each do |p|
p.merge!(
"Source" => "user",
"IsModifiable" => true,
"Description" => "some string",
"DataType" => "string",
"AllowedValues" => p["ParameterValue"],
"ApplyType" => "dynamic"
)
end
group[:parameters] = parameters
self.data[:parameter_groups][group_name] = group
response = Excon::Response.new
response.body = {
"ResponseMetadata" => {"RequestId" => Fog::AWS::Mock.request_id},
"ModifyDBParameterGroupResult" => {"DBParameterGroupName" => group_name}
}
response.status = 200
response
end
end
end

View file

@ -21,7 +21,7 @@ Shindo.tests('AWS::RDS | parameter group requests', ['aws', 'rds']) do
body
end
tests("#describe_db_parameter_groups('fog-group)").formats(AWS::RDS::Formats::DESCRIBE_DB_PARAMETER_GROUP) do
tests("#describe_db_parameter_groups('fog-group')").formats(AWS::RDS::Formats::DESCRIBE_DB_PARAMETER_GROUP) do
body = Fog::AWS[:rds].describe_db_parameter_groups('fog-group').body

View file

@ -1,7 +1,5 @@
Shindo.tests('AWS::RDS | parameter requests', ['aws', 'rds']) do
tests('success') do
pending if Fog.mocking?
Fog::AWS[:rds].create_db_parameter_group('fog-group', 'MySQL5.1', 'Some description')
tests('#modify_db_parameter_group').formats(AWS::RDS::Formats::MODIFY_PARAMETER_GROUP) do