auser-poolparty 1.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/History.txt +3 -0
  2. data/README.txt +10 -7
  3. data/Rakefile +0 -1
  4. data/VERSION.yml +2 -2
  5. data/bin/cloud-osxcopy +1 -1
  6. data/bin/cloud-setup-dev +1 -1
  7. data/bin/cloud-spec +0 -1
  8. data/bin/cloud-terminate +7 -1
  9. data/bin/cloud-verify +30 -0
  10. data/examples/basic.rb +3 -6
  11. data/examples/fairchild.rb +17 -21
  12. data/examples/maize.rb +37 -0
  13. data/lib/poolparty/base_packages/haproxy.rb +6 -6
  14. data/lib/poolparty/base_packages/heartbeat.rb +1 -43
  15. data/lib/poolparty/base_packages/poolparty.rb +1 -3
  16. data/lib/poolparty/modules/cloud_dsl.rb +10 -2
  17. data/lib/poolparty/modules/cloud_resourcer.rb +0 -4
  18. data/lib/poolparty/net/init.rb +1 -1
  19. data/lib/poolparty/net/remote_instance.rb +0 -27
  20. data/lib/poolparty/net/remoter/cloud_control.rb +0 -177
  21. data/lib/poolparty/net/remoter/interactive.rb +5 -16
  22. data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +1 -10
  23. data/lib/poolparty/plugins/apache2.rb +53 -0
  24. data/lib/poolparty/plugins/deploy_directory.rb +16 -14
  25. data/lib/poolparty/plugins/gem_package.rb +24 -0
  26. data/lib/poolparty/plugins/line_in_file.rb +16 -0
  27. data/lib/poolparty/poolparty/plugin.rb +8 -6
  28. data/lib/poolparty/provision/dr_configure.rb +1 -0
  29. data/lib/poolparty/resources.rb +42 -0
  30. data/lib/poolparty/resources/cron.rb +30 -1
  31. data/lib/poolparty/resources/directory.rb +23 -0
  32. data/lib/poolparty/resources/exec.rb +22 -0
  33. data/lib/poolparty/resources/file.rb +28 -0
  34. data/lib/poolparty/resources/host.rb +22 -1
  35. data/lib/poolparty/resources/mount.rb +24 -0
  36. data/lib/poolparty/resources/package.rb +29 -13
  37. data/lib/poolparty/resources/remote_file.rb +32 -0
  38. data/lib/poolparty/resources/service.rb +20 -0
  39. data/lib/poolparty/resources/sshkey.rb +22 -0
  40. data/lib/poolparty/resources/symlink.rb +30 -0
  41. data/lib/poolparty/resources/variable.rb +25 -0
  42. data/lib/poolparty/templates/php.ini.erb +1253 -0
  43. data/lib/poolparty/verification/verifiers/ping.rb +5 -0
  44. data/lib/poolparty/verification/verify.rb +2 -0
  45. data/spec/bin/fixtures/bin_cloud_for_test.rb +0 -6
  46. data/spec/poolparty/dependency_resolver/chef_resolver_spec.rb +0 -6
  47. data/spec/poolparty/net/remoter_bases/ec2_remote_instance_spec.rb +0 -10
  48. data/spec/poolparty/spec_helper.rb +0 -1
  49. data/tasks/spec.rake +2 -0
  50. data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +0 -10
  51. data/test/poolparty/verification/verify_test.rb +3 -3
  52. data/vendor/chef/apache2/attributes/apache.rb +1 -1
  53. data/vendor/gems/parenting/Manifest.txt +2 -1
  54. data/vendor/gems/parenting/lib/parenting.rb +1 -1
  55. data/vendor/gems/parenting/parenting.gemspec +2 -2
  56. metadata +8 -70
  57. data/bin/messenger-get-current-nodes +0 -14
  58. data/bin/server-become-master +0 -24
  59. data/bin/server-build-messenger +0 -28
  60. data/bin/server-clean-cert-for +0 -15
  61. data/bin/server-provision +0 -32
  62. data/bin/server-start-agent +0 -15
  63. data/bin/server-start-client +0 -29
  64. data/bin/server-start-master +0 -26
  65. data/bin/server-start-node +0 -32
  66. data/bin/server-stop-client +0 -3
  67. data/bin/server-stop-master +0 -3
  68. data/bin/server-stop-node +0 -3
  69. data/bin/server-update-hosts +0 -49
  70. data/lib/poolparty/capistrano.rb +0 -54
  71. data/lib/poolparty/capistrano/cloud_tasks.rb +0 -10
  72. data/lib/poolparty/config/postlaunchmessage.txt +0 -5
  73. data/lib/poolparty/net/messenger.rb +0 -57
  74. data/lib/poolparty/plugins/rsyncmirror.rb +0 -28
  75. data/lib/poolparty/services/conditional.rb +0 -46
  76. data/lib/poolparty/spec.rb +0 -31
  77. data/lib/poolparty/spec/core/string.rb +0 -18
  78. data/lib/poolparty/spec/matchers/a_spec_extensions_base.rb +0 -26
  79. data/lib/poolparty/spec/matchers/have_cron.rb +0 -28
  80. data/lib/poolparty/spec/matchers/have_deploydirectory.rb +0 -15
  81. data/lib/poolparty/spec/matchers/have_directory.rb +0 -31
  82. data/lib/poolparty/spec/matchers/have_exec.rb +0 -28
  83. data/lib/poolparty/spec/matchers/have_file.rb +0 -28
  84. data/lib/poolparty/spec/matchers/have_gempackage.rb +0 -28
  85. data/lib/poolparty/spec/matchers/have_git.rb +0 -28
  86. data/lib/poolparty/spec/matchers/have_host.rb +0 -28
  87. data/lib/poolparty/spec/matchers/have_mount.rb +0 -28
  88. data/lib/poolparty/spec/matchers/have_package.rb +0 -28
  89. data/lib/poolparty/spec/matchers/have_remotefile.rb +0 -28
  90. data/lib/poolparty/spec/matchers/have_rsyncmirror.rb +0 -28
  91. data/lib/poolparty/spec/matchers/have_service.rb +0 -28
  92. data/lib/poolparty/spec/matchers/have_sshkey.rb +0 -28
  93. data/lib/poolparty/spec/matchers/have_symlink.rb +0 -28
  94. data/lib/poolparty/spec/matchers/have_variable.rb +0 -32
  95. data/lib/poolparty/spec/spec/dynamic_matchers.rb +0 -63
  96. data/lib/poolparty/spec/spec/ensure_matchers_exist.rb +0 -7
  97. data/lib/poolparty/spec/templates/have_base.rb +0 -28
  98. data/spec/poolparty/net/messenger_spec.rb +0 -16
  99. data/spec/poolparty/services/conditional_spec.rb +0 -52
  100. data/spec/poolparty/spec/core/string_spec.rb +0 -57
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.1 2009-03-03
2
+ * Release 1.1 with new stable core
3
+
1
4
  == 1.0.0 2009-1-20
