poolparty 0.0.4 → 0.2.6
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/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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
|
|
3
|
+
include PoolParty::Resources
|
|
4
|
+
|
|
5
|
+
describe "SshKey" do
|
|
6
|
+
describe "instances" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
reset_resources!
|
|
9
|
+
end
|
|
10
|
+
it "should turn the one hash instance into a string" do
|
|
11
|
+
@key = sshkey({:name => "rock"})
|
|
12
|
+
@key.to_string.should =~ /"rock":\n/
|
|
13
|
+
end
|
|
14
|
+
it "should turn the two hash instance into a string" do
|
|
15
|
+
@key = sshkey do
|
|
16
|
+
name "poolparty_key"
|
|
17
|
+
end
|
|
18
|
+
@key.to_string.should =~ /"poolparty_key":/
|
|
19
|
+
end
|
|
20
|
+
describe "sizes" do
|
|
21
|
+
before(:each) do
|
|
22
|
+
sshkey({:name => "rock"})
|
|
23
|
+
sshkey({:name => "dos"})
|
|
24
|
+
sshkey({:name => "equis"})
|
|
25
|
+
end
|
|
26
|
+
it "should contain two keyfiles if two are specified" do
|
|
27
|
+
resource(:sshkey).size.should == 3
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
describe "file" do
|
|
31
|
+
before(:each) do
|
|
32
|
+
reset_resources!
|
|
33
|
+
@sshkey = PoolParty::Resources::Sshkey.new
|
|
34
|
+
@string = "ALONGSTRINGOFDIGITS"
|
|
35
|
+
@file = File.join(File.dirname(__FILE__), "..", "test_plugins", "sshkey_test")
|
|
36
|
+
@string.stub!(:read).and_return @string
|
|
37
|
+
end
|
|
38
|
+
it "should read the file when sent keyfile=" do
|
|
39
|
+
@sshkey.should_receive(:open).and_return @string
|
|
40
|
+
@sshkey.keyfile = @file
|
|
41
|
+
end
|
|
42
|
+
it "should set the keyfile as the contents of the file" do
|
|
43
|
+
@sshkey.keyfile = @file
|
|
44
|
+
@sshkey.keyfile.should =~ /THIS IS A TEST/
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
|
|
3
|
+
include PoolParty::Resources
|
|
4
|
+
|
|
5
|
+
describe "Variable" do
|
|
6
|
+
before(:each) do
|
|
7
|
+
reset!
|
|
8
|
+
@variable = variable(:name => "name", :value => "ari Lerner")
|
|
9
|
+
end
|
|
10
|
+
it "should have a package" do
|
|
11
|
+
resource(:variable).should_not be_empty
|
|
12
|
+
end
|
|
13
|
+
it "should have the 'name' variable set as a variable" do
|
|
14
|
+
@variable.to_string.should =~ /\$name = 'ari Lerner'/
|
|
15
|
+
end
|
|
16
|
+
it "should be able to set the variable as an array if passed an array" do
|
|
17
|
+
v = variable(:name => "girlfriends", :value => %w(Rachel Erica Michelle))
|
|
18
|
+
v.to_string.should == "$girlfriends = [ 'Rachel', 'Erica', 'Michelle' ]"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Script" do
|
|
4
|
+
it "should have inflate as a class method" do
|
|
5
|
+
Script.respond_to?(:inflate).should == true
|
|
6
|
+
end
|
|
7
|
+
it "should have inflate_file as an instance method" do
|
|
8
|
+
Script.respond_to?(:inflate_file).should == true
|
|
9
|
+
end
|
|
10
|
+
it "should have inflate as an instance method" do
|
|
11
|
+
Script.new.respond_to?(:inflate).should == true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "with a script" do
|
|
15
|
+
before(:each) do
|
|
16
|
+
@script = 'script'
|
|
17
|
+
@filename = 'filename'
|
|
18
|
+
|
|
19
|
+
@pool = Script.new
|
|
20
|
+
Script.stub!(:new).and_return(@pool)
|
|
21
|
+
@pool.stub!(:inflate).and_return true
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should create a new Script when calling on the class method" do
|
|
25
|
+
Script.should_receive(:new).and_return @pool
|
|
26
|
+
end
|
|
27
|
+
it "should instance eval the script" do
|
|
28
|
+
@pool.should_receive(:instance_eval).with(@script, @filename).and_return true
|
|
29
|
+
end
|
|
30
|
+
it "should call inflate on itself" do
|
|
31
|
+
@pool.should_receive(:inflate).and_return true
|
|
32
|
+
end
|
|
33
|
+
after do
|
|
34
|
+
Script.inflate(@script, @filename)
|
|
35
|
+
end
|
|
36
|
+
describe "save!" do
|
|
37
|
+
before(:each) do
|
|
38
|
+
pool :appdotcom do
|
|
39
|
+
keypair "snoodle"
|
|
40
|
+
cloud :app do
|
|
41
|
+
has_file :name => "/etc/httpd/httpd.conf"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
@saved = Script.save!(false)
|
|
45
|
+
end
|
|
46
|
+
it "should save the keypair" do
|
|
47
|
+
@saved.should =~ /keypair "snoodle"/
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class WebServers
|
|
2
|
+
plugin :apache do
|
|
3
|
+
|
|
4
|
+
attr_accessor :php
|
|
5
|
+
|
|
6
|
+
def enable
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def enable_php
|
|
10
|
+
@php = true
|
|
11
|
+
php
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def php
|
|
15
|
+
@php
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def site(name=:domain1, opts={})
|
|
19
|
+
virtual_host name, opts
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def virtual_host(name, opts={})
|
|
23
|
+
opts = {
|
|
24
|
+
:document_root => opts[:document_root] || "/www/#{name}/"
|
|
25
|
+
}
|
|
26
|
+
call_function "virtual_host()"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
custom_function <<-EOE
|
|
30
|
+
define virtual_host($docroot, $ip, $order = 500, $ensure = "enabled") {
|
|
31
|
+
$file = "/etc/sites-available/$name.conf"
|
|
32
|
+
file { $file:
|
|
33
|
+
content => template("virtual_host.erb"),
|
|
34
|
+
notify => Service[apache]
|
|
35
|
+
}
|
|
36
|
+
file { "/etc/sites-enabled/$order-$name.conf":
|
|
37
|
+
ensure => $ensure ? {
|
|
38
|
+
enabled => $file,
|
|
39
|
+
disabled => absent
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
EOE
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "PoolParty" do
|
|
4
|
+
after(:all) do
|
|
5
|
+
# FileUtils.rm_r(Base.storage_directory) rescue ""
|
|
6
|
+
end
|
|
7
|
+
it "should have the method copy_file_to_storage_directory on the PoolParty" do
|
|
8
|
+
PoolParty.respond_to?(:copy_file_to_storage_directory).should == true
|
|
9
|
+
end
|
|
10
|
+
it "should copy the file given with File" do
|
|
11
|
+
FileUtils.should_receive(:cp).with("haymaker", Base.storage_directory + "/haymaker").once
|
|
12
|
+
PoolParty.copy_file_to_storage_directory("haymaker")
|
|
13
|
+
end
|
|
14
|
+
describe "writing file to storage_directory" do
|
|
15
|
+
before(:each) do
|
|
16
|
+
@path = "#{Base.storage_directory}/happydayz"
|
|
17
|
+
end
|
|
18
|
+
it "should have the method write_to_file_in_storage_directory" do
|
|
19
|
+
PoolParty.respond_to?(:write_to_file_in_storage_directory).should == true
|
|
20
|
+
end
|
|
21
|
+
it "should receive File.new with the name of the file" do
|
|
22
|
+
File.should_receive(:open).with(@path, "w+").once.and_return true
|
|
23
|
+
PoolParty.write_to_file_in_storage_directory("/usr/bin/happydayz", "write this text")
|
|
24
|
+
end
|
|
25
|
+
it "should write the contents of the file to the file" do
|
|
26
|
+
PoolParty.write_to_file_in_storage_directory("/usr/bin/happydayz", "write this text")
|
|
27
|
+
File.open(@path).read.should == "write this text"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
it "should have a logger" do
|
|
31
|
+
PoolParty.logger.should_not be_nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
|
2
|
+
require 'poolparty'
|
|
3
|
+
|
|
4
|
+
%w(test/spec).each do |library|
|
|
5
|
+
begin
|
|
6
|
+
require library
|
|
7
|
+
rescue
|
|
8
|
+
STDERR.puts "== Cannot run test without #{library}"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Dir["#{File.dirname(__FILE__)}/helpers/**"].each {|a| require a}
|
|
13
|
+
|
|
14
|
+
include PoolParty
|
|
15
|
+
extend PoolParty
|
|
16
|
+
|
|
17
|
+
Base.environment = "test"
|
|
18
|
+
Base.verbose = false
|
|
19
|
+
|
|
20
|
+
def stub_option_load
|
|
21
|
+
@str=<<-EOS
|
|
22
|
+
:access_key:
|
|
23
|
+
3.14159
|
|
24
|
+
:secret_access_key:
|
|
25
|
+
"pi"
|
|
26
|
+
EOS
|
|
27
|
+
@sio = StringIO.new
|
|
28
|
+
StringIO.stub!(:new).and_return @sio
|
|
29
|
+
Base.stub!(:open).with("http://169.254.169.254/latest/user-data").and_return @sio
|
|
30
|
+
@sio.stub!(:read).and_return @str
|
|
31
|
+
Base.reset!
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def wait_launch(time=5)
|
|
35
|
+
pid = fork {yield}
|
|
36
|
+
wait time
|
|
37
|
+
Process.kill("INT", pid)
|
|
38
|
+
Process.wait(pid, 0)
|
|
39
|
+
end
|
|
40
|
+
def reset_all!
|
|
41
|
+
end
|
|
42
|
+
def read_file(path)
|
|
43
|
+
require "open-uri"
|
|
44
|
+
open(path).read
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def stub_list_from_local_for(o)
|
|
48
|
+
@list =<<-EOS
|
|
49
|
+
master 192.168.0.1
|
|
50
|
+
node1 192.168.0.2
|
|
51
|
+
EOS
|
|
52
|
+
@file = "filename"
|
|
53
|
+
@file.stub!(:read).and_return @list
|
|
54
|
+
o.stub!(:get_working_listing_file).and_return @file
|
|
55
|
+
o.stub!(:open).and_return @file
|
|
56
|
+
|
|
57
|
+
@ris = @list.split(/\n/).map {|line| PoolParty::Remote::RemoteInstance.new(line) }
|
|
58
|
+
end
|
|
59
|
+
def stub_remoter_for(o)
|
|
60
|
+
o.stub!(:ec2).and_return EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "even more not a key")
|
|
61
|
+
end
|
|
62
|
+
def stub_list_from_remote_for(o, launch_stub=true)
|
|
63
|
+
stub_remoter_for(o)
|
|
64
|
+
@sample_instances_list = [{:ip => "127.0.0.1", :name => "master"}, {:ip => "127.0.0.2", :name => "node1"}]
|
|
65
|
+
@ris = @sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h) }
|
|
66
|
+
o.stub!(:access_key).and_return "NOT A KEY"
|
|
67
|
+
o.stub!(:secret_access_key).and_return "NOT A SECRET"
|
|
68
|
+
# o.stub!(:list_from_remote).and_return ris
|
|
69
|
+
# o.stub!(:remote_instances_list).once.and_return ris
|
|
70
|
+
# o.stub!(:master).and_return @ris[0]
|
|
71
|
+
o.stub!(:launch_new_instance!).and_return true if launch_stub
|
|
72
|
+
stub_list_of_instances_for(o)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def stub_list_of_instances_for(o)
|
|
76
|
+
# o.stub!(:list_of_running_instances).once.and_return running_remote_instances
|
|
77
|
+
o.stub!(:keypair).and_return "fake_keypair"
|
|
78
|
+
o.stub!(:describe_instances).and_return response_list_of_instances
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def response_list_of_instances(arr=[])
|
|
82
|
+
unless @response_list_of_instances
|
|
83
|
+
@a1 = stub_instance(1);
|
|
84
|
+
@a1[:name] = "master"
|
|
85
|
+
@a2 = stub_instance(1); @a3 = stub_instance(2, "terminated"); @a4 = stub_instance(3, "pending")
|
|
86
|
+
@b1 = stub_instance(4, "shutting down", "blist"); @c1 = stub_instance(5, "pending", "clist")
|
|
87
|
+
@response_list_of_instances = [@a1, @a2, @a3, @a4, @b1, @c1]
|
|
88
|
+
end
|
|
89
|
+
@response_list_of_instances
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def running_remote_instances
|
|
93
|
+
response_list_of_instances.select {|a| a[:status] =~ /running/ }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def reset_response!
|
|
97
|
+
@ris = nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def add_stub_instance_to(o, num, status="running")
|
|
101
|
+
reset_response!
|
|
102
|
+
response_list_of_instances << stub_instance(num, status)
|
|
103
|
+
stub_list_of_instances_for o
|
|
104
|
+
end
|
|
105
|
+
def ris
|
|
106
|
+
@ris ||= response_list_of_instances.collect {|h| PoolParty::Remote::RemoteInstance.new(h) }
|
|
107
|
+
end
|
|
108
|
+
def remove_stub_instance_from(o, num)
|
|
109
|
+
reset_response!
|
|
110
|
+
response_list_of_instances.reject! {|r| r if r[:name] == "node#{num}" }
|
|
111
|
+
# o.stub!(:remote_instances_list).once.and_return ris
|
|
112
|
+
end
|
|
113
|
+
def stub_instance(num=1, status="running", keypair="fake_keypair")
|
|
114
|
+
{:name => "node#{num}", :ip => "192.168.0.#{num}", :status => "#{status}", :launching_time => num.minutes.ago, :keypair => "#{keypair}"}
|
|
115
|
+
end
|
|
116
|
+
def drop_pending_instances_for(o)
|
|
117
|
+
puts "hi"
|
|
118
|
+
o.list_of_pending_instances.stub!(:size).and_return 0
|
|
119
|
+
1
|
|
120
|
+
end
|
data/tasks/cloud.rake
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Cloud tasks
|
|
2
|
+
namespace(:cloud) do
|
|
3
|
+
# Setup
|
|
4
|
+
task :init do
|
|
5
|
+
setup_application
|
|
6
|
+
raise Exception.new("You must specify your access_key and secret_access_key") unless Base.access_key && Base.secret_access_key
|
|
7
|
+
end
|
|
8
|
+
# Install the stack on all of the nodes
|
|
9
|
+
desc "Prepare all servers"
|
|
10
|
+
task :prepare => :init do
|
|
11
|
+
PoolParty::Master.new.nodes.each do |node|
|
|
12
|
+
node.install
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
# Start the cloud
|
|
16
|
+
desc "Start the cloud"
|
|
17
|
+
task :start => :init do
|
|
18
|
+
PoolParty::Master.new.start_cloud!
|
|
19
|
+
end
|
|
20
|
+
# Reload the cloud with the new updated data
|
|
21
|
+
desc "Reload all instances with updated data"
|
|
22
|
+
task :reload => :init do
|
|
23
|
+
PoolParty::Master.new.nodes.each do |node|
|
|
24
|
+
node.configure
|
|
25
|
+
node.restart_with_monit
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
# List the cloud
|
|
29
|
+
desc "List cloud"
|
|
30
|
+
task :list => :init do
|
|
31
|
+
puts PoolParty::Master.new.list
|
|
32
|
+
end
|
|
33
|
+
# Shutdown the cloud
|
|
34
|
+
desc "Shutdown the entire cloud"
|
|
35
|
+
task :shutdown => :init do
|
|
36
|
+
PoolParty::Master.new.request_termination_of_all_instances
|
|
37
|
+
end
|
|
38
|
+
# Watch the cloud and scale it if necessary
|
|
39
|
+
desc "Watch the cloud and maintain it"
|
|
40
|
+
task :scale => :init do
|
|
41
|
+
begin
|
|
42
|
+
PoolParty::Master.new.scale_cloud!
|
|
43
|
+
rescue Exception => e
|
|
44
|
+
puts "There was an error scaling the cloud: #{e}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
# Maintain the cloud in a background process
|
|
49
|
+
desc "Maintain the cloud (run on the master)"
|
|
50
|
+
task :maintain => :init do
|
|
51
|
+
begin
|
|
52
|
+
PoolParty::Master.new.start_monitor!
|
|
53
|
+
rescue Exception => e
|
|
54
|
+
puts "There was an error starting the monitor: #{e}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
desc 'Release the website and new gem version'
|
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
|
3
|
+
puts "Remember to create SVN tag:"
|
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
|
6
|
+
puts "Suggested comment:"
|
|
7
|
+
puts "Tagging release #{CHANGES}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
|
12
|
+
|
|
13
|
+
task :check_version do
|
|
14
|
+
unless ENV['VERSION']
|
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
|
16
|
+
exit
|
|
17
|
+
end
|
|
18
|
+
unless ENV['VERSION'] == VERS
|
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
|
20
|
+
exit
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
namespace :manifest do
|
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
|
31
|
+
task :refresh do
|
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
namespace(:dev) do
|
|
2
|
+
task :initialize do
|
|
3
|
+
setup_application
|
|
4
|
+
run "mkdir ~/.ec2 >/dev/null 2>/dev/null" unless File.directory?("~/.ec2")
|
|
5
|
+
end
|
|
6
|
+
# Setup a basic development environment for the user
|
|
7
|
+
desc "Setup development environment specify the config_file"
|
|
8
|
+
task :setup => [:initialize, :setup_keypair] do
|
|
9
|
+
certloc = "#{Base.ec2_dir}/#{Base.keypair}/cert-*.pem 2>/dev/null"
|
|
10
|
+
pkloc = "#{Base.ec2_dir}/#{Base.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
|
|
20
|
+
keyfilename = ".#{Base.keypair}_pool_keys"
|
|
21
|
+
run <<-EOR
|
|
22
|
+
echo 'export AWS_ACCESS_KEY=\"#{Base.access_key}\"' > $HOME/#{keyfilename}
|
|
23
|
+
echo 'export AWS_SECRET_ACCESS=\"#{Base.secret_access_key}\"' >> $HOME/#{keyfilename}
|
|
24
|
+
echo 'export EC2_HOME=\"#{Base.ec2_dir}\"' >> $HOME/#{keyfilename}
|
|
25
|
+
echo 'export KEYPAIR_NAME=\"#{Base.keypair}\"' >> $HOME/#{keyfilename}
|
|
26
|
+
echo 'export EC2_PRIVATE_KEY=`ls ~/.ec2/#{Base.keypair}/pk-*.pem`;' >> $HOME/#{keyfilename}
|
|
27
|
+
echo 'export EC2_CERT=`ls ~/.ec2/#{Base.keypair}/cert-*.pem`;' >> $HOME/#{keyfilename}
|
|
28
|
+
EOR
|
|
29
|
+
puts <<-EOM
|
|
30
|
+
To work on this cloud, source the file like:
|
|
31
|
+
|
|
32
|
+
source $HOME/#{keyfilename}
|
|
33
|
+
|
|
34
|
+
EOM
|
|
35
|
+
end
|
|
36
|
+
desc "Generate a new keypair"
|
|
37
|
+
task :setup_keypair => [:initialize] do
|
|
38
|
+
Base.keypair ||= "#{File.basename(Dir.pwd)}"
|
|
39
|
+
run "ec2-delete-keypair #{Base.keypair}" if File.file?(Base.keypair_path)
|
|
40
|
+
puts "-- setting up keypair named #{Base.keypair} in #{Base.keypair_path}"
|
|
41
|
+
run <<-EOR
|
|
42
|
+
chmod 600 #{Base.keypair_path} 2>/dev/null
|
|
43
|
+
mkdir ~/.ec2/#{Base.keypair} 2>/dev/null
|
|
44
|
+
ec2-add-keypair #{Base.keypair} > #{Base.keypair_path}
|
|
45
|
+
EOR
|
|
46
|
+
end
|
|
47
|
+
desc "Setup pem keys"
|
|
48
|
+
task :setup_pemkeys => [:initialize] do
|
|
49
|
+
puts "Setting up stubbed pem keys in ~/.ec2/#{Base.keypair}"
|
|
50
|
+
run <<-EOR
|
|
51
|
+
mkdir -p ~/.ec2/#{Base.keypair} 2>/dev/null
|
|
52
|
+
echo 'UPDATE ME' > #{Base.ec2_dir}/#{Base.keypair}/cert-UPDATEME.pem
|
|
53
|
+
echo 'UPDATE ME' > #{Base.ec2_dir}/#{Base.keypair}/pk-UPDATEME.pem
|
|
54
|
+
EOR
|
|
55
|
+
puts "Don't forget to replace your ~/.ec2/#{Base.keypair}/*.pem keys with the real amazon keys"
|
|
56
|
+
end
|
|
57
|
+
desc "initialize setup"
|
|
58
|
+
task :init => [:setup_pemkeys]
|
|
59
|
+
|
|
60
|
+
desc "Just an argv test"
|
|
61
|
+
task :test => :initialize do
|
|
62
|
+
puts "---- Testing ----"
|
|
63
|
+
puts PoolParty.options(ARGV.dup)
|
|
64
|
+
puts "Using keypair at: #{Base.keypair_path}"
|
|
65
|
+
end
|
|
66
|
+
desc "Installation listing"
|
|
67
|
+
task :list_install => :initialize do
|
|
68
|
+
puts "-- packages to install --"
|
|
69
|
+
Provider.install_PoolParty(true)
|
|
70
|
+
end
|
|
71
|
+
desc "Authorize base ports for application"
|
|
72
|
+
task :authorize_ports => :initialize do
|
|
73
|
+
run <<-EOR
|
|
74
|
+
ec2-authorize -p 22 default
|
|
75
|
+
ec2-authorize -p 80 default
|
|
76
|
+
EOR
|
|
77
|
+
end
|
|
78
|
+
end
|