auser-poolparty 0.1.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/History.txt +22 -0
  2. data/License.txt +20 -0
  3. data/README.txt +52 -0
  4. data/Rakefile +4 -109
  5. data/bin/cloud +31 -0
  6. data/bin/cloud-add-keypair +23 -0
  7. data/bin/cloud-configure +35 -0
  8. data/bin/cloud-contract +27 -0
  9. data/bin/cloud-expand +27 -0
  10. data/bin/cloud-list +32 -0
  11. data/bin/cloud-maintain +36 -0
  12. data/bin/cloud-provision +30 -0
  13. data/bin/cloud-reconfigure +24 -0
  14. data/bin/cloud-ssh +18 -0
  15. data/bin/cloud-start +29 -0
  16. data/bin/pool +23 -75
  17. data/bin/pool-console +12 -0
  18. data/bin/pool-describe +9 -0
  19. data/bin/pool-list +28 -0
  20. data/bin/pool-provision +34 -0
  21. data/bin/pool-spec +17 -0
  22. data/bin/pool-start +32 -0
  23. data/examples/basic.rb +20 -0
  24. data/examples/plugin_without_plugin_directory.rb +13 -0
  25. data/examples/poolparty.rb +12 -0
  26. data/examples/with_apache_plugin.rb +22 -0
  27. data/generators/poolspec/USAGE +5 -0
  28. data/generators/poolspec/poolspec_generator.rb +65 -0
  29. data/generators/poolspec/templates/pool_spec_template.erb +9 -0
  30. data/lib/erlang/eb_server.erl +27 -0
  31. data/lib/poolparty.rb +40 -116
  32. data/lib/poolparty/base_packages/haproxy.rb +41 -0
  33. data/lib/poolparty/base_packages/heartbeat.rb +43 -0
  34. data/lib/poolparty/base_packages/poolparty.rb +18 -0
  35. data/lib/poolparty/base_packages/ruby.rb +27 -0
  36. data/lib/poolparty/core/array.rb +24 -0
  37. data/lib/{core → poolparty/core}/exception.rb +0 -0
  38. data/lib/{core → poolparty/core}/float.rb +0 -0
  39. data/lib/poolparty/core/hash.rb +29 -0
  40. data/lib/poolparty/core/kernel.rb +34 -0
  41. data/lib/{core → poolparty/core}/module.rb +18 -0
  42. data/lib/poolparty/core/my_open_struct.rb +18 -0
  43. data/lib/poolparty/core/object.rb +54 -0
  44. data/lib/poolparty/core/proc.rb +2 -0
  45. data/lib/poolparty/core/string.rb +72 -0
  46. data/lib/poolparty/core/symbol.rb +8 -0
  47. data/lib/{core → poolparty/core}/time.rb +15 -0
  48. data/lib/poolparty/exceptions/RemoteException.rb +12 -0
  49. data/lib/poolparty/exceptions/ResourceException.rb +7 -0
  50. data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
  51. data/lib/poolparty/exceptions/SpecException.rb +7 -0
  52. data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
  53. data/lib/poolparty/helpers/binary.rb +30 -0
  54. data/lib/poolparty/helpers/console.rb +30 -0
  55. data/lib/poolparty/helpers/display.rb +25 -0
  56. data/lib/poolparty/helpers/optioner.rb +61 -0
  57. data/lib/poolparty/helpers/provisioner_base.rb +226 -0
  58. data/lib/poolparty/helpers/provisioners/master.rb +120 -0
  59. data/lib/poolparty/helpers/provisioners/slave.rb +52 -0
  60. data/lib/poolparty/modules/cloud_resourcer.rb +72 -0
  61. data/lib/poolparty/modules/configurable.rb +34 -0
  62. data/lib/poolparty/modules/definable_resource.rb +59 -0
  63. data/lib/poolparty/modules/file_writer.rb +55 -0
  64. data/lib/poolparty/modules/method_missing_sugar.rb +17 -0
  65. data/lib/poolparty/modules/output.rb +13 -0
  66. data/lib/poolparty/modules/pretty_printer.rb +38 -0
  67. data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -29
  68. data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
  69. data/lib/poolparty/monitors/base_monitor.rb +16 -0
  70. data/lib/poolparty/net/remote.rb +35 -0
  71. data/lib/poolparty/net/remote_bases/ec2.rb +145 -0
  72. data/lib/poolparty/net/remote_instance.rb +68 -0
  73. data/lib/poolparty/net/remoter.rb +209 -0
  74. data/lib/poolparty/net/remoter_base.rb +117 -0
  75. data/lib/poolparty/plugins/gem_package.rb +39 -0
  76. data/lib/poolparty/plugins/line.rb +76 -0
  77. data/lib/poolparty/plugins/svn.rb +48 -0
  78. data/lib/poolparty/pool/base.rb +74 -0
  79. data/lib/poolparty/pool/cloud.rb +132 -0
  80. data/lib/poolparty/pool/custom_resource.rb +61 -0
  81. data/lib/poolparty/pool/loggable.rb +29 -0
  82. data/lib/poolparty/pool/plugin.rb +42 -0
  83. data/lib/poolparty/pool/plugin_model.rb +48 -0
  84. data/lib/poolparty/pool/pool.rb +55 -0
  85. data/lib/poolparty/pool/resource.rb +235 -0
  86. data/lib/poolparty/pool/resources/class_package.rb +60 -0
  87. data/lib/poolparty/pool/resources/cron.rb +14 -0
  88. data/lib/poolparty/pool/resources/directory.rb +23 -0
  89. data/lib/poolparty/pool/resources/exec.rb +26 -0
  90. data/lib/poolparty/pool/resources/file.rb +23 -0
  91. data/lib/poolparty/pool/resources/gem.rb +14 -0
  92. data/lib/poolparty/pool/resources/host.rb +14 -0
  93. data/lib/poolparty/pool/resources/package.rb +14 -0
  94. data/lib/poolparty/pool/resources/remote_file.rb +20 -0
  95. data/lib/poolparty/pool/resources/service.rb +21 -0
  96. data/lib/poolparty/pool/resources/sshkey.rb +19 -0
  97. data/lib/poolparty/pool/resources/variable.rb +27 -0
  98. data/lib/poolparty/pool/script.rb +21 -0
  99. data/{config/heartbeat_authkeys.conf → lib/poolparty/templates/authkeys} +0 -0
  100. data/lib/poolparty/templates/cib.xml +1 -0
  101. data/lib/poolparty/templates/fileserver.conf +4 -0
  102. data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -1
  103. data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
  104. data/lib/poolparty/templates/namespaceauth.conf +19 -0
  105. data/lib/poolparty/templates/puppet.conf +13 -0
  106. data/lib/poolparty/version.rb +9 -0
  107. data/lib/poolpartycl.rb +3 -0
  108. data/script/destroy +14 -0
  109. data/script/generate +14 -0
  110. data/script/txt2html +82 -0
  111. data/{lib/poolparty/tasks → tasks}/cloud.rake +1 -1
  112. data/tasks/deployment.rake +34 -0
  113. data/tasks/development.rake +78 -0
  114. data/{lib/poolparty/tasks → tasks}/ec2.rake +1 -1
  115. data/tasks/environment.rake +7 -0
  116. data/{lib/poolparty/tasks → tasks}/instance.rake +0 -0
  117. data/{lib/poolparty/tasks → tasks}/server.rake +0 -0
  118. data/tasks/spec.rake +17 -0
  119. data/tasks/website.rake +17 -0
  120. metadata +154 -249
  121. data/CHANGELOG +0 -23
  122. data/LICENSE +0 -22
  123. data/README +0 -139
  124. data/assets/clouds.png +0 -0
  125. data/bin/instance +0 -68
  126. data/bin/poolnotify +0 -34
  127. data/config/cloud_master_takeover +0 -17
  128. data/config/create_proxy_ami.sh +0 -582
  129. data/config/installers/ubuntu_install.sh +0 -77
  130. data/config/monit.conf +0 -9
  131. data/config/monit/haproxy.monit.conf +0 -8
  132. data/config/monit/nginx.monit.conf +0 -0
  133. data/config/nginx.conf +0 -24
  134. data/config/reconfigure_instances_script.sh +0 -37
  135. data/config/sample-config.yml +0 -23
  136. data/config/scp_instances_script.sh +0 -12
  137. data/lib/core/array.rb +0 -16
  138. data/lib/core/hash.rb +0 -11
  139. data/lib/core/kernel.rb +0 -12
  140. data/lib/core/object.rb +0 -21
  141. data/lib/core/proc.rb +0 -15
  142. data/lib/helpers/plugin_spec_helper.rb +0 -58
  143. data/lib/modules/callback.rb +0 -133
  144. data/lib/modules/ec2_wrapper.rb +0 -108
  145. data/lib/modules/file_writer.rb +0 -38
  146. data/lib/modules/sprinkle_overrides.rb +0 -27
  147. data/lib/modules/vlad_override.rb +0 -83
  148. data/lib/poolparty/application.rb +0 -199
  149. data/lib/poolparty/init.rb +0 -6
  150. data/lib/poolparty/master.rb +0 -492
  151. data/lib/poolparty/monitors.rb +0 -11
  152. data/lib/poolparty/monitors/cpu.rb +0 -23
  153. data/lib/poolparty/monitors/memory.rb +0 -33
  154. data/lib/poolparty/monitors/web.rb +0 -29
  155. data/lib/poolparty/optioner.rb +0 -20
  156. data/lib/poolparty/plugin.rb +0 -78
  157. data/lib/poolparty/provider.rb +0 -104
  158. data/lib/poolparty/provider/essential.rb +0 -6
  159. data/lib/poolparty/provider/git.rb +0 -8
  160. data/lib/poolparty/provider/haproxy.rb +0 -9
  161. data/lib/poolparty/provider/heartbeat.rb +0 -6
  162. data/lib/poolparty/provider/rsync.rb +0 -8
  163. data/lib/poolparty/provider/ruby.rb +0 -65
  164. data/lib/poolparty/provider/s3fuse.rb +0 -22
  165. data/lib/poolparty/remote_instance.rb +0 -250
  166. data/lib/poolparty/remoter.rb +0 -171
  167. data/lib/poolparty/remoting.rb +0 -137
  168. data/lib/poolparty/scheduler.rb +0 -93
  169. data/lib/poolparty/tasks.rb +0 -47
  170. data/lib/poolparty/tasks/development.rake +0 -78
  171. data/lib/poolparty/tasks/plugins.rake +0 -30
  172. data/lib/poolparty/thread_pool.rb +0 -94
  173. data/lib/s3/s3_object_store_folders.rb +0 -44
  174. data/poolparty.gemspec +0 -71
  175. data/spec/files/describe_response +0 -37
  176. data/spec/files/multi_describe_response +0 -69
  177. data/spec/files/remote_desc_response +0 -37
  178. data/spec/helpers/ec2_mock.rb +0 -57
  179. data/spec/lib/core/core_spec.rb +0 -26
  180. data/spec/lib/core/kernel_spec.rb +0 -24
  181. data/spec/lib/core/string_spec.rb +0 -28
  182. data/spec/lib/modules/callback_spec.rb +0 -213
  183. data/spec/lib/modules/file_writer_spec.rb +0 -74
  184. data/spec/lib/poolparty/application_spec.rb +0 -135
  185. data/spec/lib/poolparty/ec2_wrapper_spec.rb +0 -110
  186. data/spec/lib/poolparty/master_spec.rb +0 -479
  187. data/spec/lib/poolparty/optioner_spec.rb +0 -34
  188. data/spec/lib/poolparty/plugin_spec.rb +0 -115
  189. data/spec/lib/poolparty/poolparty_spec.rb +0 -60
  190. data/spec/lib/poolparty/provider_spec.rb +0 -74
  191. data/spec/lib/poolparty/remote_instance_spec.rb +0 -178
  192. data/spec/lib/poolparty/remoter_spec.rb +0 -72
  193. data/spec/lib/poolparty/remoting_spec.rb +0 -148
  194. data/spec/lib/poolparty/scheduler_spec.rb +0 -70
  195. data/spec/monitors/cpu_monitor_spec.rb +0 -39
  196. data/spec/monitors/memory_spec.rb +0 -51
  197. data/spec/monitors/misc_monitor_spec.rb +0 -51
  198. data/spec/monitors/web_spec.rb +0 -40
  199. data/spec/spec_helper.rb +0 -53