2
5
  * Released 1.0 at CitrusByte
3
6
  * Party
data/README.txt CHANGED
@@ -13,13 +13,6 @@ pool :cloud do
13
13
  end
14
14
  end
15
15
 
16
- == FEATURES/PROBLEMS:
17
-
18
- * Written in Ruby and Erlang
19
- * Written from the ground up to be extensible with plugins
20
- * Easy git-style commands to communicate with your clouds
21
- * Much much more
22
-
23
16
  == SYNOPSIS:
24
17
 
25
18
  PoolParty is written with the intention of being as application-agnostic as possible. It installs only the basic
@@ -28,6 +21,16 @@ required software to glue the cloud together on the instances as listed below.
28
21
  PoolParty is easily configuration. In fact, it makes little assumptions about your development environment and allows
29
22
  several options on how to begin configuring the cloud.
30
23
 
24
+ == WHAT NEXT:
25
+ * PoolParty::Resources - learn how to use resources in your <tt>clouds.rb</tt>
26
+
27
+ == FEATURES/PROBLEMS:
28
+
29
+ * Written in Ruby and Erlang
30
+ * Written from the ground up to be extensible with plugins
31
+ * Easy git-style commands to communicate with your clouds
32
+ * Much much more
33
+
31
34
  == REQUIREMENTS:
