auser-poolparty 0.2.35 → 0.2.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Manifest.txt +5 -9
  2. data/bin/cloud-start +1 -1
  3. data/lib/erlang/messenger/ebin/master_app.beam +0 -0
  4. data/lib/erlang/messenger/ebin/node_app.beam +0 -0
  5. data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
  6. data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
  7. data/lib/erlang/messenger/ebin/pm_event_manager.beam +0 -0
  8. data/lib/erlang/messenger/ebin/pm_master_event_handler.beam +0 -0
  9. data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
  10. data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
  11. data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
  12. data/lib/erlang/messenger/src/pm_client.erl +19 -13
  13. data/lib/erlang/messenger/src/pm_cluster.erl +7 -6
  14. data/lib/erlang/messenger/src/pm_master.erl +5 -8
  15. data/lib/poolparty/aska/aska.rb +111 -0
  16. data/lib/poolparty/base_packages/poolparty.rb +23 -13
  17. data/lib/poolparty/core/array.rb +3 -0
  18. data/lib/poolparty/core/kernel.rb +2 -2
  19. data/lib/poolparty/core/object.rb +17 -1
  20. data/lib/poolparty/core/symbol.rb +6 -0
  21. data/lib/poolparty/helpers/provisioner_base.rb +3 -7
  22. data/lib/poolparty/helpers/provisioners/master.rb +9 -6
  23. data/lib/poolparty/helpers/provisioners/slave.rb +3 -4
  24. data/lib/poolparty/monitors/base_monitor.rb +32 -5
  25. data/lib/poolparty/{helpers → net}/messenger.rb +1 -1
  26. data/lib/poolparty/net/remoter.rb +4 -3
  27. data/lib/poolparty/pool/cloud.rb +1 -1
  28. data/lib/poolparty/pool/script.rb +1 -1
  29. data/lib/poolparty/templates/puppetcleaner +3 -1
  30. data/lib/poolparty/version.rb +1 -1
  31. data/lib/poolparty.rb +1 -1
  32. data/poolparty.gemspec +7 -11
  33. data/spec/poolparty/aska/aska_spec.rb +97 -0
  34. data/spec/poolparty/monitors/base_monitor_spec.rb +83 -2
  35. data/spec/poolparty/monitors/monitors/cpu_monitor_spec.rb +0 -1
  36. data/spec/poolparty/{helpers → net}/messenger_spec.rb +2 -0
  37. data/spec/poolparty/net/remote_bases/ec2_spec.rb +3 -2
  38. data/spec/poolparty/net/remote_instance_spec.rb +1 -0
  39. data/spec/poolparty/net/remote_spec.rb +8 -1
  40. data/spec/poolparty/net/remoter_base_spec.rb +4 -1
  41. data/spec/poolparty/net/remoter_spec.rb +5 -0
  42. data/spec/poolparty/pool/cloud_spec.rb +2 -0
  43. data/spec/poolparty/pool/plugin_model_spec.rb +1 -0
  44. data/spec/poolparty/pool/resource_spec.rb +3 -0
  45. data/spec/poolparty/pool/script_spec.rb +14 -2
  46. data/spec/poolparty/spec_helper.rb +13 -1
  47. data/website/index.html +1 -1
  48. metadata +7 -11
  49. data/lib/erlang/messenger/utils.beam +0 -0
data/Manifest.txt CHANGED
@@ -37,6 +37,7 @@ bin/server-start-master
37
37
  bin/server-start-node
38
38
  config/hoe.rb
39
39
  config/requirements.rb
40
+ erl_crash.dump
40
41
  examples/basic.rb
41
42
  examples/plugin_without_plugin_directory.rb
42
43
  examples/poolparty.rb
@@ -143,8 +144,8 @@ lib/erlang/messenger/src/pm_node_supervisor.erl
143
144
  lib/erlang/messenger/src/pm_packager.erl
144
145
  lib/erlang/messenger/src/utils.erl
145
146
  lib/erlang/messenger/useful_snippets
146
- lib/erlang/messenger/utils.beam
147
147
  lib/poolparty.rb
148
+ lib/poolparty/aska/aska.rb
148
149
  lib/poolparty/base_packages/haproxy.rb
149
150
  lib/poolparty/base_packages/heartbeat.rb
150
151
  lib/poolparty/base_packages/poolparty.rb
