poolparty 0.2.6 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. data/Manifest.txt +123 -4
  2. data/PostInstall.txt +2 -1
  3. data/bin/cloud +16 -7
  4. data/bin/cloud-provision +9 -5
  5. data/bin/cloud-run +19 -0
  6. data/bin/cloud-ssh +2 -7
  7. data/bin/cloud-start +2 -1
  8. data/bin/pool +3 -3
  9. data/bin/server-build-messenger +20 -0
  10. data/bin/server-fire-cmd +14 -0
  11. data/bin/server-get-load +29 -0
  12. data/bin/server-list-active +25 -0
  13. data/bin/server-list-responding +24 -0
  14. data/bin/server-rerun +24 -0
  15. data/bin/server-start-master +27 -0
  16. data/bin/server-start-node +33 -0
  17. data/config/requirements.rb +1 -1
  18. data/erl_crash.dump +8409 -0
  19. data/lib/erlang/messenger/Emakefile +1 -0
  20. data/lib/erlang/messenger/Makefile +15 -0
  21. data/lib/erlang/messenger/README +5 -0
  22. data/lib/erlang/messenger/Rakefile +60 -0
  23. data/lib/erlang/messenger/control +11 -0
  24. data/lib/erlang/messenger/ebin/master.app +19 -0
  25. data/lib/erlang/messenger/ebin/master_app.beam +0 -0
  26. data/lib/erlang/messenger/ebin/node.app +19 -0
  27. data/lib/erlang/messenger/ebin/node_app.beam +0 -0
  28. data/lib/erlang/messenger/ebin/packager.app +19 -0
  29. data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
  30. data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
  31. data/lib/erlang/messenger/ebin/pm_event_handler.beam +0 -0
  32. data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
  33. data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +1 -0
  34. data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
  35. data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
  36. data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +1 -0
  37. data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
  38. data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
  39. data/lib/erlang/messenger/ebin/utils.beam +0 -0
  40. data/lib/erlang/messenger/lib/eunit/AUTHORS +2 -0
  41. data/lib/erlang/messenger/lib/eunit/CHANGELOG +14 -0
  42. data/lib/erlang/messenger/lib/eunit/COPYING +504 -0
  43. data/lib/erlang/messenger/lib/eunit/Makefile +28 -0
  44. data/lib/erlang/messenger/lib/eunit/NOTES +276 -0
  45. data/lib/erlang/messenger/lib/eunit/README +3 -0
  46. data/lib/erlang/messenger/lib/eunit/doc/edoc-info +3 -0
  47. data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
  48. data/lib/erlang/messenger/lib/eunit/doc/eunit.html +172 -0
  49. data/lib/erlang/messenger/lib/eunit/doc/index.html +17 -0
  50. data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +12 -0
  51. data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +984 -0
  52. data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +980 -0
  53. data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +11 -0
  54. data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +55 -0
  55. data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
  56. data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
  57. data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +21 -0
  58. data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +1 -0
  59. data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
  60. data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
  61. data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
  62. data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
  63. data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
  64. data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
  65. data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
  66. data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
  67. data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
  68. data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
  69. data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
  70. data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
  71. data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +339 -0
  72. data/lib/erlang/messenger/lib/eunit/examples/fib.erl +19 -0
  73. data/lib/erlang/messenger/lib/eunit/examples/tests.txt +1 -0
  74. data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +313 -0
  75. data/lib/erlang/messenger/lib/eunit/src/Makefile +46 -0
  76. data/lib/erlang/messenger/lib/eunit/src/autoload.erl +388 -0
  77. data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +243 -0
  78. data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +21 -0
  79. data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +1 -0
  80. data/lib/erlang/messenger/lib/eunit/src/eunit.erl +196 -0
  81. data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +102 -0
  82. data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +798 -0
  83. data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +48 -0
  84. data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +682 -0
  85. data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +552 -0
  86. data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +157 -0
  87. data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +340 -0
  88. data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +64 -0
  89. data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +334 -0
  90. data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +45 -0
  91. data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +272 -0
  92. data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +409 -0
  93. data/lib/erlang/messenger/lib/eunit/sys.config +9 -0
  94. data/lib/erlang/messenger/lib/eunit/vsn.mk +1 -0
  95. data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
  96. data/lib/erlang/messenger/pm_master_rel-0.1.script +242 -0
  97. data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
  98. data/lib/erlang/messenger/pm_node_rel-0.1.script +242 -0
  99. data/lib/erlang/messenger/src/master_app.erl +39 -0
  100. data/lib/erlang/messenger/src/node_app.erl +39 -0
  101. data/lib/erlang/messenger/src/pm_client.erl +19 -0
  102. data/lib/erlang/messenger/src/pm_cluster.erl +57 -0
  103. data/lib/erlang/messenger/src/pm_event_handler.erl +21 -0
  104. data/lib/erlang/messenger/src/pm_master.erl +118 -0
  105. data/lib/erlang/messenger/src/pm_master_supervisor.erl +40 -0
  106. data/lib/erlang/messenger/src/pm_node.erl +124 -0
  107. data/lib/erlang/messenger/src/pm_node_supervisor.erl +40 -0
  108. data/lib/erlang/messenger/src/pm_packager.erl +73 -0
  109. data/lib/erlang/messenger/src/utils.erl +38 -0
  110. data/lib/poolparty/base_packages/haproxy.rb +9 -2
  111. data/lib/poolparty/base_packages/heartbeat.rb +40 -28
  112. data/lib/poolparty/base_packages/poolparty.rb +39 -16
  113. data/lib/poolparty/base_packages/ruby.rb +2 -3
  114. data/lib/poolparty/config/allowed_commands.yml +1 -0
  115. data/lib/poolparty/core/array.rb +5 -2
  116. data/lib/poolparty/core/hash.rb +16 -2
  117. data/lib/poolparty/core/string.rb +9 -2
  118. data/lib/poolparty/core/symbol.rb +2 -2
  119. data/lib/poolparty/dependency_resolutions/base.rb +12 -0
  120. data/lib/poolparty/dependency_resolutions/puppet.rb +49 -0
  121. data/lib/poolparty/exceptions/UnacceptableCommand.rb +5 -0
  122. data/lib/poolparty/helpers/console.rb +3 -2
  123. data/lib/poolparty/helpers/display.rb +3 -3
  124. data/lib/poolparty/helpers/messenger.rb +29 -0
  125. data/lib/poolparty/helpers/optioner.rb +6 -2
  126. data/lib/poolparty/helpers/provisioner_base.rb +18 -11
  127. data/lib/poolparty/helpers/provisioners/master.rb +24 -22
  128. data/lib/poolparty/helpers/provisioners/slave.rb +8 -4
  129. data/lib/poolparty/modules/definable_resource.rb +1 -0
  130. data/lib/poolparty/modules/file_writer.rb +11 -10
  131. data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
  132. data/lib/poolparty/modules/pretty_printer.rb +11 -11
  133. data/lib/poolparty/modules/resourcing_dsl.rb +61 -0
  134. data/lib/poolparty/monitors/base_monitor.rb +17 -3
  135. data/lib/poolparty/monitors/monitors/cpu_monitor.rb +15 -0
  136. data/lib/poolparty/monitors/monitors/memory_monitor.rb +23 -0
  137. data/lib/poolparty/net/remote_instance.rb +6 -1
  138. data/lib/poolparty/net/remoter.rb +23 -5
  139. data/lib/poolparty/net/remoter_base.rb +5 -1
  140. data/lib/poolparty/plugins/git.rb +22 -24
  141. data/lib/poolparty/pool/base.rb +22 -6
  142. data/lib/poolparty/pool/cloud.rb +28 -4
  143. data/lib/poolparty/pool/custom_resource.rb +6 -6
  144. data/lib/poolparty/pool/loggable.rb +3 -0
  145. data/lib/poolparty/pool/pool.rb +1 -1
  146. data/lib/poolparty/pool/resource.rb +58 -94
  147. data/lib/poolparty/pool/resources/class_package.rb +6 -6
  148. data/lib/poolparty/pool/resources/conditional.rb +5 -1
  149. data/lib/poolparty/pool/resources/exec.rb +6 -2
  150. data/lib/poolparty/pool/resources/gem.rb +22 -8
  151. data/lib/poolparty/pool/resources/remote_file.rb +5 -1
  152. data/lib/poolparty/pool/resources/symlink.rb +25 -0
  153. data/lib/poolparty/pool/resources/variable.rb +8 -7
  154. data/lib/poolparty/pool/tmp/.ppkeys +3 -0
  155. data/lib/poolparty/pool/tmp/happydayz +1 -0
  156. data/lib/poolparty/pool/tmp/install_master.sh +33 -0
  157. data/lib/poolparty/pool/tmp/pool.spec +11 -0
  158. data/lib/poolparty/pool/tmp/poolparty.pp +600 -0
  159. data/lib/poolparty/pool/tmp/tc-instances.list +1 -0
  160. data/lib/poolparty/templates/cib.xml +54 -0
  161. data/lib/poolparty/templates/ha.cf +12 -3
  162. data/lib/poolparty/templates/haproxy.conf +3 -3
  163. data/lib/poolparty/templates/haresources +3 -0
  164. data/lib/poolparty/templates/poolparty.monitor +14 -0
  165. data/lib/poolparty/templates/puppet.conf +3 -4
  166. data/lib/poolparty/version.rb +1 -1
  167. data/lib/poolparty.rb +9 -6
  168. data/poolparty.gemspec +7 -6
  169. data/setup.rb +3 -3
  170. data/spec/poolparty/bin/console_spec.rb +1 -1
  171. data/spec/poolparty/core/array_spec.rb +5 -0
  172. data/spec/poolparty/core/hash_spec.rb +19 -1
  173. data/spec/poolparty/core/string_spec.rb +13 -0
  174. data/spec/poolparty/dependency_resolutions/base_spec.rb +11 -0
  175. data/spec/poolparty/helpers/messenger_spec.rb +14 -0
  176. data/spec/poolparty/helpers/optioner_spec.rb +2 -1
  177. data/spec/poolparty/helpers/provisioner_base_spec.rb +1 -1
  178. data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
  179. data/spec/poolparty/helpers/provisioners/slave_spec.rb +3 -3
  180. data/spec/poolparty/modules/file_writer_spec.rb +9 -0
  181. data/spec/poolparty/monitors/base_monitor_spec.rb +19 -0
  182. data/spec/poolparty/monitors/monitors/cpu_monitor_spec.rb +17 -0
  183. data/spec/poolparty/net/remote_instance_spec.rb +6 -1
  184. data/spec/poolparty/net/remote_spec.rb +51 -42
  185. data/spec/poolparty/net/remoter_spec.rb +2 -1
  186. data/spec/poolparty/plugins/git_spec.rb +2 -2
  187. data/spec/poolparty/pool/base_spec.rb +20 -2
  188. data/spec/poolparty/pool/cloud_spec.rb +30 -1
  189. data/spec/poolparty/pool/custom_resource_spec.rb +2 -2
  190. data/spec/poolparty/pool/plugin_spec.rb +4 -4
  191. data/spec/poolparty/pool/pool_spec.rb +1 -1
  192. data/spec/poolparty/pool/resource_spec.rb +66 -0
  193. data/spec/poolparty/pool/resources/gem_spec.rb +29 -3
  194. data/spec/poolparty/pool/resources/symlink_spec.rb +22 -0
  195. data/spec/poolparty/pool/resources/variable_spec.rb +4 -0
  196. data/spec/poolparty/spec_helper.rb +5 -0
  197. data/tasks/cloud.rake +0 -54
  198. data/tasks/development.rake +0 -12
  199. data/tasks/ec2.rake +1 -16
  200. data/tasks/instance.rake +0 -61
  201. data/test_manifest.pp +286 -166
  202. data/website/index.html +5 -5
  203. data/website/index.txt +3 -3
  204. metadata +137 -8
  205. data/bin/pool-start-monitor +0 -1
  206. data/lib/erlang/eb_server.erl +0 -27
  207. data/lib/poolparty/plugins/gem_package.rb +0 -17
  208. data/spec/poolparty/modules/tmp/willy/nilly.rb +0 -1