32
35
 
33
36
  Ruby
data/Rakefile CHANGED
@@ -51,7 +51,6 @@ end
51
51
 
52
52
  task :release => [:update_timestamp]
53
53
 
54
-
55
54
  # Generate documentation
56
55
  Rake::RDocTask.new do |rd|
57
56
  rd.main = "Readme.txt"
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 7
2
+ :minor: 2
3
+ :patch: 0
4
4
  :major: 1
data/bin/cloud-osxcopy CHANGED
@@ -4,7 +4,7 @@ require "poolparty"
4
4
  require "poolpartycl"
5
5
 
6
6
  o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
7
- opts.on('-n name', '--name name', 'Copy the master ip for this cloud') { |c| optioner.cloudname c }
7
+ opts.on('-n name', '--name name', 'Copy an ip from this cloud to the clipboard') { |c| optioner.cloudname c }
8
8
  end
9
9
 
10
10
  o.loaded_clouds.each do |cld|
data/bin/cloud-setup-dev CHANGED
@@ -13,7 +13,7 @@ o.loaded_clouds.each do |cld|
13
13
  puts "Your cloud is not running"
14
14
  else
15
15
  str =<<-EOE
16
- Host #{cld.name}-master
16
+ Host #{cld.name}
17
17
  User #{cld.user}
18
18
  Hostname #{cld.remote_instances_list.first.ip}
19
19
  IdentityFile #{cld.keypair}
data/bin/cloud-spec CHANGED
@@ -31,7 +31,6 @@ o.loaded_clouds.each do |cloud|
31
31
  when nil
32
32
  print_with_nice_printer("Starting live specing cloud #{name}")
33
33
  puts "TODO: this isn't implented yet."
34
- # hide_output {launch_and_configure_master!}
35
34
  print_with_nice_printer("Waiting for cloud to provision")
36
35
 
37
36
  end
data/bin/cloud-terminate CHANGED
@@ -5,6 +5,7 @@ require "poolpartycl"
5
5
 
6
6
  o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
7
7
  opts.on('-n name', '--name name', 'Terminate the cloud of this name') { |c| optioner.cloudname c }
8
+ opts.on('-y', '--yes', 'Terminate the cloud without prompt') { optioner.yes true }
8
9
  end
9
10
 
10
11
  o.loaded_clouds.each do |cld|
@@ -14,9 +15,14 @@ Shutting down #{inst.instance_id}
14
15
  Are you sure? (Y/N)
15
16
  EOM
16
17
 
17
- if are_you_sure?(msg)
18
+ if o.yes?
18
19
  puts "Shutting down #{inst.instance_id}"
19
20
  cld.terminate_instance!(:instance_id => inst.instance_id)
21
+ else
22
+ if are_you_sure?(msg)
23
+ puts "Shutting down #{inst.instance_id}"
24
+ cld.terminate_instance!(:instance_id => inst.instance_id)
25
+ end
20
26
  end
21
27
  end
22
28
  end
data/bin/cloud-verify ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-n cloudname', '--name name', 'Start cloud by this name') { |c| optioner.cloudname c }
7
+ opts.on('-i num', '--num i', 'Instance number') { |i| optioner.inst_num i.to_i }
8
+ end
9
+
10
+ o.loaded_clouds.each do |cld|
11
+
12
+ begin
13
+ if cld.verifiers.size > 0
14
+ cld.passing?
15
+ cld.vputs "Cloud passed verification"
16
+ else
17
+ raise "Your cloud doesn't have any verifiers!"
18
+ exit 2
19
+ end
20
+ rescue Exception => e
21
+ cld.vputs <<-EOM
22
+
23
+ Verification failed: #{e}"
24
+ Please check your clouds.rb for any errors
25
+
26
+ EOM
27
+ end
28
+
29
+ end
30
+
data/examples/basic.rb CHANGED
@@ -2,20 +2,17 @@
2
2
  # Shows global settings for the clouds
