rdstune 1.2.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rdstune +18 -8
- data/lib/ec2info.rb +20 -0
- data/lib/rdstune.rb +12 -3
- data/lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ac11bb822eb833691837dde44033a06ed68e8cd
|
4
|
+
data.tar.gz: da661b2ba83116d93c866081678bc1f23e53c161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f4b503d14c8041a1a6f9be33f903a87c03ba4ccd1fae8aafd0fdf09ec1f86362f1636f9d14980a3ad8f1eb663c8175a182227369b846136950d1ab166d245ee
|
7
|
+
data.tar.gz: 1657ab25b1ea3c35511fb964810a4f54805cd388f08fd09019f8fa7ce1c71386bec6ed4a0d3a400ede77cc5718460eb3b6a5163d773d3f6051c19b9fca6cdb9c
|
data/bin/rdstune
CHANGED
@@ -13,33 +13,43 @@ This gem creates a Parameter Group with sane defaults for your PostgreSQL RDS in
|
|
13
13
|
Options:
|
14
14
|
EOS
|
15
15
|
opt :type, "Type of Database Server (Web/DW/Mixed/Desktop)", :type => :string, :default => 'web'
|
16
|
+
opt :instance_type, "Generate values based on an AWS instance type", :type => :string
|
16
17
|
opt :memory, "Amount of Memory on the Server (GiB)", :type => :float
|
17
18
|
opt :connections, "Specify the Target Max Connections", :type => :integer
|
18
19
|
opt :oversubscribe, "Oversubscribe the number of connections", :type => :integer
|
19
20
|
opt :name, "Name of your RDS Parameter Group", :type => :string
|
20
21
|
opt :family, "Database Family (Postgres version)", :type => :string, :default => 'postgres9.4'
|
21
|
-
opt :access_key_id, "Set the AWS Access Key for the account
|
22
|
-
opt :secret_access_key, "Set the AWS Secret Key for the account
|
23
|
-
opt :region, "Specify the AWS Region for the account
|
22
|
+
opt :access_key_id, "Set the AWS Access Key for the account", :type => :string, :default => ENV['AWS_ACCESS_KEY_ID']
|
23
|
+
opt :secret_access_key, "Set the AWS Secret Key for the account", :type => :string, :default => ENV['AWS_SECRET_ACCESS_KEY']
|
24
|
+
opt :region, "Specify the AWS Region for the account", :type => :string, :default => ENV['AWS_REGION']
|
25
|
+
opt :dry, "Dry Run - Do not Create", :default => false
|
24
26
|
opt :version, "Show the current version of rdstune"
|
25
27
|
end
|
26
28
|
|
27
29
|
opts = Trollop::with_standard_exception_handling p do
|
28
30
|
o = p.parse ARGV
|
29
|
-
if o[:memory] == nil or o[:connections] == nil
|
31
|
+
if (o[:memory] == nil or o[:instance_type] == nil) and (o[:connections] == nil)
|
30
32
|
raise Trollop::HelpNeeded
|
31
33
|
end
|
32
34
|
o
|
33
35
|
end
|
34
36
|
|
35
|
-
|
37
|
+
if opts[:instance_type]
|
38
|
+
name = opts[:name] || "rdstune-#{opts[:instance_type]}-#{opts[:connections]}".gsub('.','-')
|
39
|
+
else
|
40
|
+
name = opts[:name] || "rdstune-#{opts[:type]}-#{opts[:memory]}-#{opts[:connections]}".gsub('.','-')
|
41
|
+
end
|
42
|
+
|
36
43
|
options = {}
|
37
44
|
aws_credentials = { :access_key_id => opts[:access_key_id],
|
38
45
|
:secret_access_key => opts[:secret_access_key],
|
39
46
|
:region => opts[:region] }
|
40
47
|
options['connections'] = opts[:connections] if opts[:connections]
|
41
48
|
options['oversubscribe'] = opts[:oversubscribe] if opts[:oversubscribe]
|
42
|
-
|
43
|
-
|
44
|
-
|
49
|
+
|
50
|
+
rdstune = RDSTUNE::RdsTune.new(instance_type: opts[:instance_type], type: opts[:type],
|
51
|
+
memory: opts[:memory],aws_credentials: aws_credentials,
|
52
|
+
options: options)
|
53
|
+
|
54
|
+
rdstune.create_parameter_group(name: name, family: opts[:family]) unless opts[:dry]
|
45
55
|
rdstune.display_config
|
data/lib/ec2info.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module RDSTUNE
|
5
|
+
class Ec2Info
|
6
|
+
def initialize(instance_type)
|
7
|
+
@instance_type = instance_type
|
8
|
+
@ec2info = JSON.parse(Net::HTTP.get(URI('http://www.ec2instances.info/instances.json')))
|
9
|
+
end
|
10
|
+
|
11
|
+
def show()
|
12
|
+
puts get()
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_memory()
|
16
|
+
m = @ec2info.select {|instances| instances['instance_type'] == @instance_type}
|
17
|
+
m.first["memory"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/rdstune.rb
CHANGED
@@ -1,18 +1,26 @@
|
|
1
1
|
require 'aws-sdk'
|
2
2
|
require 'mrtuner'
|
3
|
+
require_relative 'ec2info'
|
3
4
|
|
4
5
|
|
5
6
|
module RDSTUNE
|
6
7
|
class RdsTune < MrTuner
|
7
8
|
|
8
|
-
def initialize(type: nil, memory: nil, options: {}, aws_credentials: {}, rds_client: nil)
|
9
|
+
def initialize(instance_type: nil, type: nil, memory: nil, options: {}, aws_credentials: {}, rds_client: nil)
|
9
10
|
if rds_client
|
10
11
|
@rds = rds_client
|
11
12
|
else
|
12
13
|
@rds = Aws::RDS::Client.new(aws_credentials)
|
13
14
|
end
|
15
|
+
|
16
|
+
if instance_type then
|
17
|
+
@ec2info = Ec2Info.new(instance_type)
|
18
|
+
@memory = @ec2info.get_memory
|
19
|
+
else
|
20
|
+
@memory = memory
|
21
|
+
end
|
22
|
+
|
14
23
|
@type = type
|
15
|
-
@memory = memory
|
16
24
|
@options = options
|
17
25
|
super(@type, @memory, @options)
|
18
26
|
end
|
@@ -22,10 +30,11 @@ module RDSTUNE
|
|
22
30
|
group_name = name
|
23
31
|
group_family = family
|
24
32
|
unless find_parameter_group(group_name)
|
33
|
+
description = "Created by RdsTune - #{@type} - #{@memory} - #{Time.now.to_s}"
|
25
34
|
@rds.create_db_parameter_group({
|
26
35
|
:db_parameter_group_name => group_name,
|
27
36
|
:db_parameter_group_family => group_family,
|
28
|
-
:description =>
|
37
|
+
:description => description
|
29
38
|
})
|
30
39
|
end
|
31
40
|
update_parameter_group(group_name)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdstune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Kerr
|
@@ -61,6 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- bin/rdstune
|
63
63
|
- contributors.txt
|
64
|
+
- lib/ec2info.rb
|
64
65
|
- lib/rdstune.rb
|
65
66
|
- lib/version.rb
|
66
67
|
- license.txt
|