@@ -0,0 +1,24 @@
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 = "puppetca --clean --all && puppetrun --host puppet #{list_of_node_names.join(", --host ")}"
21
+ run_command_on(cmd, master)
22
+ end
23
+
24
+ end
data/bin/cloud-ssh ADDED
@@ -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 )
data/bin/cloud-start ADDED
@@ -0,0 +1,29 @@
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
+ include Remote
14
+
15
+ if o.cloudname
16
+ @cloud = cloud(o.cloudname.downcase.to_sym)
17
+ else
18
+ puts "Cloud name or pool name required. Please specify it with -c name"
19
+ exit(0)
20
+ end
21
+
22
+ with_cloud(@cloud, {:testing => @testing}) do
23
+ puts header("Starting cloud")
24
+ puts "#{list_of_running_instances.size} running instances (#{minimum_instances} - #{maximum_instances})"
25
+ if (minimum_instances - list_of_running_instances.size) > 0
26
+ puts "Starting #{minimum_instances - list_of_running_instances.size} instances"
27
+ testing ? puts("\tNot launching while in testing mode") : launch_minimum_number_of_instances
28
+ end
29
+ end
data/bin/pool CHANGED
@@ -1,83 +1,31 @@
1
1
  #!/usr/bin/ruby
2
- $:.unshift(File.join(File.dirname(__FILE__)))
3
- require 'poolparty'
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
4
5
 
