poolparty 0.0.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/History.txt +25 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +203 -0
  4. data/PostInstall.txt +18 -0
  5. data/README.txt +21 -82
  6. data/Rakefile +25 -18
  7. data/bin/cloud +31 -0
  8. data/bin/cloud-add-keypair +23 -0
  9. data/bin/cloud-configure +31 -0
  10. data/bin/cloud-contract +27 -0
  11. data/bin/cloud-expand +27 -0
  12. data/bin/cloud-list +32 -0
  13. data/bin/cloud-maintain +36 -0
  14. data/bin/cloud-osxcopy +22 -0
  15. data/bin/cloud-provision +31 -0
  16. data/bin/cloud-refresh +26 -0
  17. data/bin/cloud-ssh +18 -0
  18. data/bin/cloud-start +32 -0
  19. data/bin/cloud-terminate +23 -0
  20. data/bin/pool +25 -27
  21. data/bin/pool-console +12 -0
  22. data/bin/pool-describe +9 -0
  23. data/bin/pool-list +28 -0
  24. data/bin/pool-provision +34 -0
  25. data/bin/pool-spec +17 -0
  26. data/bin/pool-start +32 -0
  27. data/bin/pool-start-monitor +1 -0
  28. data/config/hoe.rb +115 -0
  29. data/config/requirements.rb +15 -0
  30. data/examples/basic.rb +20 -0
  31. data/examples/plugin_without_plugin_directory.rb +13 -0
  32. data/examples/poolparty.rb +12 -0
  33. data/examples/with_apache_plugin.rb +22 -0
  34. data/generators/poolspec/USAGE +5 -0
  35. data/generators/poolspec/poolspec_generator.rb +65 -0
  36. data/generators/poolspec/templates/pool_spec_template.erb +9 -0
  37. data/lib/erlang/eb_server.erl +27 -0
  38. data/lib/poolparty.rb +56 -0
  39. data/lib/poolparty/base_packages/haproxy.rb +42 -0
  40. data/lib/poolparty/base_packages/heartbeat.rb +45 -0
  41. data/lib/poolparty/base_packages/poolparty.rb +36 -0
  42. data/lib/poolparty/base_packages/ruby.rb +43 -0
  43. data/lib/poolparty/core/array.rb +24 -0
  44. data/lib/{core → poolparty/core}/exception.rb +0 -0
  45. data/lib/poolparty/core/float.rb +13 -0
  46. data/lib/poolparty/core/hash.rb +29 -0
  47. data/lib/poolparty/core/kernel.rb +37 -0
  48. data/lib/{core → poolparty/core}/module.rb +18 -0
  49. data/lib/poolparty/core/my_open_struct.rb +18 -0
  50. data/lib/poolparty/core/object.rb +54 -0
  51. data/lib/poolparty/core/proc.rb +7 -0
  52. data/lib/poolparty/core/string.rb +72 -0
  53. data/lib/poolparty/core/symbol.rb +8 -0
  54. data/lib/{core → poolparty/core}/time.rb +15 -0
  55. data/lib/poolparty/exceptions/RemoteException.rb +12 -0
  56. data/lib/poolparty/exceptions/ResourceException.rb +7 -0
  57. data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
  58. data/lib/poolparty/exceptions/SpecException.rb +7 -0
  59. data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
  60. data/lib/poolparty/helpers/binary.rb +31 -0
  61. data/lib/poolparty/helpers/console.rb +30 -0
  62. data/lib/poolparty/helpers/display.rb +34 -0
  63. data/lib/poolparty/helpers/optioner.rb +64 -0
  64. data/lib/poolparty/helpers/provisioner_base.rb +250 -0
  65. data/lib/poolparty/helpers/provisioners/master.rb +136 -0
  66. data/lib/poolparty/helpers/provisioners/slave.rb +44 -0
  67. data/lib/poolparty/modules/cloud_resourcer.rb +89 -0
  68. data/lib/poolparty/modules/configurable.rb +34 -0
  69. data/lib/poolparty/modules/definable_resource.rb +59 -0
  70. data/lib/poolparty/modules/file_writer.rb +55 -0
  71. data/lib/poolparty/modules/method_missing_sugar.rb +53 -0
  72. data/lib/poolparty/modules/output.rb +13 -0
  73. data/lib/poolparty/modules/pretty_printer.rb +39 -0
  74. data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -22
  75. data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
  76. data/lib/poolparty/monitors/base_monitor.rb +16 -0
  77. data/lib/poolparty/net/remote.rb +35 -0
  78. data/lib/poolparty/net/remote_bases/ec2.rb +148 -0
  79. data/lib/poolparty/net/remote_instance.rb +69 -0
  80. data/lib/poolparty/net/remoter.rb +224 -0
  81. data/lib/poolparty/net/remoter_base.rb +117 -0
  82. data/lib/poolparty/plugins/gem_package.rb +17 -0
  83. data/lib/poolparty/plugins/git.rb +41 -0
  84. data/lib/poolparty/plugins/line.rb +76 -0
  85. data/lib/poolparty/plugins/svn.rb +48 -0
  86. data/lib/poolparty/pool/base.rb +75 -0
  87. data/lib/poolparty/pool/cloud.rb +164 -0
  88. data/lib/poolparty/pool/custom_resource.rb +61 -0
  89. data/lib/poolparty/pool/loggable.rb +29 -0
  90. data/lib/poolparty/pool/plugin.rb +41 -0
  91. data/lib/poolparty/pool/plugin_model.rb +48 -0
  92. data/lib/poolparty/pool/pool.rb +55 -0
  93. data/lib/poolparty/pool/resource.rb +248 -0
  94. data/lib/poolparty/pool/resources/class_package.rb +64 -0
  95. data/lib/poolparty/pool/resources/conditional.rb +41 -0
  96. data/lib/poolparty/pool/resources/cron.rb +14 -0
  97. data/lib/poolparty/pool/resources/directory.rb +23 -0
  98. data/lib/poolparty/pool/resources/exec.rb +26 -0
  99. data/lib/poolparty/pool/resources/file.rb +23 -0
  100. data/lib/poolparty/pool/resources/gem.rb +14 -0
  101. data/lib/poolparty/pool/resources/host.rb +14 -0
  102. data/lib/poolparty/pool/resources/package.rb +14 -0
  103. data/lib/poolparty/pool/resources/remote_file.rb +22 -0
  104. data/lib/poolparty/pool/resources/service.rb +21 -0
  105. data/lib/poolparty/pool/resources/sshkey.rb +19 -0
  106. data/lib/poolparty/pool/resources/variable.rb +27 -0
  107. data/lib/poolparty/pool/script.rb +44 -0
  108. data/lib/poolparty/templates/authkeys +2 -0
  109. data/{config/monit/nginx.monit.conf → lib/poolparty/templates/cib.xml} +0 -0
  110. data/lib/poolparty/templates/fileserver.conf +4 -0
  111. data/lib/poolparty/templates/gem +25 -0
  112. data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -2
  113. data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
  114. data/lib/poolparty/templates/namespaceauth.conf +19 -0
  115. data/lib/poolparty/templates/puppet.conf +17 -0
  116. data/lib/poolparty/version.rb +9 -0
  117. data/lib/poolpartycl.rb +3 -0
  118. data/poolparty.gemspec +56 -47
  119. data/script/destroy +14 -0
  120. data/script/generate +14 -0
  121. data/script/txt2html +82 -0
  122. data/setup.rb +1585 -0
  123. data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
  124. data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
  125. data/spec/poolparty/bin/console_spec.rb +80 -0
  126. data/spec/poolparty/core/array_spec.rb +26 -0
  127. data/spec/poolparty/core/float.rb +13 -0
  128. data/spec/poolparty/core/hash_spec.rb +63 -0
  129. data/spec/poolparty/core/kernel_spec.rb +24 -0
  130. data/spec/poolparty/core/module_spec.rb +15 -0
  131. data/spec/poolparty/core/object_spec.rb +40 -0
  132. data/spec/poolparty/core/string_spec.rb +152 -0
  133. data/spec/poolparty/core/time_spec.rb +52 -0
  134. data/spec/poolparty/helpers/binary_spec.rb +26 -0
  135. data/spec/poolparty/helpers/display_spec.rb +13 -0
  136. data/spec/poolparty/helpers/optioner_spec.rb +39 -0
  137. data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
  138. data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
  139. data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
  140. data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
  141. data/spec/poolparty/modules/configurable_spec.rb +26 -0
  142. data/spec/poolparty/modules/definable_resource.rb +9 -0
  143. data/spec/poolparty/modules/file_writer_spec.rb +49 -0
  144. data/spec/poolparty/modules/s3_string_spec.rb +15 -0
  145. data/spec/poolparty/modules/tmp/willy/nilly.rb +1 -0
  146. data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
  147. data/spec/poolparty/net/remote_instance_spec.rb +70 -0
  148. data/spec/poolparty/net/remote_spec.rb +286 -0
  149. data/spec/poolparty/net/remoter_base_spec.rb +80 -0
  150. data/spec/poolparty/net/remoter_spec.rb +191 -0
  151. data/spec/poolparty/plugins/git_spec.rb +33 -0
  152. data/spec/poolparty/plugins/line_spec.rb +16 -0
  153. data/spec/poolparty/plugins/svn_spec.rb +16 -0
  154. data/spec/poolparty/pool/base_spec.rb +108 -0
  155. data/spec/poolparty/pool/cloud_spec.rb +299 -0
  156. data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
  157. data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
  158. data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
  159. data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
  160. data/spec/poolparty/pool/example_spec.rb +112 -0
  161. data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
  162. data/spec/poolparty/pool/plugin_spec.rb +85 -0
  163. data/spec/poolparty/pool/pool_spec.rb +83 -0
  164. data/spec/poolparty/pool/resource_spec.rb +224 -0
  165. data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
  166. data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
  167. data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
  168. data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
  169. data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
  170. data/spec/poolparty/pool/resources/file_spec.rb +40 -0
  171. data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
  172. data/spec/poolparty/pool/resources/host_spec.rb +28 -0
  173. data/spec/poolparty/pool/resources/package_spec.rb +44 -0
  174. data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
  175. data/spec/poolparty/pool/resources/service_spec.rb +45 -0
  176. data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
  177. data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
  178. data/spec/poolparty/pool/script_spec.rb +51 -0
  179. data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
  180. data/{test/test_pool_party.rb → spec/poolparty/pool/test_plugins/virtual_host_template.erb} +0 -0
  181. data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
  182. data/spec/poolparty/poolparty_spec.rb +33 -0
  183. data/spec/poolparty/spec_helper.rb +120 -0
  184. data/tasks/cloud.rake +57 -0
  185. data/tasks/deployment.rake +34 -0
  186. data/tasks/development.rake +78 -0
  187. data/tasks/ec2.rake +20 -0
  188. data/tasks/environment.rake +7 -0
  189. data/tasks/instance.rake +63 -0
  190. data/tasks/server.rake +42 -0
  191. data/tasks/spec.rake +17 -0
  192. data/tasks/website.rake +17 -0
  193. data/test/test_generator_helper.rb +29 -0
  194. data/test/test_helper.rb +2 -0
  195. data/test/test_pool_spec_generator.rb +47 -0
  196. data/test/test_poolparty.rb +11 -0
  197. data/test_manifest.pp +538 -0
  198. data/website/index.html +107 -0
  199. data/website/index.txt +95 -0
  200. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  201. data/website/stylesheets/code.css +29 -0
  202. data/website/stylesheets/screen.css +147 -0
  203. data/website/template.html.erb +49 -0
  204. metadata +282 -101
  205. data/CHANGELOG +0 -4
  206. data/Manifest +0 -55
  207. data/bin/instance +0 -54
  208. data/config/config.yml +0 -23
  209. data/config/create_proxy_ami.sh +0 -582
  210. data/config/heartbeat_authkeys.conf +0 -2
  211. data/config/monit.conf +0 -8
  212. data/config/monit/haproxy.monit.conf +0 -7
  213. data/config/nginx.conf +0 -24
  214. data/lib/core/array.rb +0 -10
  215. data/lib/core/kernel.rb +0 -9
  216. data/lib/core/object.rb +0 -14
  217. data/lib/modules/callback.rb +0 -55
  218. data/lib/modules/ec2_wrapper.rb +0 -74
  219. data/lib/pool_party.rb +0 -69
  220. data/lib/pool_party/application.rb +0 -133
  221. data/lib/pool_party/init.rb +0 -4
  222. data/lib/pool_party/master.rb +0 -189
  223. data/lib/pool_party/monitors.rb +0 -13
  224. data/lib/pool_party/monitors/cpu.rb +0 -18
  225. data/lib/pool_party/monitors/memory.rb +0 -21
  226. data/lib/pool_party/monitors/web.rb +0 -18
  227. data/lib/pool_party/optioner.rb +0 -16
  228. data/lib/pool_party/os.rb +0 -11
  229. data/lib/pool_party/os/ubuntu.rb +0 -78
  230. data/lib/pool_party/remote_instance.rb +0 -180
  231. data/lib/pool_party/remoting.rb +0 -112
  232. data/lib/pool_party/scheduler.rb +0 -93
  233. data/lib/pool_party/tasks.rb +0 -220
  234. data/lib/s3/s3_object_store_folders.rb +0 -44
  235. data/spec/application_spec.rb +0 -32
  236. data/spec/callback_spec.rb +0 -65
  237. data/spec/helpers/ec2_mock.rb +0 -56
  238. data/spec/helpers/remote_instance_mock.rb +0 -11
  239. data/spec/kernel_spec.rb +0 -11
  240. data/spec/master_spec.rb +0 -147
  241. data/spec/monitor_spec.rb +0 -16
  242. data/spec/optioner_spec.rb +0 -22
  243. data/spec/poolparty_spec.rb +0 -8
  244. data/spec/remote_instance_spec.rb +0 -29
  245. data/spec/remoting_spec.rb +0 -75
  246. data/spec/spec_helper.rb +0 -38
  247. data/spec/string_spec.rb +0 -28
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
7
+ end
8
+ load_pool(o.spec || Binary.get_existing_spec_location)
9
+
10
+ @location = o.location ? o.location : "remote"
11
+
12
+ include Remote
13
+
14
+ @clouds = o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : clouds
15
+
16
+ @clouds.each do |name, cloud|
17
+
18
+ with_cloud(cloud, {:location => @location}) do
19
+ logger.info header("Creating keypair for #{name}")
20
+ create_keypair unless testing
21
+ end
22
+
23
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-c [master|slaves|all]', '--class [master|slaves|all]', 'Provision class (default: all)') { |c| optioner.provision_class c }
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ end
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @provision_class = o.provision_class || "all"
12
+
13
+ include Remote
14
+
15
+ @clouds = o.cloudname ? {:cloud => cloud(o.cloudname.downcase.to_sym)} : clouds
16
+
17
+ @clouds.each do |name, cloud|
18
+
19
+ with_cloud(cloud, {:testing => o.testing, :location => @location, :provision_class => @provision_class}) do
20
+
21
+ hide_output do
22
+ if provision_class == "master" || provision_class == "all"
23
+ Provisioner.configure_master(self, testing)
24
+ end
25
+ if provision_class == "slave" || provision_class == "all"
26
+ Provisioner.configure_slaves(self, testing)
27
+ end
28
+ end
29
+ clear_base_directory unless testing
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
6
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ end
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @testing = o.testing
12
+
13
+ include Remote
14
+
15
+ begin
16
+ @cloud = cloud(o.cloudname.downcase.to_sym)
17
+ rescue
18
+ puts "Cloud name required. Please specify it with -n name"
19
+ exit(0)
20
+ end
21
+
22
+ with_cloud(@cloud, {:testing => @testing}) do
23
+ puts header("Contracting cloud #{name}")
24
+ puts "#{list_of_running_instances.size} running instances (#{minimum_instances} minimum instances)"
25
+ puts testing ? "Not contracting (test mode)" : "Contracting the cloud if possible"
26
+ contract_cloud_if_necessary( !testing )
27
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
6
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ end
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @testing = o.testing
12
+
13
+ include Remote
14
+
15
+ begin
16
+ @cloud = cloud(o.cloudname.downcase.to_sym)
17
+ rescue
18
+ puts "Cloud name required. Please specify it with -n name"
19
+ exit(0)
20
+ end
21
+
22
+ with_cloud(@cloud, {:testing => @testing}) do
23
+ puts header("Expanding cloud #{name}")
24
+ puts "#{list_of_running_instances.size} running instances of #{maximum_instances} possible instances"
25
+ puts testing ? "Not expanding (test mode)" : "Expanding the cloud"
26
+ expand_cloud_if_necessary( !testing )
27
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-f [remote|local]', '--from [remote|local]', 'Remote or local (default: local)') { |o| optioner.location o }
7
+ opts.on('-r', '--remote', 'Remote listing') { optioner.location "remote" }
8
+ opts.on('-l', '--local', 'Local listing') { optioner.location "local" }
9
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
10
+ end
11
+ load_pool(o.spec || Binary.get_existing_spec_location)
12
+
13
+ @location = o.location ? o.location : "remote"
14
+
15
+ include Remote
16
+
17
+ @clouds = o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : clouds
18
+
19
+ @clouds.each do |name, cloud|
20
+
21
+ with_cloud(cloud, {:location => @location}) do
22
+ puts header("Listing cloud #{name}")
23
+ puts subheader("Active instances")
24
+ puts list_of_running_instances.map{|a| a.to_s}.join("\n")
25
+ puts ""
26
+ if list_of_pending_instances.size > 0
27
+ puts subheader("Pending instances")
28
+ puts list_of_pending_instances.map{|a| a.to_s}.join("\n")
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-f [remote|local]', '--from [remote|local]', 'Remote or local (default: local)') { |o| optioner.location o }
7
+ opts.on('-r', '--remote', 'Remote listing') { optioner.location "remote" }
8
+ opts.on('-l', '--local', 'Local listing') { optioner.location "local" }
9
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
10
+ end
11
+ load_pool(o.spec || Binary.get_existing_spec_location)
12
+
13
+ @location = o.location ? o.location : "remote"
14
+
15
+ include Remote
16
+
17
+ @clouds = o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : clouds
18
+
19
+ @clouds.each do |name, cloud|
20
+
21
+ with_cloud(cloud, {:location => @location, :testing => o.testing}) do
22
+ logger.info header("Maintaining cloud #{name}")
23
+ if !minimum_number_of_instances_are_running?
24
+ logger.warn "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
25
+ logger.warn "Launching new instance"
26
+ expand_cloud_if_necessary( !testing )
27
+ elsif !maximum_number_of_instances_are_not_running?
28
+ logger.warn "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
29
+ logger.warn "Shutting down non-master instance"
30
+ contract_cloud_if_necessary( !testing )
31
+ else
32
+ logger.info "Cloud is maintained"
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
7
+ end
8
+ load_pool(o.spec || Binary.get_existing_spec_location)
9
+
10
+ @location = o.location ? o.location : "remote"
11
+
12
+ include Remote
13
+
14
+ @clouds = o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : clouds
15
+
16
+ @clouds.each do |name, cloud|
17
+
18
+ with_cloud(cloud, {:location => @location}) do
19
+ Kernel.system "echo #{master.ip.chomp} | pbcopy"
20
+ end
21
+
22
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-c [master|slaves|all]', '--class [master|slaves|all]', 'Provision class (default: all)') { |c| optioner.provision_class c }
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ end
9
+
10
+ load_pool(o.spec || Binary.get_existing_spec_location)
11
+
12
+ @provision_class = o.provision_class || "all"
13
+
14
+ include Remote
15
+
16
+ @clouds = o.cloudname ? {:cloud => cloud(o.cloudname.downcase.to_sym)} : clouds
17
+
18
+ @clouds.each do |name, cloud|
19
+
20
+ with_cloud(cloud, {:testing => o.testing, :location => @location, :provision_class => @provision_class}) do
21
+
22
+ if provision_class == "master" || provision_class == "all"
23
+ Provisioner.provision_master(self, testing)
24
+ end
25
+ if provision_class == "slave" || provision_class == "all"
26
+ Provisioner.provision_slaves(self, testing)
27
+ end
28
+
29
+ clear_base_directory unless testing
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
6
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ end
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @provision_class = o.provision_class || "all"
12
+
13
+ include Remote
14
+
15
+ @clouds = o.cloudname ? {:cloud => cloud(o.cloudname.downcase.to_sym)} : clouds
16
+
17
+ @clouds.each do |name, cloud|
18
+
19
+ with_cloud(cloud, {:testing => o.testing}) do
20
+ cmd = <<-EOE
21
+ puppetrun --host #{list_of_node_names.join(", --host ")}
22
+ EOE
23
+ run_command_on(cmd.runnable, master)
24
+ end
25
+
26
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
7
+ opts.on('-i num', '--id num', 'Instance num to ssh (default: 0)') { |i| optioner.num i }
8
+ end
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ unless o.cloudname && clouds.keys.size > 1
12
+ @cloud = cloud(o.cloudname.downcase.to_sym)
13
+ else
14
+ puts "Error: You must indicate a cloud from which your instance is from"
15
+ exit(0)
16
+ end
17
+
18
+ instance = @cloud.ssh_into_instance_number( o.num.to_i || 0 )
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-c cloudname', '--cloud name', 'Start cloud by this name') { |c| optioner.cloudname c }
7
+ end
8
+
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @testing = o.testing
12
+
13
+ @clouds = o.cloudname ? {:cloud => cloud(o.cloudname.downcase.to_sym)} : clouds
14
+
15
+ @clouds.each do |name, cloud|
16
+
17
+ with_cloud(cloud, {:testing => @testing}) do
18
+ puts header("Starting cloud")
19
+ puts "#{list_of_running_instances.size} running instances (#{minimum_instances} - #{maximum_instances})"
20
+ if (minimum_instances - list_of_running_instances.size) > 0
21
+ puts "Starting the master instance"
22
+ if testing
23
+ puts("\tNot launching while in testing mode")
24
+ else
25
+ launch_and_configure_master!
26
+ # run_command_on("puppetd --test", master)
27
+ end
28
+ end
29
+ clear_base_directory unless testing
30
+ end
31
+
32
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-c [master|slaves|all]', '--class [master|slaves|all]', 'Provision class (default: all)') { |c| optioner.provision_class c }
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ end
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @clouds = o.cloudname ? {:cloud => cloud(o.cloudname.downcase.to_sym)} : clouds
12
+
13
+ @clouds.each do |name, cloud|
14
+
15
+ with_cloud(cloud, {:testing => o.testing, :location => @location, :provision_class => @provision_class}) do
16
+
17
+ list_of_running_instances.each do |inst|
18
+ puts "Shutting down #{inst.instance_id}"
19
+ terminate_instance!(inst.instance_id)
20
+ end
21
+
22
+ end
23
+ end
data/bin/pool CHANGED
@@ -1,33 +1,31 @@
1
1
  #!/usr/bin/ruby