3
3
  pool :application do
4
4
  instances 3..50
5
- keypair "auser"
6
- testing true
7
-
5
+
8
6
  cloud :basic_app do
7
+
9
8
  minimum_instances 12
10
9
  ami "ami-abc123"
11
10
  junk_yard_dogs "pains"
12
11
  has_file :name => "/etc/init.d/motd", :content => "Welcome to your PoolParty instance"
13
12
  end
14
13
 
15
- cloud :basic_db do
14
+ cloud :basic_db do
16
15
  minimum_instances 19
17
- keypair "hotstuff_database"
18
- maximum_instances 20
19
16
  ami "ami-1234bc"
20
17
  junk_yard_dogs "are bad"
21
18
  end
@@ -2,30 +2,26 @@
2
2
  # Shows global settings for the clouds
3
3
  pool :application do
4
4
  instances 1..3
5
- keypair "auser-work"
6
5
  ami 'ami-7cfd1a15'
7
6
 
8
7
  cloud :example_one do
9
- # has_directory "/var/www"
10
- #
11
- # has_file "/etc/motd",
12
- # :content => "Welcome to LARubyConf"
13
- # has_file :name => "/var/www/index.html" do
14
- # content "<h1>Welcome to your new poolparty instance</h1>"
15
- # mode 0644
16
- # owner "www-data"
17
- # end
18
- #
19
- # has_git_repos "paparazzi" do
20
- # :source => "git://github.com/auser/paparazzi.git"
21
- # :at => "/var/www"
22
- # end
23
- #
24
- # chef do
25
- # include_recipes "~/.poolparty/chef/cookbooks/*"
26
- #
27
- # recipe "#{File.dirname(__FILE__)}/examples/fairchild_chef.rb"
28
- # end
8
+
9
+ has_directory "/var/www"
10
+
11
+ has_file "/etc/motd",
12
+ :content => "Welcome to LARubyConf"
13
+ has_file :name => "/var/www/index.html" do
14
+ content "<h1>Welcome to your new poolparty instance</h1>"
15
+ mode 0644
16
+ owner "www-data"
17
+ end
18
+
19
+ has_git_repos "paparazzi" do
20
+ source "git://github.com/auser/paparazzi.git"
21
+ at "/var/www"
22
+ end
23
+
24
+ apache
29
25
 
30
26
  end
31
27
 
data/examples/maize.rb ADDED
@@ -0,0 +1,37 @@
1
+ # Basic poolparty template
2
+
3
+ pool :clouds do
4
+ cloud :app do
5
+ instances 1..3
6
+ # keypair "#{ENV['HOME']}/ec2/ec2-keypair.pem" # or the full path to the keypair on the development machine
7
+ ami 'ami-7cfd1a15'
8
+ using :vmrun do
9
+ vmx_hash({
10
+ "/Users/alerner/Documents/vm/Ubuntu32bitVM.vmwarevm/Ubuntu32bitVM.vmx" => "192.168.248.133"
11
+ })
12
+ end
13
+
14
+ # directories
15
+ has_directory "/var/www"
16
+
17
+ # packages
18
+ has_package(:name => "logwatch")
19
+ has_package(:name => "imagemagick")
20
+ has_package(:name => "libmagick9-dev")
21
+ has_package(:name => "librmagick-ruby")
22
+ has_package(:name => "ffmpeg")
23
+ has_package(:name => "monit")
24
+
25
+ # gems
26
+ has_gem_package(:name => "rmagick")
27
+ has_gem_package(:name => "rubyist-aasm")
28
+ has_gem_package(:name => "rvideo")
29
+ has_gem_package(:name => "right_aws")
30
+ has_gem_package(:name => "ap4r")
31
+ has_gem_package(:name => "rmagick")
32
+
33
+ # services
34
+ has_service(:name => "monit")
35
+ end
36
+
37
+ end
@@ -7,7 +7,7 @@ module PoolParty
7
7
 