5
- def display_config_data
6
- PoolParty.message <<-EOM
7
- PoolParty cloud: #{PoolParty::Application.app_name ? "#{PoolParty::Application.app_name} " : "" }
8
- On #{PoolParty::Application.ami}
9
- Minimum instances: #{PoolParty::Application.minimum_instances}
10
- Maximum instances: #{PoolParty::Application.maximum_instances}
11
- Polling every: #{PoolParty::Application.polling_time}
12
- Keypair: #{PoolParty::Application.keypair}
13
- Access key: #{PoolParty::Application.access_key}
14
- size: #{PoolParty::Application.size}
15
- Monitors available:
16
- --------------
17
- #{PoolParty.registered_monitors.collect {|a| " #{a}"}}
18
-
19
- Plugins:
20
- --------------
21
- #{Dir["#{PoolParty::Application.plugin_dir}/*"].collect {|a| " #{File.basename(a)}"}.join("\n")}
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 }
9
+ # end
22
10
 
23
- EOM
24
- end
11
+ name = ARGV.shift
25
12
 
26
- # Set defaults
27
- options = PoolParty.options(:optsparse =>
28
- {:banner => <<-EOU
29
- Usage: pool [OPTIONS] {start | stop | list | clouds_list | maintain | restart | install | configure | grow | shrink | ssh | switch}
30
- -----------------------------------------------------------------
31
- EOU
32
- })
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
33
20
 