@@ -15,10 +15,10 @@ describe "Base" do
15
15
  Base.base_keypair_path.should == "~/.ec2"
16
16
  end
17
17
  it "should set the storage_directory to the tmp directory of the current working directory" do
18
- Base.storage_directory.should == "#{Dir.pwd}/tmp"
18
+ Base.storage_directory.should =~ /tmp/
19
19
  end
20
20
  it "should set the tmp path to tmp" do
21
- Base.tmp_path.should == "tmp"
21
+ Base.tmp_path.should =~ /\/tmp/
22
22
  end
23
23
  it "should set the remote storage path to /var/poolparty" do
24
24
  Base.remote_storage_path.should == "/var/poolparty"
@@ -104,5 +104,23 @@ describe "Base" do
104
104
  Base.store_keys_in_file
105
105
  end
106
106
  end
107
+ describe "allowed_commands" do
108
+ before(:each) do
109
+ @str =<<-EOE
110
+ echo 'hello world'
111
+ EOE
112
+ @str.stub!(:read).and_return @str
113
+ Base.stub!(:open).and_return @str
114
+ end
115
+ it "should load the yaml file allowed_commands.yml" do
116
+ Base.allowed_commands.class.should == Array
117
+ end
118
+ it "should have the command echo 'hello world' in the list of allowed_commands" do
119
+ Base.allowed_commands.include?("echo 'hello world'").should == true
120
+ end
121
+ it "should not have the command rm -rf / in the list of allowed commands" do
122
+ Base.allowed_commands.include?("rm -rf /").should == false
123
+ end
124
+ end
107
125
  end