8
8
  def enable
9
9
  # has_chef_recipe "apache2"
10
- include_chef_recipe "#{::File.dirname(__FILE__)}/../../../vendor/chef/apache2"
10
+ # include_chef_recipe "#{::File.dirname(__FILE__)}/../../../vendor/chef/apache2"
11
11
 
12
12
  # Restart sysklogd after we update the haproxy.log
13
13
  has_service(:name => "sysklogd")
@@ -28,11 +28,11 @@ module PoolParty
28
28
  end
29
29
 
30
30
  has_directory "/var/run/haproxy"
31
- has_package "apache2"
32
- has_service "apache2"
31
+ # has_package "apache2"
32
+ # has_service "apache2"
33
33
 
34
34
  has_package "haproxy" do
35
- stops get_service("apache2"), :immediately
35
+ # stops get_service("apache2"), :immediately
36
36
  # starts get_service("apache2")
37
37
  end
38
38
 
@@ -49,8 +49,8 @@ module PoolParty
49
49
  # Service is required
50
50
  has_service("haproxy") do
51
51
  action [:start, :enable]
52
- stops get_service("apache2"), :immediately
53
- starts get_service("apache2")
52
+ # stops get_service("apache2"), :immediately
53
+ # starts get_service("apache2")
54
54
  end
55
55
 
56
56
  end
@@ -3,53 +3,11 @@ module PoolParty
3
3
  plugin :poolparty_base_heartbeat do
4
4
 
5
5
  def enable
6
- # execute_on_master do
6
+
7
7
  has_package({:name => "heartbeat-2"})
8
8
  has_package({:name => "heartbeat-2-dev"})
9
9
 
10
10
  has_service("heartbeat")
11
-
12
- # has_service(:name => "heartbeat", :hasstatus => true, :hasrestart => true)
13
- # has_directory(:name => "/etc/ha.d")
14
- #
15
- # has_remotefile(:name => "/etc/ha.d/ha.cf") do
16
- # mode 444
17
- # notify service(:name => "heartbeat")
18
- # template "ha.cf"
19
- # end
20
- #
21
- # has_remotefile(:name => "/etc/ha.d/logd.cf") do
22
- # mode 600
23
- # notify service(:name => "heartbeat")
24
- # template File.join(File.dirname(__FILE__), "..", "templates/logd.cf")
25
- # end
26
- #
27
- # has_exec(:name => "heartbeat-update-cib", :command => "/usr/sbin/cibadmin -R -x /etc/ha.d/cib.xml", :refreshonly => true)
28
- #
29
- # has_remotefile(:name => "/etc/ha.d/authkeys") do
30
- # mode 600
31
- # notify service(:name => "heartbeat")
32
- # template File.join(File.dirname(__FILE__), "..", "templates/authkeys")
33
- # end
34
- #
35
- # has_remotefile(:name => "/etc/ha.d/cib.xml") do
36
- # mode 444
37
- # notify exec(:name => "heartbeat-update-cib")
38
- # template File.join(File.dirname(__FILE__), "..", "templates/cib.xml")
39
- # end
40
- #
41
- # has_remotefile(:name => "/etc/ha.d/haresources") do
42
- # mode 644
43
- # template File.join(File.dirname(__FILE__), "..", "templates/haresources")
44
- # end
45
- # # end
46
- #
47
- # # variables for the templates
48
- # has_variable(:name => "ha_nodenames", :value => "generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'name', '-n', '#{cloud.name}')")
49
- # has_variable(:name => "ha_node_ips", :value => "generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'ip', '-n', '#{cloud.name}')")
50
- #
51
- # has_variable({:name => "ha_timeout", :value => (self.respond_to?(:timeout) ? timeout : "5s")})
52
- # has_variable({:name => "ha_port", :value => (self.respond_to?(:port) ? port : Default.port)})
53
11
 
54
12
  end
55
13
 
@@ -2,9 +2,7 @@ module PoolParty
2
2
  class Base
3
3
  plugin :poolparty_base_packages do
4
4
 