@@ -176,7 +177,6 @@ lib/poolparty/exceptions/UnacceptableCommand.rb
176
177
  lib/poolparty/helpers/binary.rb
177
178
  lib/poolparty/helpers/console.rb
178
179
  lib/poolparty/helpers/display.rb
179
- lib/poolparty/helpers/messenger.rb
180
180
  lib/poolparty/helpers/optioner.rb
181
181
  lib/poolparty/helpers/provisioner_base.rb
182
182
  lib/poolparty/helpers/provisioners/master.rb
@@ -194,6 +194,7 @@ lib/poolparty/modules/safe_instance.rb
194
194
  lib/poolparty/monitors/base_monitor.rb
195
195
  lib/poolparty/monitors/monitors/cpu_monitor.rb
196
196
  lib/poolparty/monitors/monitors/memory_monitor.rb
197
+ lib/poolparty/net/messenger.rb
197
198
  lib/poolparty/net/remote.rb
198
199
  lib/poolparty/net/remote_bases/ec2.rb
199
200
  lib/poolparty/net/remote_instance.rb
@@ -225,12 +226,6 @@ lib/poolparty/pool/resources/sshkey.rb
225
226
  lib/poolparty/pool/resources/symlink.rb
226
227
  lib/poolparty/pool/resources/variable.rb
227
228
  lib/poolparty/pool/script.rb
228
- lib/poolparty/pool/tmp/.ppkeys
229
- lib/poolparty/pool/tmp/happydayz
230
- lib/poolparty/pool/tmp/install_master.sh
231
- lib/poolparty/pool/tmp/pool.spec
232
- lib/poolparty/pool/tmp/poolparty.pp
233
- lib/poolparty/pool/tmp/tc-instances.list
234
229
  lib/poolparty/templates/authkeys
235
230
  lib/poolparty/templates/cib.xml
236
231
  lib/poolparty/templates/gem
@@ -248,6 +243,7 @@ script/destroy
248
243
  script/generate
249
244
  script/txt2html
250
245
  setup.rb
246
+ spec/poolparty/aska/aska_spec.rb
251
247
  spec/poolparty/base_packages/haproxy_spec.rb
252
248
  spec/poolparty/base_packages/heartbeat_spec.rb
253
249
  spec/poolparty/bin/console_spec.rb
@@ -262,7 +258,6 @@ spec/poolparty/core/time_spec.rb
262
258
  spec/poolparty/dependency_resolutions/base_spec.rb
263
259
  spec/poolparty/helpers/binary_spec.rb
264
260
  spec/poolparty/helpers/display_spec.rb
265
- spec/poolparty/helpers/messenger_spec.rb
266
261
  spec/poolparty/helpers/optioner_spec.rb
267
262
  spec/poolparty/helpers/provisioner_base_spec.rb
268
263
  spec/poolparty/helpers/provisioners/master_spec.rb
@@ -274,6 +269,7 @@ spec/poolparty/modules/file_writer_spec.rb
274
269
  spec/poolparty/modules/s3_string_spec.rb
275
270
  spec/poolparty/monitors/base_monitor_spec.rb
276
271
  spec/poolparty/monitors/monitors/cpu_monitor_spec.rb
272
+ spec/poolparty/net/messenger_spec.rb
277
273
  spec/poolparty/net/remote_bases/ec2_spec.rb
278
274
  spec/poolparty/net/remote_instance_spec.rb
279
275
  spec/poolparty/net/remote_spec.rb
data/bin/cloud-start CHANGED
@@ -14,7 +14,7 @@ load_pool(o.spec || Binary.get_existing_spec_location)
14
14
 
15
15
  @clouds.each do |name, cloud|
16
16
 
17
- with_cloud(cloud, {:testing => @testing}) do
17
+ with_cloud(cloud, {:testing => @testing, :verbose => (o.verbose || false)}) do
18
18
  puts header("Starting cloud")
19
19
  puts "#{list_of_running_instances.size} running instances (#{minimum_instances} - #{maximum_instances})"
20
20
  if list_of_running_instances.size != 1
@@ -1,27 +1,35 @@
1
1
  -module (pm_client).
2
2
  -include_lib("../include/defines.hrl").
3
- -define (SERVER, global:whereis_name(?MODULE)).
4
3
 
