auser-poolparty 0.1.0 → 0.1.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.
- data/CHANGELOG +1 -0
- data/README.txt +5 -7
- data/Rakefile +27 -12
- data/bin/instance +2 -2
- data/bin/pool +8 -6
- data/config/reconfigure_instances_script.sh +3 -3
- data/config/sample-config.yml +1 -1
- data/lib/core/array.rb +5 -2
- data/lib/core/hash.rb +1 -1
- data/lib/core/string.rb +6 -2
- data/lib/helpers/plugin_spec_helper.rb +4 -5
- data/lib/modules/sprinkle_overrides.rb +24 -29
- data/lib/poolparty/application.rb +37 -27
- data/lib/poolparty/master.rb +35 -14
- data/lib/poolparty/plugin.rb +11 -6
- data/lib/poolparty/plugin_manager.rb +2 -2
- data/lib/poolparty/provider/{packages/essential.rb → essential.rb} +0 -0
- data/lib/poolparty/provider/{packages/git.rb → git.rb} +0 -0
- data/lib/poolparty/provider/{packages/haproxy.rb → haproxy.rb} +1 -1
- data/lib/poolparty/provider/{packages/heartbeat.rb → heartbeat.rb} +0 -0
- data/lib/poolparty/provider/{packages/rsync.rb → rsync.rb} +0 -0
- data/lib/poolparty/provider/{packages/ruby.rb → ruby.rb} +1 -1
- data/lib/poolparty/provider/{packages/s3fuse.rb → s3fuse.rb} +0 -0
- data/lib/poolparty/provider.rb +86 -2
- data/lib/poolparty/remote_instance.rb +35 -21
- data/lib/poolparty/remoter.rb +4 -1
- data/lib/poolparty/remoting.rb +2 -1
- data/lib/poolparty/tasks/cloud.rake +1 -1
- data/lib/poolparty/tasks/development.rake +48 -13
- data/lib/poolparty/tasks.rb +24 -6
- data/lib/poolparty.rb +8 -4
- data/poolparty.gemspec +10 -7
- data/spec/helpers/ec2_mock.rb +5 -2
- data/spec/{application_spec.rb → lib/application_spec.rb} +42 -9
- data/spec/{callback_spec.rb → lib/callback_spec.rb} +1 -1
- data/spec/{core_spec.rb → lib/core_spec.rb} +6 -4
- data/spec/{ec2_wrapper_spec.rb → lib/ec2_wrapper_spec.rb} +3 -3
- data/spec/{file_writer_spec.rb → lib/file_writer_spec.rb} +2 -2
- data/spec/{kernel_spec.rb → lib/kernel_spec.rb} +1 -1
- data/spec/{master_spec.rb → lib/master_spec.rb} +38 -16
- data/spec/{optioner_spec.rb → lib/optioner_spec.rb} +1 -1
- data/spec/{plugin_manager_spec.rb → lib/plugin_manager_spec.rb} +3 -3
- data/spec/{plugin_spec.rb → lib/plugin_spec.rb} +12 -1
- data/spec/{pool_binary_spec.rb → lib/pool_binary_spec.rb} +1 -1
- data/spec/{poolparty_spec.rb → lib/poolparty_spec.rb} +5 -5
- data/spec/lib/provider_spec.rb +72 -0
- data/spec/{remote_instance_spec.rb → lib/remote_instance_spec.rb} +51 -9
- data/spec/{remoter_spec.rb → lib/remoter_spec.rb} +7 -2
- data/spec/{remoting_spec.rb → lib/remoting_spec.rb} +60 -4
- data/spec/{scheduler_spec.rb → lib/scheduler_spec.rb} +1 -1
- data/spec/{string_spec.rb → lib/string_spec.rb} +1 -1
- data/spec/monitors/cpu_monitor_spec.rb +2 -2
- data/spec/monitors/memory_spec.rb +3 -3
- data/spec/monitors/misc_monitor_spec.rb +1 -1
- data/spec/monitors/web_spec.rb +3 -3
- metadata +46 -41
- data/lib/poolparty/provider/packages/monit.rb +0 -6
- data/lib/poolparty/provider/provider.rb +0 -100
- data/spec/provider_spec.rb +0 -18
data/lib/poolparty/provider.rb
CHANGED
@@ -1,2 +1,86 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module PoolParty
|
2
|
+
class Provider
|
3
|
+
include Sprinkle
|
4
|
+
|
5
|
+
def install_poolparty
|
6
|
+
PoolParty.message "Installing required poolparty paraphernalia"
|
7
|
+
load_packages
|
8
|
+
user_packages.map {|blk| blk.call if blk }
|
9
|
+
|
10
|
+
policy :poolparty, :roles => :app do
|
11
|
+
requires :git
|
12
|
+
requires :ruby
|
13
|
+
requires :heartbeat
|
14
|
+
requires :haproxy
|
15
|
+
requires :s3fs
|
16
|
+
requires :rsync
|
17
|
+
requires :required_gems
|
18
|
+
|
19
|
+
PoolParty::Provider.user_install_packages.each do |req|
|
20
|
+
requires req.to_sym
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
set_start_with_sprinkle
|
25
|
+
@deployment.process if @deployment
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.define_custom_package name=:userpackages, &block
|
29
|
+
(user_install_packages << name).uniq!
|
30
|
+
user_packages << block
|
31
|
+
end
|
32
|
+
|
33
|
+
def user_packages
|
34
|
+
self.class.user_packages
|
35
|
+
end
|
36
|
+
|
37
|
+
def user_install_packages
|
38
|
+
self.class.user_install_packages
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.user_packages
|
42
|
+
@user_packages ||= []
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.user_install_packages
|
46
|
+
@load_strings ||= []
|
47
|
+
end
|
48
|
+
|
49
|
+
def load_packages
|
50
|
+
Dir["#{File.expand_path(File.dirname(__FILE__))}/provider/*"].each do |f|
|
51
|
+
load f
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_start_with_sprinkle
|
56
|
+
deployment do
|
57
|
+
delivery :vlad do
|
58
|
+
set :user, "#{Application.username}"
|
59
|
+
|
60
|
+
Master.cloud_ips.each do |ip|
|
61
|
+
role :app, "#{Application.username}@#{ip}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
source do
|
66
|
+
prefix '/usr/local'
|
67
|
+
archives '/root/sources'
|
68
|
+
builds '/root/builds'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
class << self
|
75
|
+
require "sprinkle"
|
76
|
+
|
77
|
+
def install_poolparty
|
78
|
+
singleton.install_poolparty
|
79
|
+
end
|
80
|
+
def singleton
|
81
|
+
@singleton ||= new
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -67,42 +67,42 @@ module PoolParty
|
|
67
67
|
ssh("monit #{cmd} all")
|
68
68
|
end
|
69
69
|
end
|
70
|
-
def configure_tasks
|
70
|
+
def configure_tasks(quiet=true)
|
71
71
|
{
|
72
|
+
:setup_pems => setup_pems,
|
72
73
|
:move_hostfile => change_hostname,
|
73
74
|
:config_master => configure_master,
|
74
75
|
:move_config_file => move_config_file,
|
75
|
-
:set_hostname => change_hostname,
|
76
76
|
:mount_s3_drive => mount_s3_drive,
|
77
|
-
:update_plugins => update_plugin_string,
|
78
|
-
:configure_monit => configure_monit,
|
77
|
+
:update_plugins => update_plugin_string,
|
79
78
|
:configure_authkeys => configure_authkeys,
|
80
79
|
:configure_resource_d => configure_resource_d,
|
81
80
|
:configure_haproxy => setup_haproxy,
|
82
81
|
:configure_heartbeat => configure_heartbeat,
|
83
82
|
:user_tasks => user_tasks
|
84
|
-
}
|
83
|
+
}#.map {|k,v| {k.to_sym => v.nice_runnable(quiet)} }.inject({}) {|a,s| s.merge(a) }
|
85
84
|
end
|
86
85
|
def user_tasks
|
87
86
|
@@user_tasks ||= []
|
88
87
|
end
|
89
88
|
def move_config_file
|
90
89
|
<<-EOC
|
91
|
-
mv #{remote_base_tmp_dir}/config.yml ~/.config
|
90
|
+
#{if_exists "config.yml", "mv #{remote_base_tmp_dir}/config.yml ~/.config"}
|
92
91
|
mkdir -p ~/.ec2
|
93
|
-
mv #{remote_base_tmp_dir}/keypair ~/.ec2
|
92
|
+
#{if_exists "keypair", "mv #{remote_base_tmp_dir}/keypair ~/.ec2/#{Application.keypair_name}"}
|
94
93
|
EOC
|
95
94
|
end
|
96
|
-
def configure_heartbeat
|
97
|
-
|
95
|
+
def configure_heartbeat
|
96
|
+
cmd=<<-EOC
|
98
97
|
mv #{remote_base_tmp_dir}/ha.cf /etc/ha.d/ha.cf
|
99
98
|
/etc/init.d/heartbeat start
|
100
99
|
EOC
|
100
|
+
Master.requires_heartbeat? ? cmd : ""
|
101
101
|
end
|
102
102
|
def configure_authkeys
|
103
103
|
<<-EOC
|
104
104
|
mkdir -p /etc/ha.d
|
105
|
-
mv #{remote_base_tmp_dir}/authkeys /etc/ha.d/
|
105
|
+
#{if_exists "authkeys", "mv #{remote_base_tmp_dir}/authkeys /etc/ha.d/"}
|
106
106
|
EOC
|
107
107
|
end
|
108
108
|
|
@@ -118,25 +118,32 @@ module PoolParty
|
|
118
118
|
|
119
119
|
def configure_resource_d
|
120
120
|
<<-EOC
|
121
|
-
mkdir -p /etc/ha.d/resource.d
|
122
|
-
mv #{remote_base_tmp_dir}/cloud_master_takeover /etc/ha.d/resource.d
|
123
|
-
mv #{remote_base_tmp_dir}/resource.d/* /etc/ha.d/resource.d
|
121
|
+
mkdir -p /etc/ha.d/resource.d/
|
122
|
+
#{if_exists "cloud_master_takeover", "mv #{remote_base_tmp_dir}/cloud_master_takeover /etc/ha.d/resource.d"}
|
123
|
+
#{if_dir_exists "resource.d/", "mv #{remote_base_tmp_dir}/resource.d/* /etc/ha.d/resource.d"}
|
124
124
|
EOC
|
125
125
|
end
|
126
126
|
|
127
|
-
def configure_monit
|
127
|
+
# def configure_monit
|
128
|
+
# <<-EOC
|
129
|
+
# mv #{remote_base_tmp_dir}/monitrc /etc/monit/monitrc
|
130
|
+
# mkdir -p /etc/monit.d/
|
131
|
+
# mv #{remote_base_tmp_dir}/monit.d/* /etc/monit.d/
|
132
|
+
# chown #{Application.username} /etc/monit/monitrc
|
133
|
+
# chmod 700 /etc/monit/monitrc
|
134
|
+
# EOC
|
135
|
+
# end
|
136
|
+
|
137
|
+
def setup_pems
|
128
138
|
<<-EOC
|
129
|
-
mv #{remote_base_tmp_dir}/
|
130
|
-
|
131
|
-
mv #{remote_base_tmp_dir}/monit.d/* /etc/monit.d/
|
132
|
-
chown #{Application.username} /etc/monit/monitrc
|
133
|
-
chmod 700 /etc/monit/monitrc
|
139
|
+
#{if_exists "cert.pem", "mv #{remote_base_tmp_dir}/cert-*.pem #{Application.keypair_path}/cert-CLOUD.pem"}
|
140
|
+
#{if_exists "pk.pem", "mv #{remote_base_tmp_dir}/pk-*.pem #{Application.keypair_path}/pk-CLOUD.pem"}
|
134
141
|
EOC
|
135
142
|
end
|
136
143
|
|
137
144
|
def change_hostname
|
138
145
|
<<-EOC
|
139
|
-
mv #{remote_base_tmp_dir}/#{name}-hosts /etc/hosts
|
146
|
+
#{if_exists "#{name}-hosts", "mv #{remote_base_tmp_dir}/#{name}-hosts /etc/hosts"}
|
140
147
|
hostname -v #{name}
|
141
148
|
EOC
|
142
149
|
end
|
@@ -184,7 +191,14 @@ module PoolParty
|
|
184
191
|
end
|
185
192
|
def update_plugin_string
|
186
193
|
dir = File.basename(Application.plugin_dir)
|
187
|
-
|
194
|
+
|
195
|
+
if_exists "plugins.tar.gz", "mkdir -p #{dir} && tar -zxf #{remote_base_tmp_dir}/plugins.tar.gz -C #{dir}"
|
196
|
+
end
|
197
|
+
def if_exists(file, dothis)
|
198
|
+
"if [ -f #{remote_base_tmp_dir}/#{file} ]; then #{dothis}; fi"
|
199
|
+
end
|
200
|
+
def if_dir_exists(dir, dothis)
|
201
|
+
"if [ -d #{remote_base_tmp_dir}/#{dir} ]; then #{dothis}; fi"
|
188
202
|
end
|
189
203
|
# Is this the master and if not, is the master running?
|
190
204
|
def is_not_master_and_master_is_not_running?
|
data/lib/poolparty/remoter.rb
CHANGED
@@ -6,7 +6,10 @@ module PoolParty
|
|
6
6
|
module Remoter
|
7
7
|
module ClassMethods
|
8
8
|
def ssh_string
|
9
|
-
"ssh
|
9
|
+
(["ssh"] << ssh_array).join(" ")
|
10
|
+
end
|
11
|
+
def ssh_array
|
12
|
+
["-o StrictHostKeyChecking=no", "-l '#{Application.username}'", "-i '#{Application.keypair_path}'"]
|
10
13
|
end
|
11
14
|
def rsync_string
|
12
15
|
"rsync --delete -azP -e '#{ssh_string}' "
|
data/lib/poolparty/remoting.rb
CHANGED
@@ -36,6 +36,7 @@ module PoolParty
|
|
36
36
|
end
|
37
37
|
# list of keypairs for the current AWS access key and secret key
|
38
38
|
def cloud_keypairs
|
39
|
+
get_instances_description.each {|a| a[:keypair] = "no-keypair" unless a[:keypair] } # Get rid of the instances not launched with a keypair
|
39
40
|
instances = get_instances_description.sort{|x,y| x[:keypair] <=> y[:keypair]}
|
40
41
|
keypair = nil
|
41
42
|
instances.map {|a| keypair != a[:keypair] ? (keypair = a[:keypair]; keypair) : nil }.compact
|
@@ -104,7 +105,7 @@ module PoolParty
|
|
104
105
|
end
|
105
106
|
# Request termination of all instances regardless of their state (includes pending instances)
|
106
107
|
def request_termination_of_all_instances
|
107
|
-
|
108
|
+
list_of_instances.each {|a| terminate_instance!(a[:instance_id])}
|
108
109
|
end
|
109
110
|
# Terminate instance by id
|
110
111
|
def request_termination_of_instance(id)
|
@@ -1,35 +1,70 @@
|
|
1
1
|
namespace(:dev) do
|
2
|
-
task :
|
2
|
+
task :initialize do
|
3
3
|
setup_application
|
4
4
|
run "mkdir ~/.ec2 >/dev/null 2>/dev/null" unless File.directory?("~/.ec2")
|
5
5
|
end
|
6
6
|
# Setup a basic development environment for the user
|
7
7
|
desc "Setup development environment specify the config_file"
|
8
|
-
task :setup => [:
|
8
|
+
task :setup => [:initialize, :setup_keypair] do
|
9
|
+
certloc = "#{Application.ec2_dir}/#{Application.keypair}/cert-*.pem 2>/dev/null"
|
10
|
+
pkloc = "#{Application.ec2_dir}/#{Application.keypair}/pk-*.pem 2>/dev/null"
|
11
|
+
unless `ls #{certloc}`.length > 1 && `ls #{pkloc}`.length > 1
|
12
|
+
puts <<-EOM
|
13
|
+
Make sure you run rake dev:setup_pemkeys before you run this command
|
14
|
+
|
15
|
+
I cannot continue until your keys are setup.
|
16
|
+
exiting...
|
17
|
+
EOM
|
18
|
+
exit
|
19
|
+
end
|
9
20
|
keyfilename = ".#{Application.keypair}_pool_keys"
|
10
21
|
run <<-EOR
|
11
|
-
echo 'export
|
12
|
-
echo 'export
|
22
|
+
echo 'export AWS_ACCESS_KEY=\"#{Application.access_key}\"' > $HOME/#{keyfilename}
|
23
|
+
echo 'export AWS_SECRET_ACCESS=\"#{Application.secret_access_key}\"' >> $HOME/#{keyfilename}
|
13
24
|
echo 'export EC2_HOME=\"#{Application.ec2_dir}\"' >> $HOME/#{keyfilename}
|
14
25
|
echo 'export KEYPAIR_NAME=\"#{Application.keypair}\"' >> $HOME/#{keyfilename}
|
15
|
-
echo 'export CONFIG_FILE=\"#{Application.config_file}\"' >> $HOME/#{keyfilename}
|
16
26
|
echo 'export EC2_PRIVATE_KEY=`ls ~/.ec2/#{Application.keypair}/pk-*.pem`;' >> $HOME/#{keyfilename}
|
17
27
|
echo 'export EC2_CERT=`ls ~/.ec2/#{Application.keypair}/cert-*.pem`;' >> $HOME/#{keyfilename}
|
18
|
-
source $HOME/#{keyfilename}
|
19
28
|
EOR
|
29
|
+
puts <<-EOM
|
30
|
+
To work on this cloud, source the file like:
|
31
|
+
|
32
|
+
source #{Application.ec2_dir}/#{keyfilename}
|
33
|
+
|
34
|
+
EOM
|
20
35
|
end
|
21
|
-
desc "Generate a keypair"
|
22
|
-
task :setup_keypair => :
|
36
|
+
desc "Generate a new keypair"
|
37
|
+
task :setup_keypair => [:initialize] do
|
23
38
|
unless File.file?(Application.keypair_path)
|
24
|
-
Application.keypair
|
25
|
-
|
26
|
-
|
27
|
-
chmod 600 #{Application.keypair_path}
|
39
|
+
Application.keypair ||= "cloud"
|
40
|
+
puts "-- setting up keypair named #{Application.keypair}"
|
41
|
+
run <<-EOR
|
42
|
+
chmod 600 #{Application.keypair_path} 2>/dev/null
|
43
|
+
mkdir ~/.ec2/#{Application.keypair} 2>/dev/null
|
44
|
+
ec2-add-keypair #{Application.keypair} > #{Application.keypair_path}
|
28
45
|
EOR
|
29
46
|
end
|
30
47
|
end
|
48
|
+
desc "Setup pem keys"
|
49
|
+
task :setup_pemkeys => [:initialize] do
|
50
|
+
puts "Setting up stubbed pem keys in ~/.ec2/#{Application.keypair}"
|
51
|
+
run <<-EOR
|
52
|
+
mkdir -p ~/.ec2/#{Application.keypair} 2>/dev/null
|
53
|
+
echo 'UPDATE ME' > #{Application.ec2_dir}/#{Application.keypair}/cert-UPDATEME.pem
|
54
|
+
echo 'UPDATE ME' > #{Application.ec2_dir}/#{Application.keypair}/pk-UPDATEME.pem
|
55
|
+
EOR
|
56
|
+
puts "Don't forget to replace your ~/.ec2/#{Application.keypair}/*.pem keys with the real amazon keys"
|
57
|
+
end
|
58
|
+
desc "initialize setup"
|
59
|
+
task :init => [:setup_pemkeys]
|
60
|
+
|
61
|
+
desc "Just an argv test"
|
62
|
+
task :test => :initialize do
|
63
|
+
puts "---- Testing ----"
|
64
|
+
puts PoolParty.options(ARGV.dup)
|
65
|
+
end
|
31
66
|
desc "Authorize base ports for application"
|
32
|
-
task :authorize_ports => :
|
67
|
+
task :authorize_ports => :initialize do
|
33
68
|
run <<-EOR
|
34
69
|
ec2-authorize -p 22 default
|
35
70
|
ec2-authorize -p 80 default
|
data/lib/poolparty/tasks.rb
CHANGED
@@ -11,19 +11,37 @@ module PoolParty
|
|
11
11
|
def define_tasks
|
12
12
|
# Run the command on the local system
|
13
13
|
def run(cmd)
|
14
|
-
system(cmd.runnable)
|
14
|
+
Kernel.system(cmd.runnable)
|
15
15
|
end
|
16
16
|
# Basic setup action
|
17
17
|
def setup_application
|
18
|
-
PoolParty.options(
|
18
|
+
@options ||= PoolParty.options(ARGV.dup)
|
19
19
|
end
|
20
20
|
|
21
21
|
# Require the poolparty specific tasks
|
22
|
-
|
23
|
-
|
24
|
-
Dir["#{PoolParty.plugin_dir}/*/Rakefile"].each {|t| load "#{t}" }
|
22
|
+
compiled_rakefile
|
25
23
|
|
24
|
+
desc "Reload the static variables"
|
25
|
+
task :reload do
|
26
|
+
reload!
|
27
|
+
end
|
26
28
|
true
|
27
|
-
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def reload!
|
32
|
+
@compiled_rakefile = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def compiled_rakefile
|
36
|
+
rake_str = []
|
37
|
+
|
38
|
+
Dir["#{File.expand_path(File.dirname(__FILE__))}/tasks/*.rake"].each { |t| rake_str << open(t).read }
|
39
|
+
plugin_rakefiles
|
40
|
+
|
41
|
+
@compiled_rakefile ||= eval(rake_str.join("\n")) # Not ideal
|
42
|
+
end
|
43
|
+
def plugin_rakefiles
|
44
|
+
Dir["#{PoolParty.plugin_dir}/*/Rakefile"].each {|t| load t }
|
45
|
+
end
|
28
46
|
end
|
29
47
|
end
|
data/lib/poolparty.rb
CHANGED
@@ -10,7 +10,11 @@ require 'rubygems'
|
|
10
10
|
require "aws/s3"
|
11
11
|
require "EC2"
|
12
12
|
require "aska"
|
13
|
-
|
13
|
+
begin
|
14
|
+
require 'crafterm-sprinkle'
|
15
|
+
rescue LoadError
|
16
|
+
require "sprinkle"
|
17
|
+
end
|
14
18
|
require "pp"
|
15
19
|
require "tempfile"
|
16
20
|
|
@@ -44,7 +48,7 @@ module PoolParty
|
|
44
48
|
class Version #:nodoc:
|
45
49
|
@major = 0
|
46
50
|
@minor = 1
|
47
|
-
@tiny =
|
51
|
+
@tiny = 1
|
48
52
|
|
49
53
|
def self.string
|
50
54
|
[@major, @minor, @tiny].join('.')
|
@@ -95,7 +99,7 @@ module PoolParty
|
|
95
99
|
def registered_monitor?(name); registered_monitors.include?(name); end
|
96
100
|
def registered_monitors; @@registered_monitors ||= [];end
|
97
101
|
|
98
|
-
def
|
102
|
+
def load_app
|
99
103
|
load_monitors
|
100
104
|
load_plugins
|
101
105
|
end
|
@@ -112,7 +116,7 @@ module PoolParty
|
|
112
116
|
@@installed_plugins = nil
|
113
117
|
end
|
114
118
|
def plugin_dir
|
115
|
-
"#{user_dir}/
|
119
|
+
"#{user_dir}/plugins"
|
116
120
|
end
|
117
121
|
def read_config_file(filename)
|
118
122
|
return {} unless filename
|
data/poolparty.gemspec
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{poolparty}
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new("= 1.2") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Ari Lerner"]
|
7
7
|
s.cert_chain = nil
|
8
|
-
s.date = %q{2008-07-
|
8
|
+
s.date = %q{2008-07-19}
|
9
9
|
s.description = %q{Run your entire application off EC2, managed and auto-scaling}
|
10
10
|
s.email = %q{ari.lerner@citrusbyte.com}
|
11
11
|
s.executables = ["instance", "pool", "poolnotify"]
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "README.txt", "bin", "bin/instance", "bin/pool", "bin/poolnotify", "lib", "lib/core", "lib/core/array.rb", "lib/core/exception.rb", "lib/core/float.rb", "lib/core/hash.rb", "lib/core/kernel.rb", "lib/core/module.rb", "lib/core/object.rb", "lib/core/proc.rb", "lib/core/string.rb", "lib/core/time.rb", "lib/helpers", "lib/helpers/plugin_spec_helper.rb", "lib/modules", "lib/modules/callback.rb", "lib/modules/ec2_wrapper.rb", "lib/modules/file_writer.rb", "lib/modules/safe_instance.rb", "lib/modules/sprinkle_overrides.rb", "lib/modules/vlad_override.rb", "lib/poolparty", "lib/poolparty.rb", "lib/poolparty/application.rb", "lib/poolparty/init.rb", "lib/poolparty/master.rb", "lib/poolparty/monitors", "lib/poolparty/monitors.rb", "lib/poolparty/monitors/cpu.rb", "lib/poolparty/monitors/memory.rb", "lib/poolparty/monitors/web.rb", "lib/poolparty/optioner.rb", "lib/poolparty/plugin.rb", "lib/poolparty/plugin_manager.rb", "lib/poolparty/provider", "lib/poolparty/provider.rb", "lib/poolparty/provider/
|
13
|
-
s.files = ["CHANGELOG", "README.txt", "Rakefile", "assets", "assets/clouds.png", "bin", "bin/instance", "bin/pool", "bin/poolnotify", "config", "config/cloud_master_takeover", "config/create_proxy_ami.sh", "config/haproxy.conf", "config/heartbeat.conf", "config/heartbeat_authkeys.conf", "config/installers", "config/installers/ubuntu_install.sh", "config/monit", "config/monit.conf", "config/monit/haproxy.monit.conf", "config/monit/nginx.monit.conf", "config/nginx.conf", "config/reconfigure_instances_script.sh", "config/sample-config.yml", "config/scp_instances_script.sh", "lib", "lib/core", "lib/core/array.rb", "lib/core/exception.rb", "lib/core/float.rb", "lib/core/hash.rb", "lib/core/kernel.rb", "lib/core/module.rb", "lib/core/object.rb", "lib/core/proc.rb", "lib/core/string.rb", "lib/core/time.rb", "lib/helpers", "lib/helpers/plugin_spec_helper.rb", "lib/modules", "lib/modules/callback.rb", "lib/modules/ec2_wrapper.rb", "lib/modules/file_writer.rb", "lib/modules/safe_instance.rb", "lib/modules/sprinkle_overrides.rb", "lib/modules/vlad_override.rb", "lib/poolparty", "lib/poolparty.rb", "lib/poolparty/application.rb", "lib/poolparty/init.rb", "lib/poolparty/master.rb", "lib/poolparty/monitors", "lib/poolparty/monitors.rb", "lib/poolparty/monitors/cpu.rb", "lib/poolparty/monitors/memory.rb", "lib/poolparty/monitors/web.rb", "lib/poolparty/optioner.rb", "lib/poolparty/plugin.rb", "lib/poolparty/plugin_manager.rb", "lib/poolparty/provider", "lib/poolparty/provider.rb", "lib/poolparty/provider/
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "README.txt", "bin", "bin/instance", "bin/pool", "bin/poolnotify", "lib", "lib/core", "lib/core/array.rb", "lib/core/exception.rb", "lib/core/float.rb", "lib/core/hash.rb", "lib/core/kernel.rb", "lib/core/module.rb", "lib/core/object.rb", "lib/core/proc.rb", "lib/core/string.rb", "lib/core/time.rb", "lib/helpers", "lib/helpers/plugin_spec_helper.rb", "lib/modules", "lib/modules/callback.rb", "lib/modules/ec2_wrapper.rb", "lib/modules/file_writer.rb", "lib/modules/safe_instance.rb", "lib/modules/sprinkle_overrides.rb", "lib/modules/vlad_override.rb", "lib/poolparty", "lib/poolparty.rb", "lib/poolparty/application.rb", "lib/poolparty/init.rb", "lib/poolparty/master.rb", "lib/poolparty/monitors", "lib/poolparty/monitors.rb", "lib/poolparty/monitors/cpu.rb", "lib/poolparty/monitors/memory.rb", "lib/poolparty/monitors/web.rb", "lib/poolparty/optioner.rb", "lib/poolparty/plugin.rb", "lib/poolparty/plugin_manager.rb", "lib/poolparty/provider", "lib/poolparty/provider.rb", "lib/poolparty/provider/essential.rb", "lib/poolparty/provider/git.rb", "lib/poolparty/provider/haproxy.rb", "lib/poolparty/provider/heartbeat.rb", "lib/poolparty/provider/rsync.rb", "lib/poolparty/provider/ruby.rb", "lib/poolparty/provider/s3fuse.rb", "lib/poolparty/remote_instance.rb", "lib/poolparty/remoter.rb", "lib/poolparty/remoting.rb", "lib/poolparty/scheduler.rb", "lib/poolparty/tasks", "lib/poolparty/tasks.rb", "lib/poolparty/tasks/cloud.rake", "lib/poolparty/tasks/development.rake", "lib/poolparty/tasks/ec2.rake", "lib/poolparty/tasks/instance.rake", "lib/poolparty/tasks/plugins.rake", "lib/poolparty/tasks/server.rake", "lib/poolparty/thread_pool.rb", "lib/s3", "lib/s3/s3_object_store_folders.rb"]
|
13
|
+
s.files = ["CHANGELOG", "README.txt", "Rakefile", "assets", "assets/clouds.png", "bin", "bin/instance", "bin/pool", "bin/poolnotify", "config", "config/cloud_master_takeover", "config/create_proxy_ami.sh", "config/haproxy.conf", "config/heartbeat.conf", "config/heartbeat_authkeys.conf", "config/installers", "config/installers/ubuntu_install.sh", "config/monit", "config/monit.conf", "config/monit/haproxy.monit.conf", "config/monit/nginx.monit.conf", "config/nginx.conf", "config/reconfigure_instances_script.sh", "config/sample-config.yml", "config/scp_instances_script.sh", "lib", "lib/core", "lib/core/array.rb", "lib/core/exception.rb", "lib/core/float.rb", "lib/core/hash.rb", "lib/core/kernel.rb", "lib/core/module.rb", "lib/core/object.rb", "lib/core/proc.rb", "lib/core/string.rb", "lib/core/time.rb", "lib/helpers", "lib/helpers/plugin_spec_helper.rb", "lib/modules", "lib/modules/callback.rb", "lib/modules/ec2_wrapper.rb", "lib/modules/file_writer.rb", "lib/modules/safe_instance.rb", "lib/modules/sprinkle_overrides.rb", "lib/modules/vlad_override.rb", "lib/poolparty", "lib/poolparty.rb", "lib/poolparty/application.rb", "lib/poolparty/init.rb", "lib/poolparty/master.rb", "lib/poolparty/monitors", "lib/poolparty/monitors.rb", "lib/poolparty/monitors/cpu.rb", "lib/poolparty/monitors/memory.rb", "lib/poolparty/monitors/web.rb", "lib/poolparty/optioner.rb", "lib/poolparty/plugin.rb", "lib/poolparty/plugin_manager.rb", "lib/poolparty/provider", "lib/poolparty/provider.rb", "lib/poolparty/provider/essential.rb", "lib/poolparty/provider/git.rb", "lib/poolparty/provider/haproxy.rb", "lib/poolparty/provider/heartbeat.rb", "lib/poolparty/provider/rsync.rb", "lib/poolparty/provider/ruby.rb", "lib/poolparty/provider/s3fuse.rb", "lib/poolparty/remote_instance.rb", "lib/poolparty/remoter.rb", "lib/poolparty/remoting.rb", "lib/poolparty/scheduler.rb", "lib/poolparty/tasks", "lib/poolparty/tasks.rb", "lib/poolparty/tasks/cloud.rake", "lib/poolparty/tasks/development.rake", "lib/poolparty/tasks/ec2.rake", "lib/poolparty/tasks/instance.rake", "lib/poolparty/tasks/plugins.rake", "lib/poolparty/tasks/server.rake", "lib/poolparty/thread_pool.rb", "lib/s3", "lib/s3/s3_object_store_folders.rb", "plugins", "spec", "spec/files", "spec/files/describe_response", "spec/files/multi_describe_response", "spec/files/remote_desc_response", "spec/helpers", "spec/helpers/ec2_mock.rb", "spec/lib", "spec/lib/application_spec.rb", "spec/lib/callback_spec.rb", "spec/lib/core_spec.rb", "spec/lib/ec2_wrapper_spec.rb", "spec/lib/file_writer_spec.rb", "spec/lib/kernel_spec.rb", "spec/lib/master_spec.rb", "spec/lib/optioner_spec.rb", "spec/lib/plugin_manager_spec.rb", "spec/lib/plugin_spec.rb", "spec/lib/pool_binary_spec.rb", "spec/lib/poolparty_spec.rb", "spec/lib/provider_spec.rb", "spec/lib/remote_instance_spec.rb", "spec/lib/remoter_spec.rb", "spec/lib/remoting_spec.rb", "spec/lib/scheduler_spec.rb", "spec/lib/string_spec.rb", "spec/monitors", "spec/monitors/cpu_monitor_spec.rb", "spec/monitors/memory_spec.rb", "spec/monitors/misc_monitor_spec.rb", "spec/monitors/web_spec.rb", "spec/spec_helper.rb", "poolparty.gemspec"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://poolpartyrb.com}
|
16
16
|
s.post_install_message = %q{
|
17
17
|
|
18
|
-
Get ready to jump in the pool, you just installed PoolParty! (Updated at
|
18
|
+
Get ready to jump in the pool, you just installed PoolParty! (Updated at 05:57PM, 07/19/08)
|
19
19
|
|
20
20
|
Please check out the documentation for any questions or check out the google groups at
|
21
21
|
http://groups.google.com/group/poolpartyrb
|
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
For more information, check http://poolpartyrb.com
|
26
26
|
On IRC:
|
27
|
-
irc.freenode.net
|
28
|
-
|
27
|
+
irc.freenode.net / #poolpartyrb
|
28
|
+
|
29
29
|
*** Ari Lerner @ <ari.lerner@citrusbyte.com> ***
|
30
30
|
}
|
31
31
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Poolparty", "--main", "README.txt"]
|
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.add_runtime_dependency(%q<git>, [">= 0"])
|
46
46
|
s.add_runtime_dependency(%q<crafterm-sprinkle>, [">= 0"])
|
47
47
|
s.add_runtime_dependency(%q<SystemTimer>, [">= 0"])
|
48
|
+
s.add_runtime_dependency(%q<open4>, [">= 0"])
|
48
49
|
s.add_development_dependency(%q<echoe>, [">= 0"])
|
49
50
|
else
|
50
51
|
s.add_dependency(%q<aws-s3>, [">= 0"])
|
@@ -53,6 +54,7 @@ Gem::Specification.new do |s|
|
|
53
54
|
s.add_dependency(%q<git>, [">= 0"])
|
54
55
|
s.add_dependency(%q<crafterm-sprinkle>, [">= 0"])
|
55
56
|
s.add_dependency(%q<SystemTimer>, [">= 0"])
|
57
|
+
s.add_dependency(%q<open4>, [">= 0"])
|
56
58
|
s.add_dependency(%q<echoe>, [">= 0"])
|
57
59
|
end
|
58
60
|
else
|
@@ -62,6 +64,7 @@ Gem::Specification.new do |s|
|
|
62
64
|
s.add_dependency(%q<git>, [">= 0"])
|
63
65
|
s.add_dependency(%q<crafterm-sprinkle>, [">= 0"])
|
64
66
|
s.add_dependency(%q<SystemTimer>, [">= 0"])
|
67
|
+
s.add_dependency(%q<open4>, [">= 0"])
|
65
68
|
s.add_dependency(%q<echoe>, [">= 0"])
|
66
69
|
end
|
67
70
|
end
|
data/spec/helpers/ec2_mock.rb
CHANGED
@@ -2,9 +2,9 @@ module PoolParty
|
|
2
2
|
class Master
|
3
3
|
def launch_new_instance!
|
4
4
|
letter = ("a".."z").to_a[instances.size] # For unique instance_ids
|
5
|
-
h = {:instance_id => "i-58ba56#{letter}", :ip => "ip-127-0-0-1.aws.amazonaws.com", :status => "pending", :launching_time => Time.now }
|
5
|
+
h = {:instance_id => "i-58ba56#{letter}", :ip => "ip-127-0-0-1.aws.amazonaws.com", :status => "pending", :keypair => "alist", :launching_time => Time.now }
|
6
6
|
instances << h
|
7
|
-
Thread.new {wait 0.
|
7
|
+
Thread.new {wait 0.01;h[:status] = "running"} # Simulate the startup time
|
8
8
|
return h
|
9
9
|
end
|
10
10
|
# Shutdown the instance by instance_id
|
@@ -43,5 +43,8 @@ module PoolParty
|
|
43
43
|
def scp(s,d,o={})
|
44
44
|
"true"
|
45
45
|
end
|
46
|
+
def run(s)
|
47
|
+
"true"
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|
@@ -1,12 +1,16 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe "Application" do
|
4
4
|
before(:each) do
|
5
5
|
stub_option_load
|
6
6
|
Application.reset!
|
7
7
|
end
|
8
|
-
|
9
|
-
options
|
8
|
+
describe "command line options" do
|
9
|
+
it "should destroy the default options with the commandline options" do
|
10
|
+
ARGV << ["-k", "testappkeypair"]
|
11
|
+
ARGV.should_receive(:dup).and_return ARGV
|
12
|
+
PoolParty.options.keypair.should == "testappkeypair"
|
13
|
+
end
|
10
14
|
end
|
11
15
|
it "should have the root_dir defined" do
|
12
16
|
PoolParty.root_dir.should_not be_nil
|
@@ -29,10 +33,17 @@ describe "Application" do
|
|
29
33
|
Application.stub!(:environment).and_return("production")
|
30
34
|
Application.production?.should == true
|
31
35
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
describe "keypair" do
|
37
|
+
before(:each) do
|
38
|
+
Application.stub!(:ec2_dir).and_return("~/.ec2")
|
39
|
+
Application.stub!(:keypair).and_return("poolparty")
|
40
|
+
end
|
41
|
+
it "should be able to say it's keypair path is in the $HOME/ directory" do
|
42
|
+
Application.keypair_path.should == "~/.ec2/id_rsa-poolparty"
|
43
|
+
end
|
44
|
+
it "should be able to say the keypair is of the structure id_rsa-keyname" do
|
45
|
+
Application.keypair_name.should == "id_rsa-poolparty"
|
46
|
+
end
|
36
47
|
end
|
37
48
|
it "should be able to show the version of the gem" do
|
38
49
|
Application.version.should_not be_nil
|
@@ -46,8 +57,16 @@ describe "Application" do
|
|
46
57
|
Application.options = nil
|
47
58
|
Application.stub!(:open).with("http://169.254.169.254/latest/user-data").and_return(@str)
|
48
59
|
@str.stub!(:read).and_return ":access_key: 3.14159\n:secret_access_key: pi"
|
49
|
-
Application.default_options.stub!(:merge!).with({})
|
50
|
-
Application.default_options.stub!(:merge!).with({:access_key => 3.14159, :secret_access_key => "pi"})
|
60
|
+
# Application.default_options.stub!(:merge!).with({})
|
61
|
+
# Application.default_options.stub!(:merge!).with({:access_key => 3.14159, :secret_access_key => "pi"})
|
62
|
+
end
|
63
|
+
describe "added data keypair_path" do
|
64
|
+
before(:each) do
|
65
|
+
@str.stub!(:read).and_return ":access_key: 3.14159\n:secret_access_key: pi\n:keypair_path: hopscotch"
|
66
|
+
end
|
67
|
+
it "should use the options keypair_path if it exists" do
|
68
|
+
Application.keypair_path.should == "hopscotch"
|
69
|
+
end
|
51
70
|
end
|
52
71
|
it "should try to load the user data into a yaml hash" do
|
53
72
|
YAML.should_receive(:load).with(":access_key: 3.14159\n:secret_access_key: pi")
|
@@ -73,6 +92,20 @@ describe "Application" do
|
|
73
92
|
YAML.should_receive(:load).at_least(1).and_return({:config_file => "config/sample-config.yml"})
|
74
93
|
Application.make_options(:config_file => "config/sample-config.yml")
|
75
94
|
end
|
95
|
+
describe "config file" do
|
96
|
+
before(:each) do
|
97
|
+
@str = ":access_key: 3.14159\n:secret_access_key: pi"
|
98
|
+
Application.options = nil
|
99
|
+
@str.stub!(:read).and_return ":access_key: 3.14159\n:secret_access_key: pi"
|
100
|
+
Application.make_options
|
101
|
+
end
|
102
|
+
it "should read the config file and use the options in the config file if it exists" do
|
103
|
+
Application.access_key.should == 3.14159
|
104
|
+
end
|
105
|
+
it "should set the secret_access_key if the config file exists" do
|
106
|
+
Application.secret_access_key.should == "pi"
|
107
|
+
end
|
108
|
+
end
|
76
109
|
it "should not read the config file if it is not passed and doesn't exist" do
|
77
110
|
File.stub!(:file?).and_return false
|
78
111
|
YAML.should_not_receive(:load).with("config/config.yml")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe "Hash" do
|
4
4
|
it "should preserve the contents of the original hash when safe_merge'ing" do
|
@@ -14,11 +14,13 @@ describe "Hash" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
describe "String" do
|
17
|
-
|
18
|
-
str =<<-EOS
|
17
|
+
before(:each) do
|
18
|
+
@str =<<-EOS
|
19
19
|
echo 'hi'
|
20
20
|
puts 'hi'
|
21
21
|
EOS
|
22
|
-
|
22
|
+
end
|
23
|
+
it "should be able to convert a big string with \n to a runnable string" do
|
24
|
+
@str.runnable.should == "echo 'hi' && puts 'hi'"
|
23
25
|
end
|
24
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
2
|
-
require File.dirname(__FILE__) + "
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../helpers/ec2_mock"
|
3
3
|
|
4
4
|
class EC2Test
|
5
5
|
include Ec2Wrapper
|
@@ -14,7 +14,7 @@ class EC2Test
|
|
14
14
|
@resp3 = EC2::Response.parse(:xml => read_file("remote_desc_response"))
|
15
15
|
end
|
16
16
|
def read_file(name)
|
17
|
-
open("#{File.dirname(__FILE__)}
|
17
|
+
open("#{File.dirname(__FILE__)}/../files/#{name}").read
|
18
18
|
end
|
19
19
|
end
|
20
20
|
describe "EC2ResponseObject" do
|