5
- def enable
6
- has_package "git-core"
7
-
5
+ def enable
8
6
  has_cron "/usr/bin/server-manage-election" do
9
7
  minute "0,5,10,15,20,25,30,35,40,45,50,55"
10
8
  command "/usr/bin/server-manage-election"
@@ -18,9 +18,17 @@ module PoolParty
18
18
  end
19
19
 
20
20
  # Enable a service package
21
- def enable(service);dsl_options[service] = :enabled;end
21
+ def enable(*services)
22
+ services.each do |service|
23
+ dsl_options[service] = :enabled
24
+ end
25
+ end
22
26
  # Disable a service package
23
- def disable(service);dsl_options[service] = :disabled;end
27
+ def disable(*services)
28
+ services.each do |service|
29
+ dsl_options[service] = :disabled
30
+ end
31
+ end
24
32
 
25
33
  # Check to see if the package has been enabled
26
34
  def enabled?(srv);dsl_options.has_key?(srv) && dsl_options[srv] == :enabled;end
@@ -54,10 +54,6 @@ module PoolParty
54
54
  raise SpecException.new("Don't know how to handle instances cloud input #{arg}")
55
55
  end
56
56
  end
57
-
58
- def setup_dev
59
- return true if keypair || master.nil?
60
- end
61
57
 
62
58
  # Declare the remoter base
63
59
  # Check to make sure the available_bases is available, otherwise raise
@@ -1,5 +1,5 @@
1
1
  # Load the core net libraries. These are neccessary for any of the remoter_bases to function.
2
- %w(remote_instance messenger remote_bases remoter_base).each do |file|
2
+ %w(remote_instance remote_bases remoter_base).each do |file|
3
3
  require File.join(::File.dirname(__FILE__),file+'.rb')
4
4
  end
5
5
 
@@ -20,12 +20,6 @@ module PoolParty
20
20
  def on_init
21
21
  end
22
22
 
23
- # Is this remote instance the master?
24
- # DEPRECATE
25
- def master?
26
- name == "master"
27
- end
28
-
29
23
  # The remote instances is only valid if there is an ip and a name
30
24
  def valid?
31
25
  (ip.nil? || name.nil?) ? false : true
@@ -78,27 +72,6 @@ module PoolParty
78
72
  new(hsh).to_s
79
73
  end
80
74
 
81
- #TODO: Diet the next 5 commands
82
- def dependency_resolver_command
83
- cloud.dependency_resolver_command
84
- end
85
-
86
- #FIXME: deprecate puppet specific commands in this class
87
- def puppet_runner_command
88
- self.class.send :puppet_runner_command
89
- end
90
- # Commands for the servers
91
- def self.puppet_runner_command
92
- ". /etc/profile && puppetrunner"
93
- end
94
- def self.puppet_master_rerun_command
95
- ". /etc/profile && puppetrerun"
96
- end
97
- def self.puppet_rerun_commad
98
- puppet_runner_command
99
- end
100
- #
101
-
102
75
  def hosts_file_listing_for(cl)
103
76
  string = (cl.name == cloud.name) ? "#{name}.#{my_cloud.name}\t#{name}" : "#{name}.#{my_cloud.name}"
104
77
  "#{internal_ip}\t#{string}"
@@ -11,179 +11,6 @@ module PoolParty
11
11
  def are_too_many_instances_running?
12
12
  nodes(:status => "running").size > maximum_instances.to_i
13
13
  end
14
-
15
-
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
187
14
 
188
15
  def list_of_nodes_exceeding_minimum_runtime
189
16
  nodes(:status => "running").reject{|i| i.elapsed_runtime < minimum_runtime}
@@ -192,10 +19,6 @@ module PoolParty
192
19
  def are_any_nodes_exceeding_minimum_runtime?
193
20
  !list_of_nodes_exceeding_minimum_runtime.blank?
194
21
  end
195
- # Is there a node that is running with the name master
196
- def is_master_running?
197
- !nodes(:status => "running").select {|a| a.name == "master"}.first.nil?
198
- end
199
22
 
200
23
  end
201
24
  end