5
- -export ([init_conn/0, send_cmd/1, reconfigure_cloud/0, get_load/1, get_live_nodes/0]).
4
+ -export ([reconfigure_cloud/0, get_load/1, get_live_nodes/0, start/0]).
5
+ -export ([run_cmd/1, fire_cmd/1]).
6
6
  -export ([provision_orphan_running_servers/0]).
7
7
  -export ([shutdown/0]).
8
8
  % Run commands on the running master process
9
9
  % erl -pa ./ebin/ -run pm_client get_load cpu -run init stop -noshell
10
10
 
11
11
  % Connect to the master
12
- init_conn() -> net_adm:ping(?MASTER_LOCATION).
12
+ start() ->
13
+ pong = net_adm:ping(?MASTER_LOCATION),
14
+ global:sync().
13
15
  % Send the command Cmd to the pm_master process
14
- send_cmd(Cmd) ->
15
- init_conn(),
16
- pm_master:fire_cmd(Cmd).
16
+ run_cmd(Cmd) ->
17
+ Out = pm_master:run_cmd(Cmd),
18
+ io:format("~p", [Out]),
19
+ Out.
20
+ fire_cmd(Cmd) ->
21
+ Out = pm_master:fire_cmd(Cmd),
22
+ io:format("~p", [Out]),
23
+ Out.
17
24
  % Reconfigure the cloud
18
- reconfigure_cloud() ->
19
- init_conn(),
20
- pm_master:reconfigure_cloud().
25
+ reconfigure_cloud() -> pm_master:reconfigure_cloud().
21
26
  % Get the load on the cloud of type Type
22
27
  get_load(Type) ->
23
- init_conn(),
24
- pm_master:get_load(Type).
28
+ start(),
29
+ Load = pm_master:get_load(Type),
30
+ io:format("~p", [Load]),
31
+ Load.
32
+
25
33
  % Check to see if there are servers that are unprovisioned
26
34
  % And if there are, log in to them and start their messenger
27
35
  % sending the live code on the master to them
@@ -38,10 +46,8 @@ provision_orphan_running_servers() ->
38
46
 
39
47
  % Get a list of the live nodes
40
48
  get_live_nodes() ->
41
- init_conn(),
42
49
  pm_cluster:get_live_nodes().
43
50
  % Terminate the cloud messenger
44
51
  % This sends a shutdown to the whole cloud
45
52
  shutdown() ->
46
- init_conn(),
47
53
  pm_master:shutdown_cloud().
@@ -30,8 +30,7 @@ slaves([Host|Hosts]) ->
30
30
  io:format("Erlang node started = [~p]~n", [Node]),
31
31
  slaves(Hosts).
32
32
 
33
- slaves() ->
34
- get_live_nodes().
33
+ slaves() -> get_live_nodes().
35
34
 
36
35
  erl_system_args()->
37
36
  Shared = case init:get_argument(shared) of
@@ -46,15 +45,17 @@ erl_system_args()->
46
45
 
47
46
  any_new_servers() ->
48
47
  String = ". /etc/profile && server-list-active -c name",
49
- Nodes = lists:map(fun
48
+ NodesFromActive = lists:map(fun
50
49
  (No) ->
51
50
  erlang:list_to_atom(lists:append([No, "@", No]))
52
51
  end,string:tokens(os:cmd(String), "\n\t")),
53
- NewServers = Nodes -- get_live_nodes(),
52
+ % Nodes -- get_live_nodes(),
53
+ NewServers = [X || X <- NodesFromActive, (lists:member(X, get_live_nodes()) /= true) ],
54
54
  NewServers.
55
55
 
56
- % Get the live nodes
56
+ % Get the live nodes that are NOT client nodes
57
57
  get_live_nodes() ->
58
- nodes().
58
+ ClientString = "client",
59
+ [X || X <- nodes(), (erlang:is_atom(regexp:first_match(erlang:atom_to_list(X), ClientString))) ].
59
60
  %% Do not forget to start erlang with a command like:
60
61
  %% erl -rsh ssh -sname clustmaster
@@ -21,7 +21,7 @@
21
21
  terminate/2, code_change/3]).
22
22
 
23
23
  % Client function definitions
24
- -export ([get_load/1, reconfigure_cloud/0, get_live_nodes/0]).
24
+ -export ([get_load/1, reconfigure_cloud/0]).
25
25
  -export ([run_cmd/1, fire_cmd/1]).