2
- require 'rubygems'
3
- require 'pool_party'
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
4
5
 
5
- # Set defaults
6
- list = PoolParty::Optioner.parse(ARGV.dup)
7
- options = PoolParty::Application.options(ARGV.dup)
8
- master = PoolParty::Master.new
9
-
10
- # if list.empty?
11
- # puts "Usage: pool [options] {start|stop|list|maintain}"
12
- # exit
6
+ # Get the git-style program action
7
+ # o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
8
+ # opts.on('-n [name]','--name [name]', 'Binary to run') { |o| optioner.name o }
13
9
  # end
14
10
 
15
- case list[0]
16
- when "start"
17
- PoolParty.message "Starting cloud"
18
- master.start_cloud!
19
- when "stop"
20
- PoolParty.message "Stopping cloud"
21
- master.request_termination_of_all_instances
22
- when "list"
23
- puts master.list
24
- when "maintain"
25
- PoolParty.message "Maintaining cloud"
26
- master.start_monitor!
27
- when "restart"
28
- PoolParty.message "Restarting cloud"
29
- master.request_termination_of_all_instances
30
- master.start_cloud!
11
+ name = ARGV.shift
12
+
13
+ # If there was no program action given
14
+ if !name || name == "-h" || name == "--help"
15
+ puts "Usage: pool <specfile> <action> <options>"
16
+ puts "Pool actions:"
17
+ puts Binary.list_binaries_for("pool")
18
+ exit
19
+ end
20
+
21
+ program_name = "#{File.basename($0)}-#{name}"
22
+ program_location = File.join(Binary.binary_directory, program_name)
23
+
24
+ command_line = "#{program_location} #{ARGV.join(" ")}"
25
+
26
+ # Run it from the command-line first
27
+ if Binary.available_binaries_for("pool").include?(name)
28
+ Kernel.exec "#{command_line}"
31
29
  else