34
- PoolParty.load_app
35
- master = PoolParty::Master.new
36
- list = PoolParty::Optioner.parse(ARGV.dup, %w(-v))
21
+ program_name = "#{File.basename($0)}-#{name}"
22
+ program_location = File.join(Binary.binary_directory, program_name)
37
23
 
38
- display_config_data
24
+ command_line = "#{program_location} #{ARGV.join(" ")}"
39
25
 
40
- list.each do |cmd|
41
- case cmd
42
- when "start"
43
- master.start_cloud!
44
- when "show"
45
- display_config_data
46
- when "grow"
47
- master.grow_by
48
- when "shrink"
49
- master.shrink_by
50
- when "install"
51
- master.install_cloud(true)
52
- when "configure"
53
- master.setup_cloud
54
- when "ssh"
55
- list.shift
56
- PoolParty.message "Running #{list} on the cloud"
57
- master.ssh list.shift
58
- when "stop"
59
- PoolParty.message "Stopping cloud"
60
- master.request_termination_of_all_instances
61
- when "list"
62
- puts master.list
63
- when "size"
64
- puts master.nodes.size
65
- when "clouds_list"
66
- puts master.clouds_list
67
- when "maintain"
68
- PoolParty.message "Maintaining cloud"
69
- master.start_monitor!
70
- when "restart"
71
- PoolParty.message "Restarting cloud"
72
- master.request_termination_of_all_instances
73
- master.start_cloud!
74
- when "switch"
75
- list.shift
76
- context = list.shift
77
- keyfilename = ".#{context}_pool_keys"
78
- PoolParty.message "switching cloud to #{context}"
79
- context ? Kernel.system("source $HOME/#{keyfilename}") : puts("You must supply a context to switch to")
80
- else
81
- puts master.list
82
- end
26
+ # Run it from the command-line first
27
+ if Binary.available_binaries_for("pool").include?(name)
28
+ Kernel.exec "#{command_line}"
29
+ else
30
+ puts "Unknown poolparty binary: #{program_name}"
83
31
  end