26
26
  -export ([shutdown_cloud/0]).
27
27
 
@@ -36,7 +36,6 @@
36
36
  get_load(Type) ->
37
37
  % {Loads, _} = pm_cluster:send_call(get_load_for_type, [Type]),
38
38
  {Loads, _} = gen_server:call(?SERVER, {get_load_for_type, [Type]}),
39
- io:format("Loads: ~p~n", [Loads]),
40
39
  utils:convert_responses_to_int_list(Loads).
41
40
 
42
41
  % Send reconfigure tasks to every node
@@ -46,9 +45,6 @@ reconfigure_cloud() ->
46
45
  % Fire the given command on all nodes
47
46
  run_cmd(Cmd) -> gen_server:call(?SERVER, {run_cmd, Cmd}).
48
47
  fire_cmd(Cmd) -> gen_server:call(?SERVER, {fire_cmd, Cmd}).
49
-
50
- get_live_nodes() ->
51
- nodes().
52
48
 
53
49
  % Shutdown
54
50
  shutdown_cloud() ->
@@ -87,11 +83,12 @@ init([]) ->
87
83
  %%--------------------------------------------------------------------
88
84
  % Handle load messages
89
85
  handle_call({Type, Args}, _From, _State) ->
90
- io:format("Calling ~p with ~p on slaves~n", [Type, Args]),
91
- List = rpc:multicall(get_live_nodes(), pm_node, Type, [Args]),
86
+ Nodes = pm_cluster:get_live_nodes(),
87
+ List = rpc:multicall(Nodes, pm_node, Type, [Args]),
92
88
  {reply, List, nostate};
93
89
  handle_call(Request, _From, State) ->
94
- Reply = Reply = rpc:multicall(get_live_nodes(), pm_node, Request, []),
90
+ Nodes = pm_cluster:get_live_nodes(),
91
+ Reply = Reply = rpc:multicall(Nodes, pm_node, Request, []),
95
92
  {reply, Reply, State}.
96
93
 
97
94
  %%--------------------------------------------------------------------
