fairchild-poolparty 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +0 -12
- data/Rakefile +17 -1
- data/VERSION.yml +1 -1
- data/bin/cloud +20 -1
- data/bin/cloud-bootstrap +14 -4
- data/bin/cloud-configure +26 -9
- data/bin/cloud-contract +7 -7
- data/bin/cloud-describe +28 -0
- data/bin/cloud-expand +13 -6
- data/bin/cloud-list +3 -5
- data/bin/cloud-osxcopy +1 -1
- data/bin/cloud-provision +1 -1
- data/bin/cloud-show +6 -5
- data/bin/cloud-ssh +1 -3
- data/bin/cloud-start +8 -6
- data/bin/cloud-terminate +9 -7
- data/bin/server-cloud-elections +29 -18
- data/bin/server-ensure-provisioning +24 -29
- data/bin/server-list-active +10 -5
- data/bin/server-monitor.ru +18 -1
- data/bin/server-update-hosts +3 -3
- data/bin/server-write-new-nodes +1 -1
- data/config/jeweler.rb +12 -3
- data/lib/poolparty/aska/aska.rb +1 -12
- data/lib/poolparty/base_packages/haproxy.rb +26 -18
- data/lib/poolparty/base_packages/poolparty.rb +1 -1
- data/lib/poolparty/capistrano.rb +1 -1
- data/lib/poolparty/core/array.rb +12 -0
- data/lib/poolparty/core/hash.rb +12 -5
- data/lib/poolparty/core/nil.rb +8 -0
- data/lib/poolparty/core/object.rb +15 -5
- data/lib/poolparty/core/string.rb +28 -2
- data/lib/poolparty/dependency_resolver/chef_resolver.rb +106 -79
- data/lib/poolparty/dependency_resolver/dependency_resolver.rb +1 -1
- data/lib/poolparty/dependency_resolver/dependency_resolver_cloud_extensions.rb +5 -4
- data/lib/poolparty/dependency_resolver/puppet_resolver.rb +44 -17
- data/lib/poolparty/helpers/console.rb +1 -1
- data/lib/poolparty/helpers/optioner.rb +9 -2
- data/lib/poolparty/lite.rb +12 -2
- data/lib/poolparty/modules/callbacks.rb +44 -0
- data/lib/poolparty/modules/cloud_dsl.rb +17 -11
- data/lib/poolparty/modules/cloud_resourcer.rb +29 -21
- data/lib/poolparty/modules/definable_resource.rb +1 -1
- data/lib/poolparty/modules/pinger.rb +28 -0
- data/lib/poolparty/modules/resourcing_dsl.rb +7 -3
- data/lib/poolparty/modules/thread_pool.rb +107 -106
- data/lib/poolparty/modules/user_helpers.rb +20 -0
- data/lib/poolparty/monitors/base_monitor.rb +32 -81
- data/lib/poolparty/monitors/monitor_rack.rb +60 -69
- data/lib/poolparty/monitors/monitors/favicon_monitor.rb +12 -0
- data/lib/poolparty/monitors/monitors/load_monitor.rb +9 -15
- data/lib/poolparty/monitors/monitors/memory_monitor.rb +48 -48
- data/lib/poolparty/monitors/monitors/neighborhood_monitor.rb +77 -0
- data/lib/poolparty/monitors/{stats_monitor.rb → monitors/stats_monitor.rb} +29 -24
- data/lib/poolparty/monitors/monitors/time_monitor.rb +15 -0
- data/lib/poolparty/net/messenger.rb +2 -0
- data/lib/poolparty/net/remoter/cloud_control.rb +177 -227
- data/lib/poolparty/net/remoter/connections.rb +10 -18
- data/lib/poolparty/net/remoter/interactive.rb +24 -90
- data/lib/poolparty/net/remoter_base.rb +98 -25
- data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +83 -66
- data/lib/poolparty/net/remoter_bases/vmrun/utilities/vm_disk.rb +12 -0
- data/lib/poolparty/net/remoter_bases/vmrun/utilities/vmx.rb +33 -0
- data/lib/poolparty/net/remoter_bases/vmrun/utilities/vmx_file.rb +117 -0
- data/lib/poolparty/net/remoter_bases/vmrun/vmrun.rb +165 -0
- data/lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb +71 -0
- data/lib/poolparty/{base_packages → plugins}/bind.rb +1 -1
- data/lib/poolparty/plugins/chef.rb +71 -71
- data/lib/poolparty/plugins/chef_deploy.rb +58 -0
- data/lib/poolparty/plugins/{deploydirectory.rb → deploy_directory.rb} +12 -3
- data/lib/poolparty/plugins/dynomite.rb +14 -0
- data/lib/poolparty/plugins/gem_package.rb +37 -0
- data/lib/poolparty/plugins/line_in_file.rb +1 -0
- data/lib/poolparty/plugins/nanite.rb +41 -0
- data/lib/poolparty/{base_packages → plugins}/tokyo_tyrant.rb +1 -1
- data/lib/poolparty/poolparty/cloud.rb +36 -35
- data/lib/poolparty/poolparty/default.rb +2 -11
- data/lib/poolparty/poolparty/key.rb +15 -12
- data/lib/poolparty/poolparty/neighborhoods.rb +54 -21
- data/lib/poolparty/poolparty/plugin.rb +6 -9
- data/lib/poolparty/poolparty/plugin_model.rb +5 -5
- data/lib/poolparty/poolparty/pool.rb +8 -4
- data/lib/poolparty/poolparty/poolparty_base_class.rb +20 -11
- data/lib/poolparty/poolparty/resource.rb +9 -5
- data/lib/poolparty/poolparty/service.rb +3 -1
- data/lib/poolparty/provision/boot_strapper.rb +47 -24
- data/lib/poolparty/provision/configurations/chef.rb +7 -4
- data/lib/poolparty/provision/dr_configure.rb +80 -25
- data/lib/poolparty/resources/cron.rb +8 -0
- data/lib/poolparty/resources/directory.rb +1 -1
- data/lib/poolparty/resources/file.rb +16 -0
- data/lib/poolparty/resources/package.rb +7 -2
- data/lib/poolparty/resources/service.rb +4 -3
- data/lib/poolparty/resources/symlink.rb +0 -8
- data/lib/poolparty/schema.rb +35 -20
- data/lib/poolparty/templates/haproxy.conf +27 -25
- data/lib/poolparty/templates/monitor.ru +3 -3
- data/lib/poolparty/verification/verifier_base.rb +17 -0
- data/lib/poolparty/verification/verifiers/ping.rb +17 -0
- data/lib/poolparty/verification/verify.rb +74 -0
- data/lib/poolparty.rb +8 -9
- data/lib/poolpartycl.rb +14 -0
- data/spec/bin/server-list-active_spec.rb +2 -0
- data/spec/poolparty/base_packages/haproxy_spec.rb +1 -1
- data/spec/poolparty/core/array_spec.rb +3 -1
- data/spec/poolparty/core/ordered_hash_spec.rb +2 -2
- data/spec/poolparty/dependency_resolver/chef_resolver_spec.rb +9 -15
- data/spec/poolparty/dependency_resolver/dependency_resolver_cloud_extensions_spec.rb +6 -6
- data/spec/poolparty/dependency_resolver/puppet_resolver_spec.rb +121 -124
- data/spec/poolparty/net/remote_spec.rb +287 -286
- data/spec/poolparty/net/remoter_bases/ec2_mocks_and_stubs.rb +1 -1
- data/spec/poolparty/net/remoter_bases/ec2_remote_instance_spec.rb +7 -8
- data/spec/poolparty/net/remoter_bases/ec2_spec.rb +22 -7
- data/spec/poolparty/net/remoter_spec.rb +48 -45
- data/spec/poolparty/poolparty/cloud_spec.rb +15 -22
- data/spec/poolparty/poolparty/key_spec.rb +4 -4
- data/spec/poolparty/poolparty/neighborhoods_spec.rb +1 -2
- data/spec/poolparty/poolparty/plugin_spec.rb +2 -2
- data/spec/poolparty/poolparty/resource_spec.rb +4 -5
- data/spec/poolparty/poolparty_base_class_spec.rb +82 -78
- data/spec/poolparty/resources/package_spec.rb +0 -3
- data/spec/poolparty/spec_helper.rb +4 -4
- data/tasks/development.rake +9 -0
- data/test/poolparty/core/array_test.rb +21 -0
- data/test/poolparty/core/hash_test.rb +14 -1
- data/test/poolparty/core/string_test.rb +29 -0
- data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +106 -0
- data/test/poolparty/modules/callbacks_test.rb +40 -0
- data/test/poolparty/modules/cloud_dsl_test.rb +25 -0
- data/test/poolparty/net/remoter_bases/vmrun/vmrun_test.rb +50 -0
- data/test/poolparty/net/remoter_test.rb +14 -0
- data/test/poolparty/poolparty/neighborhood_test.rb +23 -0
- data/test/poolparty/poolparty/poolparty_base_class_test.rb +84 -0
- data/test/poolparty/verification/verify_test.rb +49 -0
- data/test/test_helper.rb +4 -1
- data/test/test_poolparty.rb +6 -5
- data/vendor/chef/apache2/attributes/apache.rb +1 -1
- data/vendor/chef/apache2/templates/default/default-site.erb +1 -1
- data/vendor/chef/chef-deploy/LICENSE +201 -0
- data/vendor/chef/chef-deploy/README.rdoc +24 -0
- data/vendor/chef/chef-deploy/Rakefile +57 -0
- data/vendor/chef/chef-deploy/TODO +4 -0
- data/vendor/chef/chef-deploy/lib/chef-deploy/cached_deploy.rb +230 -0
- data/vendor/chef/chef-deploy/lib/chef-deploy/git.rb +132 -0
- data/vendor/chef/chef-deploy/lib/chef-deploy/subversion.rb +98 -0
- data/vendor/chef/chef-deploy/lib/chef-deploy.rb +183 -0
- metadata +57 -252
- data/bin/cloud-run +0 -18
- data/bin/cloud-stats +0 -17
- data/bin/ec2-list-active +0 -24
- data/bin/pool +0 -31
- data/bin/pool-describe +0 -8
- data/bin/pool-generate +0 -18
- data/bin/pool-init +0 -28
- data/bin/pool-list +0 -30
- data/bin/pool-start +0 -26
- data/bin/server-list-instances +0 -15
- data/lib/erlang/messenger/Emakefile +0 -1
- data/lib/erlang/messenger/Makefile +0 -15
- data/lib/erlang/messenger/README +0 -5
- data/lib/erlang/messenger/Rakefile +0 -72
- data/lib/erlang/messenger/control +0 -11
- data/lib/erlang/messenger/ebin/client.app +0 -19
- data/lib/erlang/messenger/ebin/master.app +0 -19
- data/lib/erlang/messenger/ebin/node.app +0 -19
- data/lib/erlang/messenger/ebin/packager.app +0 -19
- data/lib/erlang/messenger/ebin/pm_client_rel-0.1.rel +0 -1
- data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +0 -1
- data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +0 -1
- data/lib/erlang/messenger/include/defines.hrl +0 -27
- data/lib/erlang/messenger/lib/eunit/AUTHORS +0 -2
- data/lib/erlang/messenger/lib/eunit/CHANGELOG +0 -14
- data/lib/erlang/messenger/lib/eunit/COPYING +0 -504
- data/lib/erlang/messenger/lib/eunit/Makefile +0 -28
- data/lib/erlang/messenger/lib/eunit/NOTES +0 -276
- data/lib/erlang/messenger/lib/eunit/README +0 -3
- data/lib/erlang/messenger/lib/eunit/doc/edoc-info +0 -3
- data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
- data/lib/erlang/messenger/lib/eunit/doc/eunit.html +0 -172
- data/lib/erlang/messenger/lib/eunit/doc/index.html +0 -17
- data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +0 -12
- data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +0 -984
- data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +0 -980
- data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +0 -11
- data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +0 -55
- data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +0 -21
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +0 -1
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +0 -339
- data/lib/erlang/messenger/lib/eunit/examples/fib.erl +0 -19
- data/lib/erlang/messenger/lib/eunit/examples/tests.txt +0 -1
- data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +0 -313
- data/lib/erlang/messenger/lib/eunit/src/Makefile +0 -46
- data/lib/erlang/messenger/lib/eunit/src/autoload.erl +0 -388
- data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +0 -243
- data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +0 -21
- data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +0 -1
- data/lib/erlang/messenger/lib/eunit/src/eunit.erl +0 -196
- data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +0 -102
- data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +0 -798
- data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +0 -48
- data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +0 -682
- data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +0 -552
- data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +0 -157
- data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +0 -340
- data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +0 -64
- data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +0 -334
- data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +0 -45
- data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +0 -272
- data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +0 -409
- data/lib/erlang/messenger/lib/eunit/sys.config +0 -9
- data/lib/erlang/messenger/lib/eunit/vsn.mk +0 -1
- data/lib/erlang/messenger/pm_client_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_client_rel-0.1.script +0 -238
- data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.script +0 -239
- data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.script +0 -237
- data/lib/erlang/messenger/src/client_app.erl +0 -39
- data/lib/erlang/messenger/src/client_server.erl +0 -60
- data/lib/erlang/messenger/src/master_app.erl +0 -39
- data/lib/erlang/messenger/src/node_app.erl +0 -39
- data/lib/erlang/messenger/src/pm_client.erl +0 -49
- data/lib/erlang/messenger/src/pm_client_supervisor.erl +0 -38
- data/lib/erlang/messenger/src/pm_cluster.erl +0 -61
- data/lib/erlang/messenger/src/pm_event_manager.erl +0 -27
- data/lib/erlang/messenger/src/pm_master.erl +0 -215
- data/lib/erlang/messenger/src/pm_master_event_handler.erl +0 -72
- data/lib/erlang/messenger/src/pm_master_supervisor.erl +0 -39
- data/lib/erlang/messenger/src/pm_node.erl +0 -200
- data/lib/erlang/messenger/src/pm_node_supervisor.erl +0 -38
- data/lib/erlang/messenger/src/pm_packager.erl +0 -76
- data/lib/erlang/messenger/src/pm_spawner.erl +0 -213
- data/lib/erlang/messenger/src/pm_strings.erl +0 -11
- data/lib/erlang/messenger/src/utils.erl +0 -72
- data/lib/erlang/messenger/useful_snippets +0 -17
- data/lib/poolparty/monitors/monitors/server_monitor.rb +0 -7
- data/lib/poolparty/monitors/monitors/web_monitor.rb +0 -18
- data/lib/poolparty/monitors/neighborhood_monitor.rb +0 -24
- data/lib/poolparty/monitors.rb +0 -6
- data/lib/poolparty/net/remoter/lists.rb +0 -12
- data/lib/poolparty/poolparty/custom_resource.rb +0 -45
- data/lib/poolparty/resources/custom_service.rb +0 -30
- data/lib/poolparty/services/gem_package.rb +0 -52
- data/lib/poolparty/version.rb +0 -15
- data/spec/poolparty/plugins/svn_spec.rb +0 -16
- data/spec/poolparty/poolparty/custom_resource_spec.rb +0 -79
- data/vendor/gems/butterfly/History.txt +0 -4
- data/vendor/gems/butterfly/PostInstall.txt +0 -2
- data/vendor/gems/butterfly/README.rdoc +0 -48
- data/vendor/gems/butterfly/Rakefile +0 -62
- data/vendor/gems/butterfly/VERSION.yml +0 -4
- data/vendor/gems/butterfly/bin/flutter +0 -4
- data/vendor/gems/butterfly/butterfly.gemspec +0 -37
- data/vendor/gems/butterfly/examples/config.ru +0 -15
- data/vendor/gems/butterfly/examples/my_app.rb +0 -12
- data/vendor/gems/butterfly/lib/butterfly.rb +0 -14
- data/vendor/gems/butterfly/lib/handler.rb +0 -48
- data/vendor/gems/butterfly/lib/request.rb +0 -29
- data/vendor/gems/butterfly/lib/response.rb +0 -49
- data/vendor/gems/butterfly/script/console +0 -10
- data/vendor/gems/butterfly/script/destroy +0 -14
- data/vendor/gems/butterfly/script/generate +0 -14
- data/vendor/gems/butterfly/test/test_adapter_base.rb +0 -23
- data/vendor/gems/butterfly/test/test_butterfly_request.rb +0 -46
- data/vendor/gems/butterfly/test/test_butterfly_response.rb +0 -43
- data/vendor/gems/butterfly/test/test_butterfly_server.rb +0 -16
- data/vendor/gems/butterfly/test/test_default.rb +0 -12
- data/vendor/gems/butterfly/test/test_helper.rb +0 -6
- data/vendor/gems/dslify/History.txt +0 -4
- data/vendor/gems/dslify/Manifest.txt +0 -25
- data/vendor/gems/dslify/PostInstall.txt +0 -5
- data/vendor/gems/dslify/README.txt +0 -60
- data/vendor/gems/dslify/Rakefile +0 -56
- data/vendor/gems/dslify/config/hoe.rb +0 -73
- data/vendor/gems/dslify/config/requirements.rb +0 -15
- data/vendor/gems/dslify/dslify.gemspec +0 -40
- data/vendor/gems/dslify/lib/dslify/dslify.rb +0 -69
- data/vendor/gems/dslify/lib/dslify/version.rb +0 -10
- data/vendor/gems/dslify/lib/dslify.rb +0 -7
- data/vendor/gems/dslify/script/console +0 -10
- data/vendor/gems/dslify/script/destroy +0 -14
- data/vendor/gems/dslify/script/generate +0 -14
- data/vendor/gems/dslify/script/txt2html +0 -82
- data/vendor/gems/dslify/setup.rb +0 -1585
- data/vendor/gems/dslify/tasks/deployment.rake +0 -34
- data/vendor/gems/dslify/tasks/environment.rake +0 -7
- data/vendor/gems/dslify/tasks/website.rake +0 -17
- data/vendor/gems/dslify/test/test_dslify.rb +0 -114
- data/vendor/gems/dslify/website/index.html +0 -86
- data/vendor/gems/dslify/website/index.txt +0 -83
- data/vendor/gems/dslify/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/vendor/gems/dslify/website/stylesheets/screen.css +0 -138
- data/vendor/gems/dslify/website/template.html.erb +0 -48
- data/vendor/gems/parenting/History.txt +0 -4
- data/vendor/gems/parenting/Manifest.txt +0 -13
- data/vendor/gems/parenting/PostInstall.txt +0 -2
- data/vendor/gems/parenting/README.rdoc +0 -47
- data/vendor/gems/parenting/Rakefile +0 -28
- data/vendor/gems/parenting/lib/parenting/base.rb +0 -65
- data/vendor/gems/parenting/lib/parenting.rb +0 -10
- data/vendor/gems/parenting/parenting.gemspec +0 -39
- data/vendor/gems/parenting/script/console +0 -10
- data/vendor/gems/parenting/script/destroy +0 -14
- data/vendor/gems/parenting/script/generate +0 -14
- data/vendor/gems/parenting/test/file_to_eval.rb +0 -9
- data/vendor/gems/parenting/test/test_helper.rb +0 -5
- data/vendor/gems/parenting/test/test_parenting.rb +0 -89
- data/vendor/gems/suitcase/LICENSE +0 -20
- data/vendor/gems/suitcase/README.rdoc +0 -31
- data/vendor/gems/suitcase/Rakefile +0 -57
- data/vendor/gems/suitcase/VERSION.yml +0 -4
- data/vendor/gems/suitcase/lib/suitcase/unzipper.rb +0 -15
- data/vendor/gems/suitcase/lib/suitcase/zipper.rb +0 -119
- data/vendor/gems/suitcase/lib/suitcase.rb +0 -5
- data/vendor/gems/suitcase/suitcase.gemspec +0 -32
- data/vendor/gems/suitcase/test/suitcase_test.rb +0 -102
- data/vendor/gems/suitcase/test/test_dir/box.rb +0 -1
- data/vendor/gems/suitcase/test/test_dir/test.txt +0 -1
- data/vendor/gems/suitcase/test/test_helper.rb +0 -12
@@ -3,240 +3,190 @@ require "ping"
|
|
3
3
|
module PoolParty
|
4
4
|
module Remote
|
5
5
|
|
6
|
-
#
|
7
|
-
# remoter_bases
|
8
|
-
def launch_instance!(o={}, &block)
|
9
|
-
@inst = launch_new_instance!( o )
|
10
|
-
wait "2.seconds"
|
11
|
-
500.times do |i|
|
12
|
-
if @inst.status =~ /pending/
|
13
|
-
sleep(2)
|
14
|
-
@inst = describe_instance(@inst)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
when_instance_is_responding @inst do
|
18
|
-
block.call(@inst) if block
|
19
|
-
after_launch_instance(@inst)
|
20
|
-
end
|
21
|
-
@inst
|
22
|
-
end
|
23
|
-
|
24
|
-
# Called after an instance is launched
|
25
|
-
def after_launch_instance(instance=nil)
|
26
|
-
end
|
27
|
-
|
28
|
-
def when_instance_is_responding(inst, &block)
|
29
|
-
if ping_port(inst.ip, 22)
|
30
|
-
block.call if block
|
31
|
-
else
|
32
|
-
raise "Instance not responding at #{inst.ip}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# A convenience method for waiting until there are no more
|
37
|
-
# pending instances and then running the block
|
38
|
-
def when_no_pending_instances(&block)
|
39
|
-
reset!
|
40
|
-
if list_of_pending_instances && list_of_pending_instances.size == 0
|
41
|
-
vputs "" # Clear the terminal with a newline
|
42
|
-
block.call if block
|
43
|
-
else
|
44
|
-
vprint "."
|
45
|
-
wait "5.seconds"
|
46
|
-
when_no_pending_instances(&block)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# Stub method for the time being to handle expansion of the cloud
|
51
|
-
def can_expand_cloud?(force=false)
|
52
|
-
(are_too_few_instances_running? || are_expansion_rules_valid? ) || force || false
|
53
|
-
end
|
54
|
-
def are_expansion_rules_valid?
|
55
|
-
valid_rules?(:expand_when)
|
56
|
-
end
|
57
|
-
# Stub method for the time being to handle the contraction of the cloud
|
58
|
-
def can_contract_cloud?(force=false)
|
59
|
-
return true if force
|
60
|
-
((are_any_nodes_exceeding_minimum_runtime? and are_too_many_instances_running?) || are_contraction_rules_valid?) || false
|
61
|
-
end
|
62
|
-
def are_contraction_rules_valid?
|
63
|
-
valid_rules?(:contract_when)
|
64
|
-
end
|
65
|
-
# Expand the cloud
|
66
|
-
# If we can start a new instance and the load requires us to expand
|
67
|
-
# the cloud, then we should request_launch_new_instances
|
68
|
-
# Wait for the instance to boot up and when it does come back
|
69
|
-
# online, then provision it as a slave, this way, it is ready for action from the
|
70
|
-
# get go
|
71
|
-
def expand_cloud_if_necessary(force=false)
|
72
|
-
if can_start_a_new_instance? && can_expand_cloud?(force)
|
73
|
-
vputs "Expanding the cloud based on load"
|
74
|
-
@num = 1
|
75
|
-
@num.times do |i|
|
76
|
-
list_of_pending_instances.size == 0 ? request_launch_one_instance_at_a_time : wait("5.seconds")
|
77
|
-
reset!
|
78
|
-
vputs "request_launch_new_instances: #{@num}"
|
79
|
-
provision_slaves_from_n(@num)
|
80
|
-
after_launched
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
# Contract the cloud
|
85
|
-
# If we can shutdown an instnace and the load allows us to contract
|
86
|
-
# the cloud, then we should request_termination_of_non_master_instance
|
87
|
-
def contract_cloud_if_necessary(force=false)
|
88
|
-
if can_shutdown_an_instance? && can_contract_cloud?(force)
|
89
|
-
vputs "Shrinking the cloud by 1"
|
90
|
-
before_shutdown
|
91
|
-
request_termination_of_non_master_instance
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# List calculation methods
|
96
|
-
#
|
97
|
-
# Are the minimum number of instances running?
|
98
|
-
def minimum_number_of_instances_are_running?
|
99
|
-
list_of_running_instances.size >= minimum_instances.to_i
|
100
|
-
end
|
101
|
-
# Are the minimum number of instances NOT running?
|
102
|
-
def minimum_number_of_instances_are_not_running?
|
103
|
-
!(minimum_number_of_instances_are_running?)
|
104
|
-
end
|
105
|
-
# Can we shutdown an instance?
|
106
|
-
def can_shutdown_an_instance?
|
107
|
-
list_of_running_instances.size > minimum_instances.to_i
|
108
|
-
end
|
109
|
-
# Are too few instances running?
|
6
|
+
# # Are too few instances running?
|
110
7
|
def are_too_few_instances_running?
|
111
|
-
|
8
|
+
nodes(:status => "running").size < minimum_instances.to_i
|
112
9
|
end
|
113
|
-
# Are there more instances than allowed?
|
10
|
+
# # Are there more instances than allowed?
|
114
11
|
def are_too_many_instances_running?
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
########
|
119
|
-
# TODO: deprecate methods below here (only if they are deprecate-able)
|
120
|
-
########
|
121
|
-
|
122
|
-
# Request to launch a number of instances
|
123
|
-
def request_launch_new_instances(num=1)
|
124
|
-
out = []
|
125
|
-
num.times {out << launch_new_instance!(options) }
|
126
|
-
out
|
127
|
-
end
|
128
|
-
def request_launch_master_instance
|
129
|
-
@inst = launch_new_instance!
|
130
|
-
wait "5.seconds"
|
131
|
-
when_no_pending_instances do
|
132
|
-
vputs "Master has launched"
|
133
|
-
reset!
|
134
|
-
after_launch_master(@inst)
|
135
|
-
end
|
12
|
+
nodes(:status => "running").size > maximum_instances.to_i
|
136
13
|
end
|
137
14
|
|
138
15
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
#
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
#
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
#
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
#
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
def
|
163
|
-
|
164
|
-
|
16
|
+
# TODO: Deprecate all below here
|
17
|
+
# # A convenience method for waiting until there are no more
|
18
|
+
# # pending instances and then running the block
|
19
|
+
# def when_no_pending_instances(&block)
|
20
|
+
# reset!
|
21
|
+
# if list_of_pending_instances && list_of_pending_instances.size == 0
|
22
|
+
# vputs "" # Clear the terminal with a newline
|
23
|
+
# block.call if block
|
24
|
+
# else
|
25
|
+
# vprint "."
|
26
|
+
# wait "5.seconds"
|
27
|
+
# when_no_pending_instances(&block)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# # Stub method for the time being to handle expansion of the cloud
|
32
|
+
# def can_expand_cloud?(force=false)
|
33
|
+
# (are_too_few_instances_running? || are_expansion_rules_valid? ) || force || false
|
34
|
+
# end
|
35
|
+
# def are_expansion_rules_valid?
|
36
|
+
# valid_rules?(:expand_when)
|
37
|
+
# end
|
38
|
+
# # Stub method for the time being to handle the contraction of the cloud
|
39
|
+
# def can_contract_cloud?(force=false)
|
40
|
+
# return true if force
|
41
|
+
# ((are_any_nodes_exceeding_minimum_runtime? and are_too_many_instances_running?) || are_contraction_rules_valid?) || false
|
42
|
+
# end
|
43
|
+
# def are_contraction_rules_valid?
|
44
|
+
# valid_rules?(:contract_when)
|
45
|
+
# end
|
46
|
+
# # Expand the cloud
|
47
|
+
# # If we can start a new instance and the load requires us to expand
|
48
|
+
# # the cloud, then we should request_launch_new_instances
|
49
|
+
# # Wait for the instance to boot up and when it does come back
|
50
|
+
# # online, then provision it as a slave, this way, it is ready for action from the
|
51
|
+
# # get go
|
52
|
+
# def expand_cloud_if_necessary(force=false)
|
53
|
+
# if can_start_a_new_instance? && can_expand_cloud?(force)
|
54
|
+
# vputs "Expanding the cloud based on load"
|
55
|
+
# @num = 1
|
56
|
+
# @num.times do |i|
|
57
|
+
# list_of_pending_instances.size == 0 ? request_launch_one_instance_at_a_time : wait("5.seconds")
|
58
|
+
# reset!
|
59
|
+
# vputs "request_launch_new_instances: #{@num}"
|
60
|
+
# provision_slaves_from_n(@num)
|
61
|
+
# after_launched
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# # Contract the cloud
|
66
|
+
# # If we can shutdown an instnace and the load allows us to contract
|
67
|
+
# # the cloud, then we should request_termination_of_non_master_instance
|
68
|
+
# def contract_cloud_if_necessary(force=false)
|
69
|
+
# if can_shutdown_an_instance? && can_contract_cloud?(force)
|
70
|
+
# vputs "Shrinking the cloud by 1"
|
71
|
+
# before_shutdown
|
72
|
+
# request_termination_of_non_master_instance
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# # List calculation methods
|
77
|
+
# #
|
78
|
+
# # Are the minimum number of instances running?
|
79
|
+
# def minimum_number_of_instances_are_running?
|
80
|
+
# nodes(:status => "running").size >= minimum_instances.to_i
|
81
|
+
# end
|
82
|
+
# # Are the minimum number of instances NOT running?
|
83
|
+
# def minimum_number_of_instances_are_not_running?
|
84
|
+
# !(minimum_number_of_instances_are_running?)
|
85
|
+
# end
|
86
|
+
# # Can we shutdown an instance?
|
87
|
+
# def can_shutdown_an_instance?
|
88
|
+
# nodes(:status => "running").size > minimum_instances.to_i
|
89
|
+
# end
|
90
|
+
|
91
|
+
#
|
92
|
+
# ########
|
93
|
+
# # TODO: deprecate methods below here (only if they are deprecate-able)
|
94
|
+
# ########
|
95
|
+
#
|
96
|
+
# # Request to launch a number of instances
|
97
|
+
# def request_launch_new_instances(num=1)
|
98
|
+
# out = []
|
99
|
+
# num.times {out << launch_new_instance!(options) }
|
100
|
+
# out
|
101
|
+
# end
|
102
|
+
# def request_launch_master_instance
|
103
|
+
# @inst = launch_new_instance!
|
104
|
+
# wait "5.seconds"
|
105
|
+
# when_no_pending_instances do
|
106
|
+
# vputs "Master has launched"
|
107
|
+
# reset!
|
108
|
+
# after_launch_master(@inst)
|
109
|
+
# end
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
#
|
113
|
+
# def after_launch_master(inst=nil)
|
114
|
+
# vputs "After launch master in remoter"
|
115
|
+
# end
|
116
|
+
# # Let's terminate an instance that is not the master instance
|
117
|
+
# def request_termination_of_non_master_instance
|
118
|
+
# inst = nonmaster_nonterminated_instances.last
|
119
|
+
# terminate_instance!(inst.instance_id) if inst
|
120
|
+
# end
|
121
|
+
# # Can we start a new instance?
|
122
|
+
# def can_start_a_new_instance?
|
123
|
+
# maximum_number_of_instances_are_not_running? && list_of_pending_instances.size == 0
|
124
|
+
# end
|
125
|
+
# # Are the maximum number of instances not running?
|
126
|
+
# def maximum_number_of_instances_are_not_running?
|
127
|
+
# nodes(:status => "running").size < maximum_instances.to_i
|
128
|
+
# end
|
129
|
+
# # Are the maximum number of instances running?
|
130
|
+
# def maximum_number_of_instances_are_running?
|
131
|
+
# nodes(:status => "running").size >= maximum_instances.to_i
|
132
|
+
# end
|
133
|
+
# # Launch new instance while waiting for the number of pending instances
|
134
|
+
# # to be zero before actually launching. This ensures that we only
|
135
|
+
# # launch one instance at a time
|
136
|
+
# def request_launch_one_instance_at_a_time
|
137
|
+
# when_no_pending_instances { launch_new_instance! }
|
138
|
+
# end
|
139
|
+
#
|
140
|
+
# # A convenience method for waiting until all the instances have an ip
|
141
|
+
# # assigned to them. This is useful when shifting the ip addresses
|
142
|
+
# # around on the instances
|
143
|
+
# def when_all_assigned_ips(&block)
|
144
|
+
# reset!
|
145
|
+
# if list_of_nonterminated_instances.select {|a| a.ip == 'not.assigned' }.empty?
|
146
|
+
# block.call if block
|
147
|
+
# else
|
148
|
+
# vprint "."
|
149
|
+
# wait "5.seconds"
|
150
|
+
# when_all_assigned_ips(&block)
|
151
|
+
# end
|
152
|
+
# end
|
153
|
+
# def running_instance_ips
|
154
|
+
# remote_instances_list.select {|inst|
|
155
|
+
# inst.running? and inst.ip!='not.assigned'
|
156
|
+
# }.collect{|n| n.ip}
|
157
|
+
# end
|
158
|
+
#
|
159
|
+
# # This will launch the minimum_instances if the minimum number of instances are not running
|
160
|
+
# # If the minimum number of instances are not running and if we can start a new instance
|
161
|
+
# def launch_minimum_number_of_instances
|
162
|
+
# if can_start_a_new_instance? && !minimum_number_of_instances_are_running?
|
163
|
+
# list_of_pending_instances.size == 0 ? request_launch_one_instance_at_a_time : wait("5.seconds")
|
164
|
+
# reset!
|
165
|
+
# launch_minimum_number_of_instances
|
166
|
+
# provision_slaves_from_n(minimum_instances.to_i)
|
167
|
+
# after_launched
|
168
|
+
# end
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# def provision_slaves_from_n(num=1)
|
172
|
+
# vputs "In provision_slaves_from_n: #{num}"
|
173
|
+
# reset!
|
174
|
+
# when_no_pending_instances do
|
175
|
+
# vputs "Waiting for 10 seconds"
|
176
|
+
# wait "10.seconds" # Give some time for ssh to startup
|
177
|
+
# @num_instances = nodes(:status => "running").size
|
178
|
+
# vputs "(@num_instances - (num))..(@num_instances): #{(@num_instances - (num))..(@num_instances)}"
|
179
|
+
# last_instances = nonmaster_nonterminated_instances[(@num_instances - (num))..(@num_instances)]
|
180
|
+
# last_instances.each do |inst|
|
181
|
+
# vputs "Provision slave: #{inst}"
|
182
|
+
# verbose ? provisioner_for(inst).install(testing) : hide_output { provisioner_for(inst).install(testing)}
|
183
|
+
# end
|
184
|
+
# # PoolParty::Provisioner.reconfigure_master(self)
|
185
|
+
# end
|
186
|
+
# end
|
165
187
|
|
166
|
-
# A convenience method for waiting until all the instances have an ip
|
167
|
-
# assigned to them. This is useful when shifting the ip addresses
|
168
|
-
# around on the instances
|
169
|
-
def when_all_assigned_ips(&block)
|
170
|
-
reset!
|
171
|
-
if list_of_nonterminated_instances.select {|a| a.ip == 'not.assigned' }.empty?
|
172
|
-
block.call if block
|
173
|
-
else
|
174
|
-
vprint "."
|
175
|
-
wait "5.seconds"
|
176
|
-
when_all_assigned_ips(&block)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
def running_instance_ips
|
180
|
-
remote_instances_list.select {|inst|
|
181
|
-
inst.running? and inst.ip!='not.assigned'
|
182
|
-
}.collect{|n| n.ip}
|
183
|
-
end
|
184
|
-
|
185
|
-
# This will launch the minimum_instances if the minimum number of instances are not running
|
186
|
-
# If the minimum number of instances are not running and if we can start a new instance
|
187
|
-
def launch_minimum_number_of_instances
|
188
|
-
if can_start_a_new_instance? && !minimum_number_of_instances_are_running?
|
189
|
-
list_of_pending_instances.size == 0 ? request_launch_one_instance_at_a_time : wait("5.seconds")
|
190
|
-
reset!
|
191
|
-
launch_minimum_number_of_instances
|
192
|
-
provision_slaves_from_n(minimum_instances.to_i)
|
193
|
-
after_launched
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def provision_slaves_from_n(num=1)
|
198
|
-
vputs "In provision_slaves_from_n: #{num}"
|
199
|
-
reset!
|
200
|
-
when_no_pending_instances do
|
201
|
-
vputs "Waiting for 10 seconds"
|
202
|
-
wait "10.seconds" # Give some time for ssh to startup
|
203
|
-
@num_instances = list_of_running_instances.size
|
204
|
-
vputs "(@num_instances - (num))..(@num_instances): #{(@num_instances - (num))..(@num_instances)}"
|
205
|
-
last_instances = nonmaster_nonterminated_instances[(@num_instances - (num))..(@num_instances)]
|
206
|
-
last_instances.each do |inst|
|
207
|
-
vputs "Provision slave: #{inst}"
|
208
|
-
verbose ? provisioner_for(inst).install(testing) : hide_output { provisioner_for(inst).install(testing)}
|
209
|
-
end
|
210
|
-
# PoolParty::Provisioner.reconfigure_master(self)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
# Launch the master and let the master handle the starting of the cloud
|
214
|
-
# We should only launch an instance if there are no pending instances, in the case
|
215
|
-
# that the master has launched, but is still pending
|
216
|
-
# and if the master is not running AND we can start a new instance
|
217
|
-
# Then wait for the master to launch
|
218
|
-
def launch_and_configure_master!(testing=false)
|
219
|
-
vputs "Requesting to launch new instance"
|
220
|
-
dputs "Launching master"
|
221
|
-
request_launch_master_instance if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running? && !testing
|
222
|
-
reset!
|
223
|
-
unless testing
|
224
|
-
vputs ""
|
225
|
-
vputs "Waiting for there to be no pending instances..."
|
226
|
-
when_no_pending_instances do
|
227
|
-
when_all_assigned_ips {wait "20.seconds"}
|
228
|
-
vputs ""
|
229
|
-
vputs "Provisioning master..."
|
230
|
-
# cleanup_storage_directory
|
231
|
-
@provisioner = PoolParty::Provisioner::Capistrano.new(master, self, :ubuntu)
|
232
|
-
verbose ? @provisioner.install(testing) : hide_output { @provisioner.install(testing) }
|
233
|
-
|
234
|
-
after_launched
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
188
|
def list_of_nodes_exceeding_minimum_runtime
|
239
|
-
|
189
|
+
nodes(:status => "running").reject{|i| i.elapsed_runtime < minimum_runtime}
|
240
190
|
end
|
241
191
|
|
242
192
|
def are_any_nodes_exceeding_minimum_runtime?
|
@@ -244,7 +194,7 @@ module PoolParty
|
|
244
194
|
end
|
245
195
|
# Is there a node that is running with the name master
|
246
196
|
def is_master_running?
|
247
|
-
!
|
197
|
+
!nodes(:status => "running").select {|a| a.name == "master"}.first.nil?
|
248
198
|
end
|
249
199
|
|
250
200
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
require "#{::File.dirname(__FILE__)}/../../modules/pinger"
|
1
2
|
require 'rubygems'
|
2
3
|
require 'net/ssh'
|
3
|
-
require "socket"
|
4
4
|
|
5
5
|
module PoolParty
|
6
6
|
module Remote
|
7
7
|
|
8
|
+
include ::PoolParty::Pinger
|
9
|
+
|
8
10
|
def target_host(dns_or_ip=nil)
|
9
11
|
dns_or_ip ? @target_host=dns_or_ip : @target_host
|
10
12
|
end
|
@@ -27,7 +29,7 @@ module PoolParty
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def ssh_options(opts={})
|
30
|
-
o = {"-i" =>
|
32
|
+
o = {"-i" => keypair.full_filepath,
|
31
33
|
"-l" => user,
|
32
34
|
"-o" =>"StrictHostKeyChecking=no"
|
33
35
|
}.merge(opts)
|
@@ -35,7 +37,9 @@ module PoolParty
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def rsync( source_path, destination_path, rsync_opts=['-v -a'] )
|
38
|
-
|
40
|
+
dputs "rsync -e 'ssh #{ssh_options}' #{rsync_opts.join(' ')} #{source_path} root@#{target_host}:#{destination_path}"
|
41
|
+
out = %x{ rsync -e 'ssh #{ssh_options}' #{rsync_opts.join(' ')} #{source_path} root@#{target_host}:#{destination_path} }
|
42
|
+
puts out if debugging?
|
39
43
|
end
|
40
44
|
|
41
45
|
def run_local(commands)
|
@@ -51,27 +55,15 @@ module PoolParty
|
|
51
55
|
# TODO: make extendable multithreaded version
|
52
56
|
def execute!(cmds=commands)
|
53
57
|
netssh(
|
54
|
-
[cmds.compact.join(' && ')],
|
58
|
+
[cmds.compact.join(' && ')],
|
55
59
|
:host=>target_host, :user=>'root')
|
56
60
|
# commands.each {|c| run_remote(c, target_host) }
|
57
|
-
end
|
58
|
-
|
59
|
-
def ping_port(host, port=22, retry_times=400)
|
60
|
-
connected = false
|
61
|
-
retry_times.times do |i|
|
62
|
-
begin
|
63
|
-
break if connected = TCPSocket.new(host, port).is_a?(TCPSocket)
|
64
|
-
rescue Exception => e
|
65
|
-
sleep(2)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
connected
|
69
61
|
end
|
70
62
|
|
71
63
|
def netssh(cmds=[], opts={})
|
72
64
|
user = opts.delete(:user) || user #rescue 'root'
|
73
65
|
host = opts.delete(:host) || target_host
|
74
|
-
ssh_options_hash = {:keys => [
|
66
|
+
ssh_options_hash = {:keys => [keypair.full_filepath],
|
75
67
|
:auth_methods => 'publickey',
|
76
68
|
:paranoid => false
|
77
69
|
}.merge(opts)
|
@@ -79,7 +71,7 @@ module PoolParty
|
|
79
71
|
# Start the connection
|
80
72
|
Net::SSH.start(host, user, ssh_options_hash) do |ssh|
|
81
73
|
cmds.each do |command|
|
82
|
-
ssh.exec!(command) do |ch, stream, data|
|
74
|
+
ssh.exec!(command) do |ch, stream, data|
|
83
75
|
if stream == :stdout
|
84
76
|
print data
|
85
77
|
else
|
@@ -1,27 +1,5 @@
|
|
1
1
|
module PoolParty
|
2
2
|
module Remote
|
3
|
-
# The following methods are inherent on the RemoterBase
|
4
|
-
# If you need to overwrite these methods, do so with caution
|
5
|
-
# Listing methods
|
6
|
-
def list_of_running_instances(list = list_of_nonterminated_instances)
|
7
|
-
list.select {|a| a if a.running? }
|
8
|
-
end
|
9
|
-
# Get a list of the pending instances
|
10
|
-
def list_of_pending_instances(list = list_of_nonterminated_instances)
|
11
|
-
list.select {|a| a if a.pending? }
|
12
|
-
end
|
13
|
-
# list of shutting down instances
|
14
|
-
def list_of_terminating_instances(list = remote_instances_list)
|
15
|
-
list.reject {|i| true if !i.terminating? }
|
16
|
-
end
|
17
|
-
# Get the instances that are non-master instances
|
18
|
-
def nonmaster_nonterminated_instances(list = list_of_nonterminated_instances)
|
19
|
-
list_of_nonterminated_instances.reject {|i| i.master? }
|
20
|
-
end
|
21
|
-
# list all the nonterminated instances
|
22
|
-
def list_of_nonterminated_instances(list = remote_instances_list)
|
23
|
-
list.reject {|i| i.terminating? || i.terminated? }
|
24
|
-
end
|
25
3
|
|
26
4
|
# #DEPRECATE We'll stub the ip to be the master ip for ease and accessibility
|
27
5
|
# def ip(i=nil)
|
@@ -34,88 +12,44 @@ module PoolParty
|
|
34
12
|
get_instance_by_number(0)
|
35
13
|
end
|
36
14
|
|
37
|
-
#
|
38
|
-
def
|
39
|
-
|
40
|
-
|
15
|
+
# Select a list of instances based on their status
|
16
|
+
def nodes(hsh={})
|
17
|
+
# _nodes[hsh] ||=
|
18
|
+
list_of_instances.select_with_hash(hsh)
|
41
19
|
end
|
42
|
-
|
43
|
-
|
20
|
+
|
21
|
+
# Cache the instances_by_status here
|
22
|
+
def _nodes
|
23
|
+
@_nodes ||= {}
|
44
24
|
end
|
45
25
|
|
46
|
-
|
26
|
+
# Select the list of instances, either based on the neighborhoods
|
27
|
+
# loaded from /etc/poolparty/neighborhood.json
|
28
|
+
# or by the remote_base on keypair
|
29
|
+
def list_of_instances
|
30
|
+
return @list_of_instances if @list_of_instances
|
47
31
|
@containing_cloud = self
|
48
32
|
n = Neighborhoods.load_default
|
49
|
-
@
|
50
|
-
self.remote_instance_base.constantize.send :new, h, @containing_cloud
|
51
|
-
end
|
33
|
+
@list_of_instances = (n.empty? ? _list_of_instances : n.instances)
|
52
34
|
end
|
53
35
|
|
36
|
+
private
|
54
37
|
# List the instances for the current key pair, regardless of their states
|
55
38
|
# If no keypair is passed, select them all
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
unless @describe_instances
|
60
|
-
tmpInstanceList = remote_base.describe_instances(options).select {|a| a if (tmp_key.nil? || tmp_key.empty? ? true : a[:keypair] == tmp_key) }
|
61
|
-
has_master = !tmpInstanceList.select {|a| a[:name] == "master" }.empty?
|
62
|
-
if has_master
|
63
|
-
@describe_instances = tmpInstanceList
|
64
|
-
else
|
65
|
-
@id = 0
|
66
|
-
running = select_from_instances_on_status(/running/, tmpInstanceList)
|
67
|
-
pending = select_from_instances_on_status(/pending/, tmpInstanceList)
|
68
|
-
terminated = select_from_instances_on_status(/shutting/, tmpInstanceList)
|
69
|
-
|
70
|
-
running = running.map do |inst|
|
71
|
-
inst[:name] = (@id == 0 ? "master" : "node#{@id}")
|
72
|
-
@id += 1
|
73
|
-
inst
|
74
|
-
end.sort_by {|a| a[:index] }
|
75
|
-
|
76
|
-
@describe_instances = [running, pending, terminated].flatten
|
77
|
-
end
|
78
|
-
end
|
79
|
-
@describe_instances
|
39
|
+
def _list_of_instances(select={})
|
40
|
+
@describe_instances ||= remote_base.describe_instances(options).select_with_hash(select)
|
80
41
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
42
|
+
|
43
|
+
# If the cloud is starting an instance, it will not be listed in
|
44
|
+
# the running instances, so we need to keep track of the instance
|
45
|
+
# that is being started so we can add it to the neighborhood list
|
46
|
+
def started_instance
|
47
|
+
@started_instance ||= []
|
84
48
|
end
|
85
49
|
|
86
|
-
# Helpers
|
87
|
-
def create_keypair
|
88
|
-
end
|
89
50
|
# Reset the cache of descriptions
|
90
51
|
def reset_remoter_base!
|
91
|
-
@describe_instances = nil
|
92
|
-
end
|
93
|
-
def self.included(other)
|
94
|
-
# PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
|
95
|
-
end
|
96
|
-
|
97
|
-
# Callback after loaded
|
98
|
-
def loaded_remoter_base
|
99
|
-
end
|
100
|
-
|
101
|
-
# Custom minimum runnable options
|
102
|
-
# Extend the minimum runnable options that are necessary
|
103
|
-
# for poolparty to run on the remote base
|
104
|
-
def custom_minimum_runnable_options
|
105
|
-
[]
|
106
|
-
end
|
107
|
-
|
108
|
-
# Custom installation tasks
|
109
|
-
# Allow the remoter bases to attach their own tasks on the
|
110
|
-
# installation process
|
111
|
-
def custom_install_tasks_for(a=nil)
|
112
|
-
[]
|
113
|
-
end
|
114
|
-
# Custom configure tasks
|
115
|
-
# Allows the remoter bases to attach their own
|
116
|
-
# custom configuration tasks to the configuration process
|
117
|
-
def custom_configure_tasks_for(a=nil)
|
118
|
-
[]
|
52
|
+
@_nodes = @list_of_instances = @describe_instances = nil
|
119
53
|
end
|
120
54
|
|
121
55
|
end
|