108
126
  end
@@ -170,7 +170,7 @@ describe "Cloud" do
170
170
  hello my lady
171
171
  EOE
172
172
  end
173
- has_gem(:name => "poolparty")
173
+ has_gempackage(:name => "poolparty")
174
174
  has_package(:name => "dummy")
175
175
  end
176
176
  end
@@ -279,6 +279,21 @@ describe "Cloud" do
279
279
  @manifest.should =~ /host \{\n\t\t"master":/
280
280
  end
281
281
  end
282
+ describe "building with an existing manifest" do
283
+ before(:each) do
284
+ @file = "/etc/puppet/manifests/nodes/nodes.pp"
285
+ @file.stub!(:read).and_return "nodes"
286
+ ::FileTest.stub!(:file?).with("/etc/puppet/manifests/classes/poolparty.pp").and_return true
287
+ @cloud.stub!(:open).with("/etc/puppet/manifests/classes/poolparty.pp").and_return @file
288
+ end
289
+ it "should not call resources_string_from_resources if the file /etc/puppet/manifests/nodes/nodes.pp exists" do
290
+ @cloud.should_not_receive(:add_poolparty_base_requirements)
291
+ @cloud.build_manifest
292
+ end
293
+ it "should build from the existing file" do
294
+ @cloud.build_manifest.should == "nodes"
295
+ end
296
+ end
282
297
  end
283
298
  end
284
299
 
@@ -295,5 +310,19 @@ describe "Cloud" do
295
310
  end
296
311
  end
297
312
 
313
+ describe "provisioning" do
314
+ it "should be able to tell that it is provisioning when setting the provisioning flag" do
315
+ @cloud.provisioning?.should == false
316
+ end
317
+ it "should be able to set it as provisioning" do
318
+ @cloud.provisioning_in_progress
319
+ @cloud.provisioning?.should == true
320
+ end
321
+ it "should be able to unset itself as provisioning" do
322
+ @cloud.provisioning_in_progress
323
+ @cloud.provisioning_complete
324
+ @cloud.provisioning?.should == false
325
+ end
326
+ end
298
327
  end
299
328
  end
@@ -80,10 +80,10 @@ describe "Custom Resource" do
80
80
  end
81
81
  it "should create a new CallFunction instance when calling call_function with a string" do
82
82
  PoolParty::Resources::CallFunction.should_receive(:new).and_return "bunk"
83
- add_resource(:call_function, "line")
83
+ add_resource(:call_function, :name => "line")
84
84
  end
85
85
  it "should create a call function in the function call array" do
86
- add_resource(:call_function, @cloud, "heyyohey")
86
+ add_resource(:call_function, {:name => "custom_function"}, @cloud)
87
87
  resource(:call_function).size.should == 1
88
88
  end
89
89
  describe "defining" do
@@ -39,7 +39,7 @@ describe "Plugin" do
39
39
  before(:each) do
40
40
  @plugin.instance_eval do
41
41
  enable_php
42
- has_gem(:name => "aska")
42
+ has_gempackage(:name => "aska")
43
43
  end
44
44
  end
45
45
  it "should call enable_php on the class" do
@@ -49,13 +49,13 @@ describe "Plugin" do
49
49
  @plugin.resources.class.should == Hash
50
50
  end
51
51
  it "should have an array of gem resources" do
52
- @plugin.resource(:package).class.should == Array
52
+ @plugin.resource(:gempackage).class.should == Array
53
53
  end
54
54
  it "should have 1 gem in the resources defined" do
55
- @plugin.resource(:package).size.should == 1
55
+ @plugin.resource(:gempackage).size.should == 1
56
56
  end
57
57
  it "should have the gem named aska in the gem resource" do
58
- @plugin.resource(:package).first.name.should == "aska"
58
+ @plugin.resource(:gempackage).first.name.should == "aska"
59
59
  end
60
60
  it "should have its resources visible to its parent" do
61
61
  @plugin.parent = @c
@@ -37,7 +37,7 @@ describe "Pool" do
37
37
  end
38
38
  end
39
39
  it "should call Dir when the plugin directory is set" do
40
- Dir.should_receive(:[]).with("yaway/*.rb").once.and_return []
40
+ Dir.should_receive(:[]).with("yaway/*/*.rb").once.and_return []
41
41
  end
42
42
  end
43
43
  describe "configuration" do
@@ -131,6 +131,13 @@ describe "Resource" do
131
131
  include PoolParty::Resources
132
132
  before(:each) do
133
133
  reset_resources!
134
+ @cloud = cloud :command_cloud do; end
135
+ end
136
+ it "should call add_resource when creating using the command: file" do
137
+ @cloud.should_receive(:add_resource).with(:file, {:name => "frank"}, @cloud)
138
+ @cloud.instance_eval do
139
+ file(:name => "frank")
140
+ end
134
141
  end
135
142
  it "should create the new 'resource' as a resource" do
136
143
  resource(:file).class.should == Array
@@ -220,5 +227,64 @@ describe "Resource" do
220
227
  @file.parent.tangerine.should == "orange"
221
228
  end
222
229
  end
230
+ describe "appending to resource" do
231
+ before(:each) do
232
+ @cloud1 = cloud :apples do
233
+ directory(:name => "/var/www") do
234
+ file(:name => "/var/www/file.html")
235
+ end
236
+ end
237
+ @dir = @cloud1.get_resource(:directory, "/var/www")
238
+ @file = @dir.get_resource(:file, "/var/www/file.html")
239
+ end
240
+ it "should say there is 1 resource because the lower-level resources should be contained on the parenting resource" do
241
+ @cloud1.resources.size.should == 1
242
+ end
243
+ it "should say there is one resource on the outer resource" do
244
+ @dir.resources.size.should == 1
245
+ end
246
+ it "should contain the file as a resource" do
247
+ @dir.resource(:file)[0].to_s.should == @file.to_s
248
+ end
249
+ it "should set the parent as the parenting resource" do
250
+ @file.parent.to_s.should == @dir.to_s
251
+ end
252
+ end
253
+ describe "fetching" do
254
+ before(:each) do
255
+ @file = file(:name => "pancakes")
256
+ end
257
+ it "should not create a new resource if the same resource exists" do
258
+ PoolParty::Resources::File.should_not_receive(:new)
259
+ file(:name => "pancakes")
260
+ end
261
+ it "should return the file preiously created" do
262
+ get_resource(:file, "pancakes").should == @file
263
+ end
264
+ it "should be able to use the helper to grab the file" do
265
+ PoolParty::Resources::File.should_not_receive(:new)
266
+ file(:name => "pancakes").should == @file
267
+ end
268
+ it "should turn the resource into a string" do
269
+ @file.to_s.should == "File['pancakes']"
270
+ end
271
+ describe "cancelled" do
272
+ it "should make a resource not cancelled by default" do
273
+ @file.cancelled?.should == false
274
+ end
275
+ it "should say cancelled? is true if it has been cancelled" do
276
+ @file.cancel
277
+ @file.cancelled?.should == true
278
+ end
279
+ end
280
+ describe "virtual_resources" do
281
+ before(:each) do
282
+ @virtual_resource = git(:name => "tank", :source => "git://github.com/auser/testgit.git")
283
+ end
284
+ it "should fetch a virtual resource the same" do
285
+ git(:name => "tank", :source => "git://github.com/auser/testgit.git").to_s.should == @virtual_resource.to_s
286
+ end
287
+ end
288
+ end
223
289
  end
224
290
  end
@@ -5,12 +5,38 @@ include PoolParty::Resources
5
5
  describe "Gem" do
6
6
  before(:each) do
7
7
  reset!
8
- @gem = gem(:name => "rails")
8
+ @cloud = cloud :gem_cloud do
9
+ has_gempackage(:name => "activesupport") do
10
+ has_gempackage(:name => "rails")
11
+ end
12
+ end
13
+ @gem = @cloud.resource(:gempackage).first
9
14
  end
10
15
  it "should have a package" do
11
- resource(:package).should_not be_empty
16
+ @cloud.resource(:gempackage).should_not be_empty
17
+ end
18
+ it "should have the name set as activesupport" do
19
+ @gem.name.should == "activesupport"
12
20
  end
13
21
  it "should have the 'rails' gem in the packages" do
14
- @gem.to_string.should =~ /Package\[rubygems\]/
22
+ @cloud.resource(:gempackage).first.to_string.should =~ /rails/
23
+ end
24
+ describe "with parent options" do
25
+ before(:each) do
26
+ reset_all!
27
+ @cloud1 = cloud :gem_version_cloud do
28
+ has_gempackage(:name => "ParseTree", :version => "2.2.0") do
29
+ has_gempackage(:name => "edge-rails")
30
+ end
31
+ end
32
+ @gem = @cloud1.resource(:gempackage).first
33
+ @gem2 = @gem.resource(:gempackage).first
34
+ end
35
+ it "should have the version set on the parent" do
36
+ @gem.version.should == "2.2.0"
37
+ end
38
+ it "should not take the version of the parent on the child" do
39
+ @gem2.version.should == nil
40
+ end
15
41
  end
16
42
  end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Symlink" do
6
+ before(:each) do
7
+ reset_resources!
8
+ @cloud = cloud :symlink_test do
9
+ has_symlink(:name => "/etc/apache2/puppetmaster.conf", :source => "/etc/http/puppetmaster.conf")
10
+ end
11
+ @symlink = @cloud.resource(:symlink).first
12
+ end
13
+ it "should create a file" do
14
+ @cloud.resource(:symlink).empty?.should == false
15
+ end
16
+ it "should create a file { resource" do
17
+ @symlink.to_string.should =~ /file \{/
18
+ end
19
+ it "should use the from for the ensures" do
20
+ @symlink.ensure.should == @symlink.source
21
+ end
22
+ end
@@ -17,4 +17,8 @@ describe "Variable" do
17
17
  v = variable(:name => "girlfriends", :value => %w(Rachel Erica Michelle))
18
18
  v.to_string.should == "$girlfriends = [ 'Rachel', 'Erica', 'Michelle' ]"
19
19
  end
20
+ it "should set the string to be without a string if it's a function" do
21
+ v = variable(:name => "girlfriends", :value => "lookup_var()")
22
+ v.to_string.should == "$girlfriends = lookup_var()"
23
+ end
20
24
  end
@@ -17,6 +17,10 @@ extend PoolParty
17
17
  Base.environment = "test"
18
18
  Base.verbose = false
19
19
 
20
+ def setup_cl
21
+ require 'poolpartycl'
22
+ end
23
+
20
24
  def stub_option_load
21
25
  @str=<<-EOS
22
26
  :access_key:
@@ -38,6 +42,7 @@ def wait_launch(time=5)
38
42
  Process.wait(pid, 0)
39
43
  end
40
44
  def reset_all!
45
+ $cloud = nil
41
46
  end
42
47
  def read_file(path)
43
48
  require "open-uri"
data/tasks/cloud.rake CHANGED
@@ -1,57 +1,3 @@
1
1
  # Cloud tasks
2
2
  namespace(:cloud) do
3
- # Setup
4
- task :init do
5
- setup_application
6
- raise Exception.new("You must specify your access_key and secret_access_key") unless Base.access_key && Base.secret_access_key
7
- end
8
- # Install the stack on all of the nodes
9
- desc "Prepare all servers"
10
- task :prepare => :init do
11
- PoolParty::Master.new.nodes.each do |node|
12
- node.install
13
- end
14
- end
15
- # Start the cloud
16
- desc "Start the cloud"
17
- task :start => :init do
18
- PoolParty::Master.new.start_cloud!
19
- end
20
- # Reload the cloud with the new updated data
21
- desc "Reload all instances with updated data"
22
- task :reload => :init do
23
- PoolParty::Master.new.nodes.each do |node|
24
- node.configure
25
- node.restart_with_monit
26
- end
27
- end
28
- # List the cloud
29
- desc "List cloud"
30
- task :list => :init do
31
- puts PoolParty::Master.new.list
32
- end
33
- # Shutdown the cloud
34
- desc "Shutdown the entire cloud"
35
- task :shutdown => :init do
36
- PoolParty::Master.new.request_termination_of_all_instances
37
- end
38
- # Watch the cloud and scale it if necessary
39
- desc "Watch the cloud and maintain it"
40
- task :scale => :init do
41
- begin
42
- PoolParty::Master.new.scale_cloud!
43
- rescue Exception => e
44
- puts "There was an error scaling the cloud: #{e}"
45
- end
46
-
47
- end
48
- # Maintain the cloud in a background process
49
- desc "Maintain the cloud (run on the master)"
50
- task :maintain => :init do
51
- begin
52
- PoolParty::Master.new.start_monitor!
53
- rescue Exception => e
54
- puts "There was an error starting the monitor: #{e}"
55
- end
56
- end
57
3
  end
@@ -56,18 +56,6 @@ To work on this cloud, source the file like:
56
56
  end
57
57
  desc "initialize setup"
58
58
  task :init => [:setup_pemkeys]
59
-
60
- desc "Just an argv test"
61
- task :test => :initialize do
62
- puts "---- Testing ----"
63
- puts PoolParty.options(ARGV.dup)
64
- puts "Using keypair at: #{Base.keypair_path}"
65
- end
66
- desc "Installation listing"
67
- task :list_install => :initialize do
68
- puts "-- packages to install --"
69
- Provider.install_PoolParty(true)
70
- end
71
59
  desc "Authorize base ports for application"
72
60
  task :authorize_ports => :initialize do
73
61
  run <<-EOR
data/tasks/ec2.rake CHANGED
@@ -1,20 +1,5 @@
1
- namespace(:ec2) do
1
+ namespace(:ec2) do
2
2
  task :init do
3
3
  %x[ec2-authorize default -P icmp -t -1:-1 -s 0.0.0.0/0]
4
4
  end
5
- # Start a new instance in the cloud
6
- desc "Add and start an instance to the pool"
7
- task :start_new_instance => [:init] do
8
- puts PoolParty::Remoting.new.launch_new_instance!
9
- end
10
- # Stop all the instances via command-line
11
- desc "Stop all running instances"
12
- task :stop_running_instances => [:init] do
13
- Thread.new {`ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2}' | xargs ec2-terminate-instances`}
14
- end
15
- # Reboot the instances via commandline
16
- desc "Restart all running instances"
17
- task :restart_running_instances => [:init] do
18
- Thread.new {`ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2}' | xargs ec2-reboot-instances`}
19
- end
20
5
  end
data/tasks/instance.rake CHANGED
@@ -1,63 +1,2 @@
1
1
  namespace(:instance) do
2
- # Find the instance we want to deal with
3
- # interface can be: num=0, i=0, inst=0, 0
4
- # defaults to the master instance (0)
5
- task :init do
6
- num = (ENV['num'] || ENV["i"] || ENV["inst"] || ARGV.shift || 0).to_i
7
- raise Exception.new("Please set the number of the instance (i.e. num=1, i=1, or as an argument)") unless num
8
- @node = PoolParty::Master.new.get_node(num)
9
- end
10
- # Ssh into the node
11
- desc "Remotely login to the remote instance"
12
- task :ssh => [:init] do
13
- @node.ssh
14
- end
15
- desc "Send a file to the remote instance"
16
- task :exec => :init do
17
- @node.ssh ENV['cmd']
18
- end
19
- # Send a file to the remote instance
20
- # as designated by src='' and dest=''
21
- desc "Send a file to the remote instance"
22
- task :scp => :init do
23
- @node.scp ENV['src'], ENV['dest']
24
- end
25
- # Execute a command on the remote instance as designated
26
- # by cmd=''
27
- desc "Execute cmd on a remote instance"
28
- task :exec => [:init] do
29
- cmd = ENV['cmd'] || "ls -l"
30
- puts @node.ssh(cmd.runnable)
31
- end
32
- # Restart all the services monitored by monit
33
- desc "Restart all the services"
34
- task :reload => [:init] do
35
- @node.restart_with_monit
36
- end
37
- # Start all the services monitored by monit
38
- desc "Start all services"
39
- task :load => [:init] do
40
- @node.start_with_monit
41
- end
42
- # Stop the services monitored by monit
43
- desc "Stop all services"
44
- task :stop => [:init] do
45
- @node.stop_with_monit
46
- end
47
- # Install the required services on this node
48
- desc "Install stack on this node"
49
- task :install => :init do
50
- @node.install
51
- end
52
- # Turnoff this instance
53
- desc "Teardown instance"
54
- task :shutdown => :init do
55
- `ec2-terminate-instances #{@node.instance_id}`
56
- end
57
- # Configure this node and start the services
58
- desc "Configure the stack on this node"
59
- task :configure => :init do
60
- @node.configure
61
- @node.restart_with_monit
62
- end
63
2
  end