@@ -0,0 +1,111 @@
1
+ =begin rdoc
2
+ Aska
3
+ TODO: Extract this into a proper gem
4
+ =end
5
+ module Aska
6
+ module ClassMethods
7
+ def rules(name=:rules, arr=[])
8
+ returning look_up_rules(name) do |rs|
9
+ arr.each do |line|
10
+ next unless line
11
+ k = line[/(.+)[=\\\<\>](.*)/, 1].gsub(/\s+/, '')
12
+ v = line[/(.+)[=\\<>](.*)/, 2].gsub(/\s+/, '')
13
+ m = line[/[=\\<>]/, 0].gsub(/\s+/, '')
14
+
15
+ create_instance_variable(k)
16
+ rs << {k => [m, v]}
17
+ end
18
+ self.send(:define_method, name) do
19
+ look_up_rules(name)
20
+ end
21
+ end
22
+ end
23
+ def create_instance_variable(k)
24
+ aska_attr_accessors << k.to_sym unless aska_attr_accessors.include?(k.to_sym)
25
+ attr_reader k.to_sym unless respond_to?("#{k}".to_sym)
26
+ attr_writer k.to_sym unless respond_to?("#{k}=".to_sym)
27
+ end
28
+ def look_up_rules(name)
29
+ defined_rules[name.to_sym] ||= Rules.new
30
+ end
31
+ def are_rules?(name)
32
+ !look_up_rules(name).empty?
33
+ end
34
+ def aska_attr_accessors
35
+ @aska_attr_accessors ||= Rules.new
36
+ end
37
+ def defined_rules
38
+ @defined_rules ||= {}
39
+ end
40
+ def aska_named(name)
41
+ "#{name}_aska"
42
+ end
43
+ end
44
+
45
+ module InstanceMethods
46
+ def rules
47
+ @rules ||= self.class.defined_rules
48
+ end
49
+ def valid_rules?(name=:rules)
50
+ self.class.look_up_rules(name).reject {|rule| valid_rule?(rule) }.empty?
51
+ end
52
+ def __aska_aska_stuff(m)
53
+ if respond_to?(m.to_sym)
54
+ self.send(m.to_sym)
55
+ else
56
+ m
57
+ end
58
+ end
59
+ def valid_rule?(rule)
60
+ rule.each do |key,value|
61
+ begin
62
+ # puts "#{aska(key)} #{value[0].to_sym} #{get_var(value[1])} (#{attr_accessor?(value[1])})"
63
+ return __aska_aska_stuff(key).send(value[0].to_sym, __aska_get_var(value[1]))
64
+ rescue Exception => e
65
+ return false
66
+ end
67
+ end
68
+ end
69
+ # Get the variable from the class
70
+ # If it's defined as an attr_accessor, we know it has been defined as a rule
71
+ # Otherwise, if we are passing it as a
72
+ def __aska_get_var(name)
73
+ # attr_accessor?(name) ? aska(name) :
74
+ (supported_method?(name) ? name.to_sym : name.to_f)
75
+ end
76
+ def __aska_aska(name)
77
+ self.class.aska_named(name)
78
+ end
79
+ def attr_accessor?(name)
80
+ self.class.aska_attr_accessors.include?(name.to_sym)
81
+ end
82
+ def supported_method?(meth)
83
+ %w(< > == => =<).include?("#{meth}")
84
+ end
85
+
86
+ def look_up_rules(r);self.class.look_up_rules(r);end
87
+ def are_rules?(r);self.class.are_rules?(r);end
88
+
89
+ # def method_missing(m, *args, &block)
90
+ # if self.class.defined_rules.has_key?(m.to_sym)
91
+ # self.class.send(:define_method, m) do
92
+ # self.class.look_up_rules(m)
93
+ # end
94
+ # self.send m
95
+ # else
96
+ # super
97
+ # end
98
+ # end
99
+ end
100
+
101
+ def self.included(receiver)
102
+ receiver.extend ClassMethods
103
+ receiver.send :include, InstanceMethods
104
+ end
105
+
106
+ class Rules < Array
107
+ def to_s
108
+ self.map {|r| v=r.keys.first;"'#{v} #{r[v][0]} #{r[v][1]}'"}.join(", ")
109
+ end
110
+ end
111
+ end
@@ -9,24 +9,34 @@ module PoolParty
9
9
 
10
10
  has_package(:name => "rubygems") do |g|
11
11
  # These should be installed automagically by poolparty, but just in case
12
- # TODO: Fix the requires method with a helper
13
- g.has_gempackage(:name => "logging", :download_url => "http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem")
14
- g.has_gempackage(:name => "hoe", :download_url => "http://rubyforge.org/frs/download.php/45685/hoe-1.8.2.gem")
12
+ # TODO: Fix the requires method with a helper
13
+ g.has_gempackage(:name => "flexmock", :download_url => "http://rubyforge.org/frs/download.php/42580/flexmock-0.8.3.gem")
14
+ g.has_gempackage(:name => "lockfile", :download_url => "http://rubyforge.org/frs/download.php/18698/lockfile-1.4.3.gem")
15
+ g.has_gempackage(:name => "logging", :download_url => "http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem", :requires => [get_gempackage("flexmock"), get_gempackage("lockfile")])
16
+
17
+ g.has_gempackage(:name => "rubyforge", :download_url => "http://rubyforge.org/frs/download.php/45546/rubyforge-1.0.1.gem")
18
+ g.has_gempackage(:name => "hoe", :download_url => "http://rubyforge.org/frs/download.php/45685/hoe-1.8.2.gem", :version => "1.8", :requires => get_gempackage("rubyforge"))
19
+ g.has_gempackage(:name => "ZenTest", :download_url => "http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem", :requires => [get_gempackage("hoe"), get_gempackage("rubyforge")])
20
+
15
21
  g.has_gempackage(:name => "rake", :download_url => "http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem")
16
- g.has_gempackage(:name => "xml-simple") do |x|
22
+ g.has_gempackage(:name => "xml-simple", :download_url => "http://rubyforge.org/frs/download.php/18366/xml-simple-1.0.11.gem") do |x|
17
23
  x.has_gempackage(:name => "grempe-amazon-ec2", :download_url => "http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem")
18
24
  end
19
25
 
