poolparty 0.0.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +25 -0
- data/License.txt +20 -0
- data/Manifest.txt +203 -0
- data/PostInstall.txt +18 -0
- data/README.txt +21 -82
- data/Rakefile +25 -18
- data/bin/cloud +31 -0
- data/bin/cloud-add-keypair +23 -0
- data/bin/cloud-configure +31 -0
- data/bin/cloud-contract +27 -0
- data/bin/cloud-expand +27 -0
- data/bin/cloud-list +32 -0
- data/bin/cloud-maintain +36 -0
- data/bin/cloud-osxcopy +22 -0
- data/bin/cloud-provision +31 -0
- data/bin/cloud-refresh +26 -0
- data/bin/cloud-ssh +18 -0
- data/bin/cloud-start +32 -0
- data/bin/cloud-terminate +23 -0
- data/bin/pool +25 -27
- data/bin/pool-console +12 -0
- data/bin/pool-describe +9 -0
- data/bin/pool-list +28 -0
- data/bin/pool-provision +34 -0
- data/bin/pool-spec +17 -0
- data/bin/pool-start +32 -0
- data/bin/pool-start-monitor +1 -0
- data/config/hoe.rb +115 -0
- data/config/requirements.rb +15 -0
- data/examples/basic.rb +20 -0
- data/examples/plugin_without_plugin_directory.rb +13 -0
- data/examples/poolparty.rb +12 -0
- data/examples/with_apache_plugin.rb +22 -0
- data/generators/poolspec/USAGE +5 -0
- data/generators/poolspec/poolspec_generator.rb +65 -0
- data/generators/poolspec/templates/pool_spec_template.erb +9 -0
- data/lib/erlang/eb_server.erl +27 -0
- data/lib/poolparty.rb +56 -0
- data/lib/poolparty/base_packages/haproxy.rb +42 -0
- data/lib/poolparty/base_packages/heartbeat.rb +45 -0
- data/lib/poolparty/base_packages/poolparty.rb +36 -0
- data/lib/poolparty/base_packages/ruby.rb +43 -0
- data/lib/poolparty/core/array.rb +24 -0
- data/lib/{core → poolparty/core}/exception.rb +0 -0
- data/lib/poolparty/core/float.rb +13 -0
- data/lib/poolparty/core/hash.rb +29 -0
- data/lib/poolparty/core/kernel.rb +37 -0
- data/lib/{core → poolparty/core}/module.rb +18 -0
- data/lib/poolparty/core/my_open_struct.rb +18 -0
- data/lib/poolparty/core/object.rb +54 -0
- data/lib/poolparty/core/proc.rb +7 -0
- data/lib/poolparty/core/string.rb +72 -0
- data/lib/poolparty/core/symbol.rb +8 -0
- data/lib/{core → poolparty/core}/time.rb +15 -0
- data/lib/poolparty/exceptions/RemoteException.rb +12 -0
- data/lib/poolparty/exceptions/ResourceException.rb +7 -0
- data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
- data/lib/poolparty/exceptions/SpecException.rb +7 -0
- data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
- data/lib/poolparty/helpers/binary.rb +31 -0
- data/lib/poolparty/helpers/console.rb +30 -0
- data/lib/poolparty/helpers/display.rb +34 -0
- data/lib/poolparty/helpers/optioner.rb +64 -0
- data/lib/poolparty/helpers/provisioner_base.rb +250 -0
- data/lib/poolparty/helpers/provisioners/master.rb +136 -0
- data/lib/poolparty/helpers/provisioners/slave.rb +44 -0
- data/lib/poolparty/modules/cloud_resourcer.rb +89 -0
- data/lib/poolparty/modules/configurable.rb +34 -0
- data/lib/poolparty/modules/definable_resource.rb +59 -0
- data/lib/poolparty/modules/file_writer.rb +55 -0
- data/lib/poolparty/modules/method_missing_sugar.rb +53 -0
- data/lib/poolparty/modules/output.rb +13 -0
- data/lib/poolparty/modules/pretty_printer.rb +39 -0
- data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -22
- data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
- data/lib/poolparty/monitors/base_monitor.rb +16 -0
- data/lib/poolparty/net/remote.rb +35 -0
- data/lib/poolparty/net/remote_bases/ec2.rb +148 -0
- data/lib/poolparty/net/remote_instance.rb +69 -0
- data/lib/poolparty/net/remoter.rb +224 -0
- data/lib/poolparty/net/remoter_base.rb +117 -0
- data/lib/poolparty/plugins/gem_package.rb +17 -0
- data/lib/poolparty/plugins/git.rb +41 -0
- data/lib/poolparty/plugins/line.rb +76 -0
- data/lib/poolparty/plugins/svn.rb +48 -0
- data/lib/poolparty/pool/base.rb +75 -0
- data/lib/poolparty/pool/cloud.rb +164 -0
- data/lib/poolparty/pool/custom_resource.rb +61 -0
- data/lib/poolparty/pool/loggable.rb +29 -0
- data/lib/poolparty/pool/plugin.rb +41 -0
- data/lib/poolparty/pool/plugin_model.rb +48 -0
- data/lib/poolparty/pool/pool.rb +55 -0
- data/lib/poolparty/pool/resource.rb +248 -0
- data/lib/poolparty/pool/resources/class_package.rb +64 -0
- data/lib/poolparty/pool/resources/conditional.rb +41 -0
- data/lib/poolparty/pool/resources/cron.rb +14 -0
- data/lib/poolparty/pool/resources/directory.rb +23 -0
- data/lib/poolparty/pool/resources/exec.rb +26 -0
- data/lib/poolparty/pool/resources/file.rb +23 -0
- data/lib/poolparty/pool/resources/gem.rb +14 -0
- data/lib/poolparty/pool/resources/host.rb +14 -0
- data/lib/poolparty/pool/resources/package.rb +14 -0
- data/lib/poolparty/pool/resources/remote_file.rb +22 -0
- data/lib/poolparty/pool/resources/service.rb +21 -0
- data/lib/poolparty/pool/resources/sshkey.rb +19 -0
- data/lib/poolparty/pool/resources/variable.rb +27 -0
- data/lib/poolparty/pool/script.rb +44 -0
- data/lib/poolparty/templates/authkeys +2 -0
- data/{config/monit/nginx.monit.conf → lib/poolparty/templates/cib.xml} +0 -0
- data/lib/poolparty/templates/fileserver.conf +4 -0
- data/lib/poolparty/templates/gem +25 -0
- data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -2
- data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
- data/lib/poolparty/templates/namespaceauth.conf +19 -0
- data/lib/poolparty/templates/puppet.conf +17 -0
- data/lib/poolparty/version.rb +9 -0
- data/lib/poolpartycl.rb +3 -0
- data/poolparty.gemspec +56 -47
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
- data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
- data/spec/poolparty/bin/console_spec.rb +80 -0
- data/spec/poolparty/core/array_spec.rb +26 -0
- data/spec/poolparty/core/float.rb +13 -0
- data/spec/poolparty/core/hash_spec.rb +63 -0
- data/spec/poolparty/core/kernel_spec.rb +24 -0
- data/spec/poolparty/core/module_spec.rb +15 -0
- data/spec/poolparty/core/object_spec.rb +40 -0
- data/spec/poolparty/core/string_spec.rb +152 -0
- data/spec/poolparty/core/time_spec.rb +52 -0
- data/spec/poolparty/helpers/binary_spec.rb +26 -0
- data/spec/poolparty/helpers/display_spec.rb +13 -0
- data/spec/poolparty/helpers/optioner_spec.rb +39 -0
- data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
- data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
- data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
- data/spec/poolparty/modules/configurable_spec.rb +26 -0
- data/spec/poolparty/modules/definable_resource.rb +9 -0
- data/spec/poolparty/modules/file_writer_spec.rb +49 -0
- data/spec/poolparty/modules/s3_string_spec.rb +15 -0
- data/spec/poolparty/modules/tmp/willy/nilly.rb +1 -0
- data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
- data/spec/poolparty/net/remote_instance_spec.rb +70 -0
- data/spec/poolparty/net/remote_spec.rb +286 -0
- data/spec/poolparty/net/remoter_base_spec.rb +80 -0
- data/spec/poolparty/net/remoter_spec.rb +191 -0
- data/spec/poolparty/plugins/git_spec.rb +33 -0
- data/spec/poolparty/plugins/line_spec.rb +16 -0
- data/spec/poolparty/plugins/svn_spec.rb +16 -0
- data/spec/poolparty/pool/base_spec.rb +108 -0
- data/spec/poolparty/pool/cloud_spec.rb +299 -0
- data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
- data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
- data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
- data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
- data/spec/poolparty/pool/example_spec.rb +112 -0
- data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
- data/spec/poolparty/pool/plugin_spec.rb +85 -0
- data/spec/poolparty/pool/pool_spec.rb +83 -0
- data/spec/poolparty/pool/resource_spec.rb +224 -0
- data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
- data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
- data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
- data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
- data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
- data/spec/poolparty/pool/resources/file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
- data/spec/poolparty/pool/resources/host_spec.rb +28 -0
- data/spec/poolparty/pool/resources/package_spec.rb +44 -0
- data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/service_spec.rb +45 -0
- data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
- data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
- data/spec/poolparty/pool/script_spec.rb +51 -0
- data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
- data/{test/test_pool_party.rb → spec/poolparty/pool/test_plugins/virtual_host_template.erb} +0 -0
- data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
- data/spec/poolparty/poolparty_spec.rb +33 -0
- data/spec/poolparty/spec_helper.rb +120 -0
- data/tasks/cloud.rake +57 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/development.rake +78 -0
- data/tasks/ec2.rake +20 -0
- data/tasks/environment.rake +7 -0
- data/tasks/instance.rake +63 -0
- data/tasks/server.rake +42 -0
- data/tasks/spec.rake +17 -0
- data/tasks/website.rake +17 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/test/test_pool_spec_generator.rb +47 -0
- data/test/test_poolparty.rb +11 -0
- data/test_manifest.pp +538 -0
- data/website/index.html +107 -0
- data/website/index.txt +95 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/code.css +29 -0
- data/website/stylesheets/screen.css +147 -0
- data/website/template.html.erb +49 -0
- metadata +282 -101
- data/CHANGELOG +0 -4
- data/Manifest +0 -55
- data/bin/instance +0 -54
- data/config/config.yml +0 -23
- data/config/create_proxy_ami.sh +0 -582
- data/config/heartbeat_authkeys.conf +0 -2
- data/config/monit.conf +0 -8
- data/config/monit/haproxy.monit.conf +0 -7
- data/config/nginx.conf +0 -24
- data/lib/core/array.rb +0 -10
- data/lib/core/kernel.rb +0 -9
- data/lib/core/object.rb +0 -14
- data/lib/modules/callback.rb +0 -55
- data/lib/modules/ec2_wrapper.rb +0 -74
- data/lib/pool_party.rb +0 -69
- data/lib/pool_party/application.rb +0 -133
- data/lib/pool_party/init.rb +0 -4
- data/lib/pool_party/master.rb +0 -189
- data/lib/pool_party/monitors.rb +0 -13
- data/lib/pool_party/monitors/cpu.rb +0 -18
- data/lib/pool_party/monitors/memory.rb +0 -21
- data/lib/pool_party/monitors/web.rb +0 -18
- data/lib/pool_party/optioner.rb +0 -16
- data/lib/pool_party/os.rb +0 -11
- data/lib/pool_party/os/ubuntu.rb +0 -78
- data/lib/pool_party/remote_instance.rb +0 -180
- data/lib/pool_party/remoting.rb +0 -112
- data/lib/pool_party/scheduler.rb +0 -93
- data/lib/pool_party/tasks.rb +0 -220
- data/lib/s3/s3_object_store_folders.rb +0 -44
- data/spec/application_spec.rb +0 -32
- data/spec/callback_spec.rb +0 -65
- data/spec/helpers/ec2_mock.rb +0 -56
- data/spec/helpers/remote_instance_mock.rb +0 -11
- data/spec/kernel_spec.rb +0 -11
- data/spec/master_spec.rb +0 -147
- data/spec/monitor_spec.rb +0 -16
- data/spec/optioner_spec.rb +0 -22
- data/spec/poolparty_spec.rb +0 -8
- data/spec/remote_instance_spec.rb +0 -29
- data/spec/remoting_spec.rb +0 -75
- data/spec/spec_helper.rb +0 -38
- data/spec/string_spec.rb +0 -28
data/lib/pool_party/scheduler.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
module PoolParty
|
2
|
-
extend self
|
3
|
-
# Schedule tasks container
|
4
|
-
class ScheduleTasks
|
5
|
-
attr_reader :tasks
|
6
|
-
include ThreadSafeInstance
|
7
|
-
# Initialize tasks array and run
|
8
|
-
def initialize
|
9
|
-
@tasks = []
|
10
|
-
run
|
11
|
-
end
|
12
|
-
# Synchronize the running threaded tasks
|
13
|
-
def run
|
14
|
-
unless @tasks.empty?
|
15
|
-
self.class.synchronize do
|
16
|
-
@tasks.reject!{|a|
|
17
|
-
begin
|
18
|
-
a.run;a.join
|
19
|
-
rescue Exception => e
|
20
|
-
puts "There was an error in the task: #{e} #{e.backtrace.join("\n")}"
|
21
|
-
end
|
22
|
-
true
|
23
|
-
}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
# Add a task in a new thread
|
28
|
-
def <<(a)
|
29
|
-
@tasks.push( Thread.new {a.call} )
|
30
|
-
end
|
31
|
-
alias_method :push, :<<
|
32
|
-
# In the ThreadSafeInstance
|
33
|
-
make_safe :<<
|
34
|
-
end
|
35
|
-
# Scheduler class
|
36
|
-
module Scheduler
|
37
|
-
attr_reader :tasks
|
38
|
-
# Get the tasks or ScheduleTasks
|
39
|
-
def tasks
|
40
|
-
@tasks ||= ScheduleTasks.new
|
41
|
-
end
|
42
|
-
# Add a task to the new threaded block
|
43
|
-
def add_task(&blk)
|
44
|
-
tasks.push proc{blk.call}
|
45
|
-
end
|
46
|
-
# Grab the polling_time
|
47
|
-
def interval
|
48
|
-
@interval ||= Application.polling_time
|
49
|
-
end
|
50
|
-
# Run the threads
|
51
|
-
def run_threads
|
52
|
-
tasks.run
|
53
|
-
end
|
54
|
-
# Daemonize the process
|
55
|
-
def daemonize
|
56
|
-
puts "Daemonizing..."
|
57
|
-
|
58
|
-
pid = fork do
|
59
|
-
Signal.trap('HUP', 'IGNORE') # Don't die upon logout
|
60
|
-
File.open("/dev/null", "r+") do |devnull|
|
61
|
-
$stdout.reopen(devnull)
|
62
|
-
$stderr.reopen(devnull)
|
63
|
-
$stdin.reopen(devnull) unless @use_stdin
|
64
|
-
end
|
65
|
-
yield if block_given?
|
66
|
-
end
|
67
|
-
Process.detach(pid)
|
68
|
-
end
|
69
|
-
# Run the loop and wait the amount of time between running the tasks
|
70
|
-
# You can send it daemonize => true and it will daemonize
|
71
|
-
def run_thread_loop(opts={})
|
72
|
-
block = lambda {
|
73
|
-
loop do
|
74
|
-
begin
|
75
|
-
yield if block_given?
|
76
|
-
run_threads
|
77
|
-
wait interval
|
78
|
-
reset!
|
79
|
-
rescue Exception => e
|
80
|
-
puts "There was an error in the run_thread_loop: #{e}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
}
|
84
|
-
# Run the tasks
|
85
|
-
opts[:daemonize] ? daemonize(&block) : block.call
|
86
|
-
end
|
87
|
-
# Reset
|
88
|
-
def reset!
|
89
|
-
cached_variables.each {|cached| cached = nil }
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|
data/lib/pool_party/tasks.rb
DELETED
@@ -1,220 +0,0 @@
|
|
1
|
-
module PoolParty
|
2
|
-
module TaskCommands
|
3
|
-
# Run the command on the local system
|
4
|
-
def run(cmd)
|
5
|
-
system(cmd.runnable)
|
6
|
-
end
|
7
|
-
# Basic setup action
|
8
|
-
def setup_application
|
9
|
-
Application.options({:config_file => (ENV["CONFIG_FILE"] || ENV["config"]) })
|
10
|
-
end
|
11
|
-
end
|
12
|
-
class Tasks
|
13
|
-
include TaskCommands
|
14
|
-
# Setup and define all the tasks
|
15
|
-
def initialize
|
16
|
-
yield self if block_given?
|
17
|
-
define_tasks!
|
18
|
-
end
|
19
|
-
# Define the tasks in the rakefile
|
20
|
-
def define_tasks!
|
21
|
-
# Tasks dealing with only an instance
|
22
|
-
namespace(:instance) do
|
23
|
-
# Find the instance we want to deal with
|
24
|
-
# interface can be: num=0, i=0, inst=0, 0
|
25
|
-
# defaults to the master instance (0)
|
26
|
-
task :init do
|
27
|
-
num = (ENV['num'] || ENV["i"] || ENV["inst"] || ARGV.shift || 0).to_i
|
28
|
-
raise Exception.new("Please set the number of the instance (i.e. num=1, i=1, or as an argument)") unless num
|
29
|
-
@node = PoolParty::Master.new.get_node(num)
|
30
|
-
end
|
31
|
-
# Ssh into the node
|
32
|
-
desc "Remotely login to the remote instance"
|
33
|
-
task :ssh => [:init] do
|
34
|
-
@node.ssh
|
35
|
-
end
|
36
|
-
# Send a file to the remote instance
|
37
|
-
# as designated by src='' and dest=''
|
38
|
-
desc "Send a file to the remote instance"
|
39
|
-
task :scp => [:init] do
|
40
|
-
@node.scp ENV['src'], ENV['dest']
|
41
|
-
end
|
42
|
-
# Execute a command on the remote instance as designated
|
43
|
-
# by cmd=''
|
44
|
-
desc "Execute cmd on a remote instance"
|
45
|
-
task :exec => [:init] do
|
46
|
-
cmd = ENV['cmd'] || "ls -l"
|
47
|
-
puts @node.ssh(cmd.runnable)
|
48
|
-
end
|
49
|
-
# Restart all the services monitored by monit
|
50
|
-
desc "Restart all the services"
|
51
|
-
task :reload => [:init] do
|
52
|
-
@node.restart_with_monit
|
53
|
-
end
|
54
|
-
# Start all the services monitored by monit
|
55
|
-
desc "Start all services"
|
56
|
-
task :load => [:init] do
|
57
|
-
@node.start_with_monit
|
58
|
-
end
|
59
|
-
# Stop the services monitored by monit
|
60
|
-
desc "Stop all services"
|
61
|
-
task :stop => [:init] do
|
62
|
-
@node.stop_with_monit
|
63
|
-
end
|
64
|
-
# Install the required services on this node
|
65
|
-
desc "Install stack on this node"
|
66
|
-
task :install => :init do
|
67
|
-
@node.install_stack
|
68
|
-
end
|
69
|
-
# Turnoff this instance
|
70
|
-
desc "Teardown instance"
|
71
|
-
task :shutdown => :init do
|
72
|
-
`ec2-terminate-instances #{@node.instance_id}`
|
73
|
-
end
|
74
|
-
# Configure this node and start the services
|
75
|
-
desc "Configure the stack on this node"
|
76
|
-
task :configure => :init do
|
77
|
-
@node.configure
|
78
|
-
@node.restart_with_monit
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
namespace(:dev) do
|
83
|
-
task :init do
|
84
|
-
setup_application
|
85
|
-
end
|
86
|
-
# Setup a basic development environment for the user
|
87
|
-
desc "Setup development environment specify the config_file"
|
88
|
-
task :setup => :init do
|
89
|
-
keyfilename = ".#{Application.keypair}_pool_keys"
|
90
|
-
run <<-EOR
|
91
|
-
echo 'export ACCESS_KEY=\"#{Application.access_key}\"' > $HOME/#{keyfilename}
|
92
|
-
echo 'export SECRET_ACCESS_KEY=\"#{Application.secret_access_key}\"' >> $HOME/#{keyfilename}
|
93
|
-
echo 'export EC2_HOME=\"#{Application.ec2_dir}\"' >> $HOME/#{keyfilename}
|
94
|
-
echo 'export KEYPAIR_NAME=\"#{Application.keypair}\"' >> $HOME/#{keyfilename}
|
95
|
-
echo 'export CONFIG_FILE=\"#{Application.config_file}\"' >> $HOME/#{keyfilename}
|
96
|
-
EOR
|
97
|
-
end
|
98
|
-
end
|
99
|
-
# Cloud tasks
|
100
|
-
namespace(:cloud) do
|
101
|
-
# Setup
|
102
|
-
task :init do
|
103
|
-
setup_application
|
104
|
-
raise Exception.new("You must specify your access_key and secret_access_key") unless Application.access_key && Application.secret_access_key
|
105
|
-
end
|
106
|
-
# Install the stack on all of the nodes
|
107
|
-
desc "Prepare all servers"
|
108
|
-
task :prepare => :init do
|
109
|
-
PoolParty::Master.new.nodes.each do |node|
|
110
|
-
node.install_stack
|
111
|
-
end
|
112
|
-
end
|
113
|
-
# Start the cloud
|
114
|
-
desc "Start the cloud"
|
115
|
-
task :start => :init do
|
116
|
-
PoolParty::Master.new.start_cloud!
|
117
|
-
end
|
118
|
-
# Reload the cloud with the new updated data
|
119
|
-
desc "Reload all instances with updated data"
|
120
|
-
task :reload => :init do
|
121
|
-
PoolParty::Master.new.nodes.each do |node|
|
122
|
-
node.configure
|
123
|
-
node.restart_with_monit
|
124
|
-
end
|
125
|
-
end
|
126
|
-
# List the cloud
|
127
|
-
desc "List cloud"
|
128
|
-
task :list => :init do
|
129
|
-
PoolParty::Master.new.list
|
130
|
-
end
|
131
|
-
# Shutdown the cloud
|
132
|
-
desc "Shutdown the entire cloud"
|
133
|
-
task :shutdown => :init do
|
134
|
-
PoolParty::Master.new.request_termination_of_all_instances
|
135
|
-
end
|
136
|
-
# Maintain the cloud in a background process
|
137
|
-
desc "Maintain the cloud (run on the master)"
|
138
|
-
task :maintain => :init do
|
139
|
-
begin
|
140
|
-
PoolParty::Master.new.start_monitor!
|
141
|
-
rescue Exception => e
|
142
|
-
puts "There was an error starting the monitor: #{e}"
|
143
|
-
end
|
144
|
-
end
|
145
|
-
# Deploy task.
|
146
|
-
# TODO: Find a beautiful way of updating the user-defined configuration
|
147
|
-
# data
|
148
|
-
desc "Deploy web application from production git repos specified in config file"
|
149
|
-
task :deploy => :init do
|
150
|
-
puts "Deploying web app on nginx"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# Nearly antiquated tasks
|
155
|
-
namespace(:ec2) do
|
156
|
-
task :init do
|
157
|
-
Application.options
|
158
|
-
end
|
159
|
-
# Start a new instance in the cloud
|
160
|
-
desc "Add and start an instance to the pool"
|
161
|
-
task :start_new_instance => [:init] do
|
162
|
-
puts PoolParty::Remoting.new.launch_new_instance!
|
163
|
-
end
|
164
|
-
# Stop all the instances via command-line
|
165
|
-
desc "Stop all running instances"
|
166
|
-
task :stop_running_instances => [:init] do
|
167
|
-
Thread.new {`ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2}' | xargs ec2-terminate-instances`}
|
168
|
-
end
|
169
|
-
# Reboot the instances via commandline
|
170
|
-
desc "Restart all running instances"
|
171
|
-
task :restart_running_instances => [:init] do
|
172
|
-
Thread.new {`ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2}' | xargs ec2-reboot-instances`}
|
173
|
-
end
|
174
|
-
end
|
175
|
-
# Tasks to be run on the server
|
176
|
-
namespace(:server) do
|
177
|
-
task :init do
|
178
|
-
PoolParty::Coordinator.init(false)
|
179
|
-
end
|
180
|
-
# bundle, upload and register your bundle on the server
|
181
|
-
desc "Bundle, upload and register your ami"
|
182
|
-
task :all => [:bundle, :upload, :register] do
|
183
|
-
puts "== your ami is ready"
|
184
|
-
end
|
185
|
-
# Cleanup the /mnt directory
|
186
|
-
desc "Clean the /mnt directory"
|
187
|
-
task :clean_mnt do
|
188
|
-
`rm -rf /mnt/image* img*`
|
189
|
-
end
|
190
|
-
# Before we can bundle, we have to make sure we have the cert and pk files
|
191
|
-
desc "Ensure the required bundle files are present in /mnt"
|
192
|
-
task :check_bundle_files do
|
193
|
-
raise Exception.new("You must have a private key in your /mnt directory") unless File.exists?("/mnt/pk-*.pem")
|
194
|
-
raise Exception.new("You must have your access key in your /mnt directory") unless File.exists?("/mnt/cert-*.pem")
|
195
|
-
end
|
196
|
-
# Bundle the image
|
197
|
-
desc "Bundle this image into the /mnt directory"
|
198
|
-
task :bundle => [:clean_mnt, :check_bundle_files] do
|
199
|
-
puts `ec2-bundle-vol -k /mnt/pk-*.pem -u '#{Planner.user_id}' -d /mnt -c /mnt/cert-*.pem -r i386`
|
200
|
-
end
|
201
|
-
# Upload the bundle into the app_name bucket
|
202
|
-
desc "Upload the bundle to your bucket with a unique name: deletes old ami"
|
203
|
-
task :upload => [:init, :delete_bucket] do
|
204
|
-
puts `ec2-upload-bundle -b #{Planner.app_name} -m /mnt/image.manifest.xml -a #{Planner.access_key} -s #{Planner.secret_access_key}`
|
205
|
-
end
|
206
|
-
# Register the bucket with amazon and get back an ami
|
207
|
-
desc "Register the bundle with amazon"
|
208
|
-
task :register do
|
209
|
-
puts `ec2-register -K /mnt/pk-*.pem -C /mnt/cert-*.pem #{Planner.app_name}/image.manifest.xml`
|
210
|
-
end
|
211
|
-
# Delete the bucket
|
212
|
-
desc "Delete the bucket with the bundle under tha app name"
|
213
|
-
task :delete_bucket do
|
214
|
-
Planner.app_name.delete_bucket
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
end
|
220
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
=begin rdoc
|
2
|
-
S3 overloads
|
3
|
-
=end
|
4
|
-
module AWS
|
5
|
-
module S3
|
6
|
-
class S3Object
|
7
|
-
class << self
|
8
|
-
|
9
|
-
alias :original_store :store
|
10
|
-
def store(key, data, bucket = nil, options = {})
|
11
|
-
store_folders(key, bucket, options) if options[:use_virtual_directories]
|
12
|
-
original_store(key, data, bucket, options)
|
13
|
-
end
|
14
|
-
|
15
|
-
def streamed_store(key, filepath, bucket = nil, options = {})
|
16
|
-
store_folders(key, bucket, options) if options[:use_virtual_directories]
|
17
|
-
store(key,File.open(filepath), bucket)
|
18
|
-
end
|
19
|
-
|
20
|
-
def store_directory(directory, bucket, options = {})
|
21
|
-
Dir[File.join(directory, "*")].each do |file|
|
22
|
-
streamed_store("#{File.basename(File.dirname(file))}/#{File.basename(file)}", file, bucket, options.update(:use_virtual_directories => true))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def store_folders(key, bucket = nil, options = {})
|
27
|
-
folders = key.split("/")
|
28
|
-
folders.slice!(0)
|
29
|
-
folders.pop
|
30
|
-
current_folder = "/"
|
31
|
-
folders.each {|folder|
|
32
|
-
current_folder += folder
|
33
|
-
store_folder(current_folder, bucket, options)
|
34
|
-
current_folder += "/"
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
def store_folder(key, bucket = nil, options = {})
|
39
|
-
original_store(key + "_$folder$", "", bucket, options) # store the magic entry that emulates a folder
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/spec/application_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "Application" do
|
4
|
-
before(:each) do
|
5
|
-
end
|
6
|
-
it "should have the root_dir defined" do
|
7
|
-
Application.root_dir.should_not be_nil
|
8
|
-
end
|
9
|
-
it "should be able to call on the haproxy_config_file" do
|
10
|
-
Application.haproxy_config_file.should_not be_nil
|
11
|
-
end
|
12
|
-
it "should be able to find the client_port" do
|
13
|
-
Application.options.should_receive(:client_port).and_return(7788)
|
14
|
-
Application.client_port.should == 7788
|
15
|
-
end
|
16
|
-
it "should always have haproxy in the managed services list" do
|
17
|
-
Application.managed_services =~ /haproxy/
|
18
|
-
end
|
19
|
-
it "should be able to say it is in development mode if it is in dev mode" do
|
20
|
-
Application.stub!(:environment).and_return("development")
|
21
|
-
Application.development?.should == true
|
22
|
-
end
|
23
|
-
it "should be able to say it is in production if it is in production" do
|
24
|
-
Application.stub!(:environment).and_return("production")
|
25
|
-
Application.production?.should == true
|
26
|
-
end
|
27
|
-
it "should be able to say it's keypair path is in the $HOME/ directory" do
|
28
|
-
Application.stub!(:ec2_dir).and_return("~/.ec2")
|
29
|
-
Application.stub!(:keypair).and_return("poolparty")
|
30
|
-
Application.keypair_path.should == "~/.ec2/id_rsa-poolparty"
|
31
|
-
end
|
32
|
-
end
|
data/spec/callback_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
class TestCallbacks
|
4
|
-
include Callbacks
|
5
|
-
attr_reader :str
|
6
|
-
def hello
|
7
|
-
string << "hello "
|
8
|
-
end
|
9
|
-
def world
|
10
|
-
string << "world"
|
11
|
-
end
|
12
|
-
def thanks
|
13
|
-
string << ", thank you"
|
14
|
-
end
|
15
|
-
before :world, :hello
|
16
|
-
after :world, :thanks
|
17
|
-
def pop
|
18
|
-
string << "pop"
|
19
|
-
end
|
20
|
-
def boom
|
21
|
-
string << " goes boom"
|
22
|
-
end
|
23
|
-
after :pop, :boom
|
24
|
-
def string
|
25
|
-
@str ||= String.new
|
26
|
-
end
|
27
|
-
end
|
28
|
-
describe "Callbacks" do
|
29
|
-
before(:each) do
|
30
|
-
@klass = TestCallbacks.new
|
31
|
-
end
|
32
|
-
it "should retain it's class identifier" do
|
33
|
-
@klass.class.should == TestCallbacks
|
34
|
-
end
|
35
|
-
it "should callback the method before the method runs" do
|
36
|
-
@klass.world.should == "hello world, thank you"
|
37
|
-
end
|
38
|
-
it "should callback the method before the method runs" do
|
39
|
-
@klass.pop.should == "pop goes boom"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
class TestMultipleCallbacks
|
43
|
-
include Callbacks
|
44
|
-
attr_reader :str
|
45
|
-
def hi
|
46
|
-
string << "hi, "
|
47
|
-
end
|
48
|
-
def hello
|
49
|
-
string << "hello "
|
50
|
-
end
|
51
|
-
def world
|
52
|
-
string << "world"
|
53
|
-
end
|
54
|
-
def string
|
55
|
-
@str ||= String.new
|
56
|
-
end
|
57
|
-
before :world, :hi
|
58
|
-
before :world, :hello
|
59
|
-
end
|
60
|
-
describe "Multiple callbacks" do
|
61
|
-
before(:each) do
|
62
|
-
@klass = TestMultipleCallbacks.new
|
63
|
-
end
|
64
|
-
it "should be able to have multiple callbacks on the same call"
|
65
|
-
end
|