32
- puts master.list
30
+ puts "Unknown poolparty binary: #{program_name}"
33
31
  end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/poolparty.rb'}"
9
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/poolpartycl.rb'}"
10
+ puts "Loading PoolParty console..."
11
+
12
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
6
+ o = PoolParty::Optioner.new(ARGV)
7
+ load_pool(o.spec || Binary.get_existing_spec_location)
8
+
9
+ puts pool_describe
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-f [remote|local]', '--from [remote|local]', 'Remote or local (default: local)') { |o| optioner.location o }
7
+ opts.on('-r', '--remote', 'Remote listing') { optioner.location "remote" }
8
+ opts.on('-l', '--local', 'Local listing') { optioner.location "local" }
9
+ opts.on('-n name', '--name name', 'Listing for pool name') { |p| optioner.poolname p }
10
+ end
11
+ load_pool(o.spec || Binary.get_existing_spec_location)
12
+
13
+ @location = o.location ? o.location : "remote"
14
+
15
+ include Remote
16
+
17
+ @pools = o.poolname ? [pool(o.poolname.downcase.to_sym)] : pools
18
+
19
+ @pools.each do |name, pool|
20
+ with_pool(pool, {:location => @location}) do
21
+ puts header("Listing pool #{name}")
22
+ clouds.each do |name, cloud|
23
+ puts subheader("Cloud: #{name}")
24
+ out = location == "remote" ? cloud.list_from_remote({:cache => true}).map{|a| a.to_s} : cloud.list_from_local.map{|a| a.to_s}
25
+ puts out
26
+ end
27
+ end
28
+ end