20
- has_gempackage(:name => "ParseTree", :download_url => "http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem") do |pt|
21
- pt.has_gempackage(:name => "ruby2ruby", :download_url => "http://rubyforge.org/frs/download.php/45587/ruby2ruby-1.2.0.gem")
22
- pt.has_gempackage(:name => "activesupport", :download_url => "http://rubyforge.org/frs/download.php/45627/activesupport-2.1.2.gem") do |a|
23
- a.has_gempackage(:name => "poolparty", :download_url => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true")
24
- end
25
- has_gempackage(:name => "RubyInline", :download_url => "http://rubyforge.org/frs/download.php/45683/RubyInline-3.8.1.gem")
26
+ has_gempackage(:name => "sexp_processor", :download_url => "http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem")
27
+ has_gempackage(:name => "ParseTree", :download_url => "http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem", :requires => [get_gempackage("sexp_processor"), get_gempackage("ZenTest")])
26
28
 
27
- has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger", :requires => get_gempackage("poolparty"))
28
- has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node", :requires => get_exec("build_messenger"))
29
- end
29
+ has_gempackage(:name => "ruby2ruby", :download_url => "http://rubyforge.org/frs/download.php/45587/ruby2ruby-1.2.0.gem", :requires => get_gempackage("ParseTree"))
30
+
31
+ has_gempackage(:name => "activesupport", :download_url => "http://rubyforge.org/frs/download.php/45627/activesupport-2.1.2.gem")
32
+
33
+ has_gempackage(:name => "aska", :download_url => "http://github.com/auser/aska/tree/master%2Fpkg%2Faska-latest.gem?raw=true", :requires => get_gempackage("ruby2ruby"))
34
+ has_gempackage(:name => "RubyInline", :download_url => "http://rubyforge.org/frs/download.php/45683/RubyInline-3.8.1.gem")
35
+
36
+ has_gempackage(:name => "poolparty", :download_url => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true", :requires => [get_gempackage("ruby2ruby"), get_gempackage("RubyInline"), get_gempackage("aska"), get_gempackage("ParseTree")])
37
+
38
+ has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger", :requires => get_gempackage("poolparty"))
39
+ has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node", :requires => get_exec("build_messenger"))
30
40
 
31
41
  end
32
42
 
@@ -24,4 +24,7 @@ class Array
24
24
  def to_option_string(ns=[])
25
25
  "[ #{map {|e| e.to_option_string }.join(", ")} ]"
26
26
  end
27
+ def respec_string(ns=[])
28
+ "'#{map {|e| e.to_option_string }.join("', '")}'"
29
+ end
27
30
  end
@@ -10,10 +10,10 @@ module Kernel
10
10
  block.in_context(klass_or_obj).call
11
11
  end
12
12
  def load_p(dir)
13
- Dir["#{dir}/*.rb"].each do |file|
13
+ Dir["#{dir}/*.rb"].sort.each do |file|
14
14
  require "#{file}" if ::FileTest.file?(file)
15
15
  end
16
- Dir["#{dir}/*"].each do |dir|
16
+ Dir["#{dir}/*"].sort.each do |dir|
17
17
  load_p(dir) if ::FileTest.directory?(dir)
18
18
  end
19
19
  end
@@ -44,6 +44,16 @@ class Object
44
44
  "#{self}"
45
45
  end
46
46
  end
47
+ def respec_string
48
+ case self.class
49
+ when String
50
+ self.to_option_string
51
+ when Array
52
+ self.map {|a| "#{a.respec_string}" }.join(" ")
53
+ else
54
+ "'#{self}'"
55
+ end
56
+ end
47
57
  def block_instance_eval(*args, &block)
48
58
  return instance_eval(*args,&block) unless block_given? && !block.arity.zero?
49
59
  old_method = (self.class.instance_method(:__) rescue nil)
@@ -63,7 +73,7 @@ class Object
63
73
  meta_eval { remove_method name }
64
74
  end
65
75
  def run_in_context(&block)
66
- name="temp_#{self.class}_#{parent.to_s}".to_sym
76
+ name="temp_#{self.class}_#{respond_to?(:parent) ? parent.to_s : Time.now.to_i}".to_sym
67
77
  meta_def name, &block
68
78
  self.send name, self
69
79
  # self.instance_eval &block if block
@@ -72,4 +82,10 @@ class Object
72
82
  def vputs(m="", o=self)
73
83
  puts m if o.verbose
74
84
  end
85
+ def vprint(m="", o=self)
86
+ print m if o.verbose
87
+ end
88
+ def unix_hide_string
89
+ "2>&1 > /dev/null"
90
+ end
75
91
  end
@@ -1,4 +1,10 @@
1
1
  class Symbol
2
+ # def >(num);"#{self} > #{num}";end
3
+ # def <(num);"#{self} < #{num}";end
4
+ # def >=(num);"#{self} >= #{num}";end
5
+ # def <=(num);"#{self} <= #{num}";end
6
+ # def ==(num);"#{self} > #{num}";end
7
+
2
8
  def to_string(pre="")
3
9
  "#{pre}#{self.to_s}"
4
10
  end
@@ -97,12 +97,8 @@ module PoolParty
97
97
  verbose ? @cloud.run_command_on(cmd, @instance) : hide_output {@cloud.run_command_on(cmd, @instance)}
98
98
 
99
99
  process_clean_reconfigure_for!(@instance)
100
- after_install(@instance)
101
-
100
+ after_install(@instance)
102
101
  end
103
- # We have to get the right generated data into the manifest
104
- # TODO: Clean this setup
105
- @cloud.provisioning_complete
106
102
  end
107
103
  # Install callbacks
108
104
  # Before installation callback
@@ -138,7 +134,7 @@ module PoolParty
138
134
  # puppetca --clean #{instance.name}.compute-1.internal; puppetca --clean #{instance.name}.ec2.internal
139
135
  # find /etc/puppet/ssl -type f -exec rm {} \;
140
136
  command = <<-EOE
141
- if [ -f '/usr/bin/puppetcleaner' ]; then /usr/bin/puppetcleaner; fi
137
+ if [ -f '/usr/bin/puppetcleaner' ]; then /usr/bin/env puppetcleaner; fi
142
138
  EOE
143
139
  @cloud.run_command_on(command, @cloud.master) unless testing
144
140
  end
@@ -282,7 +278,7 @@ echo 'deb http://mirrors.kernel.org/ubuntu hardy main universe' >> /etc/apt/sour
282
278
  aptitude update -y <<heredoc
283
279
  Y
284
280
  heredoc
285
- aptitude autoclean
281
+ aptitude autoclean #{unix_hide_string}
286
282
  fi
287
283
  "
288
284
  else
@@ -132,11 +132,13 @@ wget http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem -O rake.gem 2>&1
132
132
  wget http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem -O sexp_processor.gem 2>&1
133
133
  wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1
134
134
  wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1
135
+ wget http://github.com/auser/aska/tree/master%2Fpkg%2Faska-latest.gem?raw=true -O aska.gem 2>&1
135
136
 
136
137
  #{
137
- %w(rake lockfile rubyforge hoe zentest sexp_processor flexmock logging activesupport RubyInline ParseTree ruby2ruby xml-simple poolparty-latest amazon-ec2).map do |dep|
138
- "gem install -y --no-ri --no-rdoc #{dep}.gem\n"
139
- end
138
+ %w(rake lockfile rubyforge hoe zentest sexp_processor flexmock logging activesupport
139
+ RubyInline ParseTree ruby2ruby xml-simple aska poolparty-latest amazon-ec2).map do |dep|
140
+ "gem install --ignore-dependencies -y --no-ri --no-rdoc #{dep}.gem"
141
+ end.join("\n")
140
142
  }
141
143
 
142
144
  # gem install -y --no-ri --no-rdoc --source http://gems.github.com grempe-amazon-ec2
@@ -147,15 +149,16 @@ wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-
147
149
  # ps aux | grep puppetmasterd | awk '{print $2}' | xargs kill
148
150
  # rm -rf /etc/puppet/ssl
149
151
  def start_puppetmaster
150
- <<-EOS
151
- puppetmasterd --verbose
152
+ <<-EOS
153
+ /usr/bin/env puppetcleaner 2>&1 > /dev/null
154
+ puppetmasterd --verbose 2>&1 > /dev/null
152
155
  EOS
153
156
  end
154
157
 
155
158
  # puppetd --listen --fqdn #{@instance.name}
156
159
  def restart_puppetd
157
160
  <<-EOS
158
- . /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1
161
+ . /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1 > /dev/null
159
162
  EOS
160
163
  end
161
164
  end
@@ -26,16 +26,15 @@ module PoolParty
26
26
  def setup_configs
27
27
  <<-EOS
28
28
  echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
29
+ rm -rf /etc/puppet/ssl
29
30
  EOS
30
31
  end
31
32
 
32
33
  # /etc/init.d/puppetmasterd stop
33
34
  # puppetd --listen --fqdn #{@instance.name}
34
35
  def start_puppet
35
- <<-EOS
36
- /etc/init.d/puppetmaster start
37
- /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1
38
- # rm -rf /etc/puppet/ssl/*
36
+ <<-EOS
37
+ /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1
39
38
  EOS
40
39
  end
41
40
 
@@ -4,11 +4,26 @@
4
4
  TODO: Fill this out
5
5
  =end
6
6
  module PoolParty
7
- module Monitors
7
+ module Monitors
8
+
9
+ module ClassMethods
10
+ end
11
+
12
+ module InstanceMethods
13
+ def expand_when(*arr)
14
+ @expand_when ||= ((arr && arr.empty?) ? options[:expand_when] : configure(:expand_when => self.class.send(:rules, :expand_when, arr)))
15
+ end
16
+
17
+ def contract_when(*arr)
18
+ @contract_when ||= ((arr && arr.empty?) ? options[:contract_when] : configure(:contract_when => self.class.send(:rules, :contract_when, arr)))
19
+ end
20
+ end
8
21
 
9
22
  def self.register_monitor(*args)
10
23
  args.each do |arg|
11
24
  (available_monitors << "#{arg}".downcase.to_sym)
25
+
26
+ InstanceMethods.module_eval "def #{arg}; PoolParty::Messenger.messenger_send!(\"get_load #{arg}\"); end"
12
27
  end
13
28
  end
14
29
 
@@ -16,15 +31,27 @@ module PoolParty
16
31
  $available_monitors ||= []
17
32
  end
18
33
 
19
- class BaseMonitor
20
-
34
+ class BaseMonitor
21
35
  def self.run
22
36
  new.run
23
37
  end
24
-
38
+ end
39
+
40
+ def self.included(receiver)
41
+ receiver.extend PoolParty::Monitors::ClassMethods
42
+ receiver.send :include, PoolParty::Monitors::InstanceMethods
43
+ receiver.send :include, Aska
25
44
  end
26
45
 
27
46
  end
28
47
  end
29
48
 
30
- Dir["#{File.dirname(__FILE__)}/monitors/*.rb"].each {|f| require f}
49
+ Dir["#{File.dirname(__FILE__)}/monitors/*.rb"].each {|f| require f}
50
+
51
+ module PoolParty
52
+ module Cloud
53
+ class Cloud
54
+ include PoolParty::Monitors
55
+ end
56
+ end
57
+ end
@@ -16,7 +16,7 @@ module PoolParty
16
16
  end
17
17
 
18
18
  def self.messenger_send!(cmd="", testing=false)
19
- command = Messenger.erl_command("client", "-rsh ssh -noshell -run pm_client #{cmd} -s erlang halt")
19
+ command = Messenger.erl_command("client", "-s pm_client -run pm_client #{cmd} -s erlang halt -noshell")
20
20
  testing ? command : %x[#{command}]
21
21
  end
22
22
 
@@ -127,10 +127,11 @@ module PoolParty
127
127
  # pending instances and then running the block
128
128
  def when_no_pending_instances(&block)
129
129
  reset!
130
+ vputs "Waiting for there to be no pending instances..."
130
131
  if list_of_pending_instances.size == 0
131
132
  block.call if block
132
133
  else
133
- vputs "Waiting for there to be no pending instances..."
134
+ vprint "."
134
135
  wait "5.seconds"
135
136
  when_no_pending_instances(&block)
136
137
  end
@@ -167,11 +168,11 @@ module PoolParty
167
168
  end
168
169
  # Stub method for the time being to handle expansion of the cloud
169
170
  def should_expand_cloud?(force=false)
170
- force || false
171
+ valid_rules?(:expansions) || force || false
171
172
  end
172
173
  # Stub method for the time being to handle the contraction of the cloud
173
174
  def should_contract_cloud?(force=false)
174
- force || false
175
+ valid_rules?(:contractions) || force || false
175
176
  end
176
177
  # Expand the cloud
177
178
  # If we can start a new instance and the load requires us to expand