data/bin/pool-console ADDED
@@ -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"
data/bin/pool-describe ADDED
@@ -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
data/bin/pool-list ADDED
@@ -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
@@ -0,0 +1,34 @@
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('-t', '--type [master|slave|all]', 'Provision these instances (default: all)') { |o| optioner.class_type o }
8
+ # opts.on('-a', '--all', 'Provision all the instances') { |o| optioner.all true }
9
+ # opts.on('-n [name]', '--name [name]', 'Pool to provision (required)') {|o| optioner.cloud_name o }
10
+ # end
11
+ # load_pool(o.spec || Binary.get_existing_spec_location)
12
+ #
13
+ # if o.cloud_name
14
+ # @c = cloud(o.cloud_name.downcase.to_sym)
15
+ # else
16
+ # puts "Cloud name required. Please specify it with -c [name]"
17
+ # exit(0)
18
+ # end
19
+ #
20
+ # if o.class_type && o.class_type != "all" && !o.all
21
+ # case o.class_type
22
+ # when "master","m"
23
+ # puts header("Provisioning the master instances")
24
+ # when "slave", "s"
25
+ # puts header("Provisioning the slave instances")
26
+ # end
27
+ # else
28
+ # # Provision all the instances
29
+ # puts header("Provisioning all the instances")
30
+ # provisioner_file = ::File.join(Base.storage_directory, "install.sh")
31
+ # File.open(provisioner_file, "w+") do |file|
32
+ # file << Provisioner::Master.install(@c)
33
+ # end
34
+ # end
data/bin/pool-spec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'poolspec/version'
8
+ puts "#{File.basename($0)} #{Poolspec::VERSION::STRING}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ source = RubiGen::PathSource.new(:application,
14
+ File.join(File.dirname(__FILE__), "../generators"))
15
+ RubiGen::Base.reset_sources
16
+ RubiGen::Base.append_sources source
17
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'poolspec')
data/bin/pool-start ADDED
@@ -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('-p poolname', '--pool name', 'Start pool by this name') { |p| optioner.poolname p }
7
+ end
8
+
9
+ load_pool(o.spec || Binary.get_existing_spec_location)
10
+
11
+ @testing = o.testing
12
+
13
+ include Remote
14
+
15
+ if o.poolname
16
+ @pool = pool(o.poolname.downcase.to_sym)
17
+ else
18
+ puts "Pool name required. Please specify it with -c name"
19
+ exit(0)
20
+ end
21
+
22
+ with_pool(@pool, {:testing => @testing}) do
23
+ puts header("Starting pool")
24
+ clouds.each do |name, cloud|
25
+ puts subheader("Cloud: #{name}")
26
+ puts "#{cloud.list_of_running_instances.size} running instances (#{cloud.minimum_instances} - #{cloud.maximum_instances})"
27
+ if (cloud.minimum_instances - cloud.list_of_running_instances.size) > 0
28
+ puts "Starting #{cloud.minimum_instances - cloud.list_of_running_instances.size} instances (from #{cloud.keypair})"
29
+ testing ? puts("\tNot launching while in testing mode") : cloud.launch_minimum_number_of_instances
30
+ end
31
+ end
32
+ end
data/examples/basic.rb ADDED
@@ -0,0 +1,20 @@
1
+ # Basic pool spec
2
+ # Shows global settings for the clouds
3
+
4
+ pool :application do
5
+
6
+ instances 3..5
7
+ keypair "auser"
8
+
9
+ cloud :app do
10
+ minimum_instances 2
11
+ ami "ami-abc123"
12
+ end
13
+
14
+ cloud :db do
15
+ keypair "hotstuff_database"
16
+ maximum_instances 20
17
+ ami "ami-1234bc"
18
+ end
19
+
20
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + "/pool/test_plugins/webserver"
2
+
3
+ pool :app do
4
+
5
+ instances 2..10
6
+
7
+ cloud :app do
8
+ apache do
9
+ enable_php
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,12 @@
1
+ # Poolparty spec
2
+
3
+ pool :poolparty do
4
+
5
+ instances 2..5
6
+
7
+ cloud :app do
8
+ keypair "auser"
9
+ ami "ami-4bb05422"
10
+ end
11
+
12
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ pool :app do
4
+
5
+ plugin_directory File.join(File.dirname(__FILE__), "pool", "test_plugins")
6
+ instances 2..10
7
+
8
+ cloud :app do
9
+ # minimum 2 instances
10
+ # maximum 10 instances
11
+ apache do
12
+ enable_php
13
+ end
14
+ end
15
+
16
+ cloud :db do
17
+ # minimum 2 instances
18
+ # maximum 10 instances
19
+ mysql # default mysql setup
20
+ end
21
+
22
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,65 @@
1
+ class PoolspecGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ default_options :author => nil
7
+
8
+ attr_reader :name
9
+
10
+ def initialize(runtime_args, runtime_options = {})
11
+ super
12
+ usage if args.empty?
13
+ @destination_root = File.expand_path(args.shift)
14
+ @name = base_name
15
+ extract_options
16
+ end
17
+
18
+ def manifest
19
+ record do |m|
20
+ # Ensure appropriate folder(s) exists
21
+ m.directory ''
22
+ BASEDIRS.each { |path| m.directory path }
23
+
24
+ m.template "pool_spec_template.erb", "#{@name}.rb"
25
+ # Create stubs
26
+ # m.template "template.rb", "some_file_after_erb.rb"
27
+ # m.template_copy_each ["template.rb", "template2.rb"]
28
+ # m.file "file", "some_file_copied"
29
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
30
+ end
31
+ end
32
+
33
+ protected
34
+ def banner
35
+ <<-EOS
36
+ Creates a basic poolparty spec tempalte
37
+
38
+ USAGE: #{spec.name} name
39
+ EOS
40
+ end
41
+
42
+ def add_options!(opts)
43
+ opts.separator ''
44
+ opts.separator 'Options:'
45
+ # For each option below, place the default
46
+ # at the top of the file next to "default_options"
47
+ # opts.on("-a", "--author=\"Your Name\"", String,
48
+ # "Some comment about this option",
49
+ # "Default: none") { |options[:author]| }
50
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
51
+ end
52
+
53
+ def extract_options
54
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
55
+ # Templates can access these value via the attr_reader-generated methods, but not the
56
+ # raw instance variable value.
57
+ # @author = options[:author]
58
+ @pool_name = ARGV.pop
59
+ end
60
+
61
+ # Installation skeleton. Intermediate directories are automatically
62
+ # created so don't sweat their absence here.
63
+ BASEDIRS = %w(
64
+ )
65
+ end