poolparty 0.2.6 → 0.2.18
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +123 -4
- data/PostInstall.txt +2 -1
- data/bin/cloud +16 -7
- data/bin/cloud-provision +9 -5
- data/bin/cloud-run +19 -0
- data/bin/cloud-ssh +2 -7
- data/bin/cloud-start +2 -1
- data/bin/pool +3 -3
- data/bin/server-build-messenger +20 -0
- data/bin/server-fire-cmd +14 -0
- data/bin/server-get-load +29 -0
- data/bin/server-list-active +25 -0
- data/bin/server-list-responding +24 -0
- data/bin/server-rerun +24 -0
- data/bin/server-start-master +27 -0
- data/bin/server-start-node +33 -0
- data/config/requirements.rb +1 -1
- data/erl_crash.dump +8409 -0
- data/lib/erlang/messenger/Emakefile +1 -0
- data/lib/erlang/messenger/Makefile +15 -0
- data/lib/erlang/messenger/README +5 -0
- data/lib/erlang/messenger/Rakefile +60 -0
- data/lib/erlang/messenger/control +11 -0
- data/lib/erlang/messenger/ebin/master.app +19 -0
- data/lib/erlang/messenger/ebin/master_app.beam +0 -0
- data/lib/erlang/messenger/ebin/node.app +19 -0
- data/lib/erlang/messenger/ebin/node_app.beam +0 -0
- data/lib/erlang/messenger/ebin/packager.app +19 -0
- data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_event_handler.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +1 -0
- data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +1 -0
- data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
- data/lib/erlang/messenger/ebin/utils.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/AUTHORS +2 -0
- data/lib/erlang/messenger/lib/eunit/CHANGELOG +14 -0
- data/lib/erlang/messenger/lib/eunit/COPYING +504 -0
- data/lib/erlang/messenger/lib/eunit/Makefile +28 -0
- data/lib/erlang/messenger/lib/eunit/NOTES +276 -0
- data/lib/erlang/messenger/lib/eunit/README +3 -0
- data/lib/erlang/messenger/lib/eunit/doc/edoc-info +3 -0
- data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
- data/lib/erlang/messenger/lib/eunit/doc/eunit.html +172 -0
- data/lib/erlang/messenger/lib/eunit/doc/index.html +17 -0
- data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +12 -0
- data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +984 -0
- data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +980 -0
- data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +11 -0
- data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +55 -0
- data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +21 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +1 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +339 -0
- data/lib/erlang/messenger/lib/eunit/examples/fib.erl +19 -0
- data/lib/erlang/messenger/lib/eunit/examples/tests.txt +1 -0
- data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +313 -0
- data/lib/erlang/messenger/lib/eunit/src/Makefile +46 -0
- data/lib/erlang/messenger/lib/eunit/src/autoload.erl +388 -0
- data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +243 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +21 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +1 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.erl +196 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +102 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +798 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +48 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +682 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +552 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +157 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +340 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +64 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +334 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +45 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +272 -0
- data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +409 -0
- data/lib/erlang/messenger/lib/eunit/sys.config +9 -0
- data/lib/erlang/messenger/lib/eunit/vsn.mk +1 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.script +242 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.script +242 -0
- data/lib/erlang/messenger/src/master_app.erl +39 -0
- data/lib/erlang/messenger/src/node_app.erl +39 -0
- data/lib/erlang/messenger/src/pm_client.erl +19 -0
- data/lib/erlang/messenger/src/pm_cluster.erl +57 -0
- data/lib/erlang/messenger/src/pm_event_handler.erl +21 -0
- data/lib/erlang/messenger/src/pm_master.erl +118 -0
- data/lib/erlang/messenger/src/pm_master_supervisor.erl +40 -0
- data/lib/erlang/messenger/src/pm_node.erl +124 -0
- data/lib/erlang/messenger/src/pm_node_supervisor.erl +40 -0
- data/lib/erlang/messenger/src/pm_packager.erl +73 -0
- data/lib/erlang/messenger/src/utils.erl +38 -0
- data/lib/poolparty/base_packages/haproxy.rb +9 -2
- data/lib/poolparty/base_packages/heartbeat.rb +40 -28
- data/lib/poolparty/base_packages/poolparty.rb +39 -16
- data/lib/poolparty/base_packages/ruby.rb +2 -3
- data/lib/poolparty/config/allowed_commands.yml +1 -0
- data/lib/poolparty/core/array.rb +5 -2
- data/lib/poolparty/core/hash.rb +16 -2
- data/lib/poolparty/core/string.rb +9 -2
- data/lib/poolparty/core/symbol.rb +2 -2
- data/lib/poolparty/dependency_resolutions/base.rb +12 -0
- data/lib/poolparty/dependency_resolutions/puppet.rb +49 -0
- data/lib/poolparty/exceptions/UnacceptableCommand.rb +5 -0
- data/lib/poolparty/helpers/console.rb +3 -2
- data/lib/poolparty/helpers/display.rb +3 -3
- data/lib/poolparty/helpers/messenger.rb +29 -0
- data/lib/poolparty/helpers/optioner.rb +6 -2
- data/lib/poolparty/helpers/provisioner_base.rb +18 -11
- data/lib/poolparty/helpers/provisioners/master.rb +24 -22
- data/lib/poolparty/helpers/provisioners/slave.rb +8 -4
- data/lib/poolparty/modules/definable_resource.rb +1 -0
- data/lib/poolparty/modules/file_writer.rb +11 -10
- data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
- data/lib/poolparty/modules/pretty_printer.rb +11 -11
- data/lib/poolparty/modules/resourcing_dsl.rb +61 -0
- data/lib/poolparty/monitors/base_monitor.rb +17 -3
- data/lib/poolparty/monitors/monitors/cpu_monitor.rb +15 -0
- data/lib/poolparty/monitors/monitors/memory_monitor.rb +23 -0
- data/lib/poolparty/net/remote_instance.rb +6 -1
- data/lib/poolparty/net/remoter.rb +23 -5
- data/lib/poolparty/net/remoter_base.rb +5 -1
- data/lib/poolparty/plugins/git.rb +22 -24
- data/lib/poolparty/pool/base.rb +22 -6
- data/lib/poolparty/pool/cloud.rb +28 -4
- data/lib/poolparty/pool/custom_resource.rb +6 -6
- data/lib/poolparty/pool/loggable.rb +3 -0
- data/lib/poolparty/pool/pool.rb +1 -1
- data/lib/poolparty/pool/resource.rb +58 -94
- data/lib/poolparty/pool/resources/class_package.rb +6 -6
- data/lib/poolparty/pool/resources/conditional.rb +5 -1
- data/lib/poolparty/pool/resources/exec.rb +6 -2
- data/lib/poolparty/pool/resources/gem.rb +22 -8
- data/lib/poolparty/pool/resources/remote_file.rb +5 -1
- data/lib/poolparty/pool/resources/symlink.rb +25 -0
- data/lib/poolparty/pool/resources/variable.rb +8 -7
- data/lib/poolparty/pool/tmp/.ppkeys +3 -0
- data/lib/poolparty/pool/tmp/happydayz +1 -0
- data/lib/poolparty/pool/tmp/install_master.sh +33 -0
- data/lib/poolparty/pool/tmp/pool.spec +11 -0
- data/lib/poolparty/pool/tmp/poolparty.pp +600 -0
- data/lib/poolparty/pool/tmp/tc-instances.list +1 -0
- data/lib/poolparty/templates/cib.xml +54 -0
- data/lib/poolparty/templates/ha.cf +12 -3
- data/lib/poolparty/templates/haproxy.conf +3 -3
- data/lib/poolparty/templates/haresources +3 -0
- data/lib/poolparty/templates/poolparty.monitor +14 -0
- data/lib/poolparty/templates/puppet.conf +3 -4
- data/lib/poolparty/version.rb +1 -1
- data/lib/poolparty.rb +9 -6
- data/poolparty.gemspec +7 -6
- data/setup.rb +3 -3
- data/spec/poolparty/bin/console_spec.rb +1 -1
- data/spec/poolparty/core/array_spec.rb +5 -0
- data/spec/poolparty/core/hash_spec.rb +19 -1
- data/spec/poolparty/core/string_spec.rb +13 -0
- data/spec/poolparty/dependency_resolutions/base_spec.rb +11 -0
- data/spec/poolparty/helpers/messenger_spec.rb +14 -0
- data/spec/poolparty/helpers/optioner_spec.rb +2 -1
- data/spec/poolparty/helpers/provisioner_base_spec.rb +1 -1
- data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +3 -3
- data/spec/poolparty/modules/file_writer_spec.rb +9 -0
- data/spec/poolparty/monitors/base_monitor_spec.rb +19 -0
- data/spec/poolparty/monitors/monitors/cpu_monitor_spec.rb +17 -0
- data/spec/poolparty/net/remote_instance_spec.rb +6 -1
- data/spec/poolparty/net/remote_spec.rb +51 -42
- data/spec/poolparty/net/remoter_spec.rb +2 -1
- data/spec/poolparty/plugins/git_spec.rb +2 -2
- data/spec/poolparty/pool/base_spec.rb +20 -2
- data/spec/poolparty/pool/cloud_spec.rb +30 -1
- data/spec/poolparty/pool/custom_resource_spec.rb +2 -2
- data/spec/poolparty/pool/plugin_spec.rb +4 -4
- data/spec/poolparty/pool/pool_spec.rb +1 -1
- data/spec/poolparty/pool/resource_spec.rb +66 -0
- data/spec/poolparty/pool/resources/gem_spec.rb +29 -3
- data/spec/poolparty/pool/resources/symlink_spec.rb +22 -0
- data/spec/poolparty/pool/resources/variable_spec.rb +4 -0
- data/spec/poolparty/spec_helper.rb +5 -0
- data/tasks/cloud.rake +0 -54
- data/tasks/development.rake +0 -12
- data/tasks/ec2.rake +1 -16
- data/tasks/instance.rake +0 -61
- data/test_manifest.pp +286 -166
- data/website/index.html +5 -5
- data/website/index.txt +3 -3
- metadata +137 -8
- data/bin/pool-start-monitor +0 -1
- data/lib/erlang/eb_server.erl +0 -27
- data/lib/poolparty/plugins/gem_package.rb +0 -17
- data/spec/poolparty/modules/tmp/willy/nilly.rb +0 -1
@@ -0,0 +1,124 @@
|
|
1
|
+
%%%-------------------------------------------------------------------
|
2
|
+
%%% File : pm_node.erl
|
3
|
+
%%% Author : Ari Lerner <arilerner@mac.com>
|
4
|
+
%%% The client is a running process that will run on the master node
|
5
|
+
%%% and spawn requests to the pm_nodes and compile the responses
|
6
|
+
%%% for use within the poolparty network
|
7
|
+
%%%-------------------------------------------------------------------
|
8
|
+
-module(pm_node).
|
9
|
+
-behaviour(gen_server).
|
10
|
+
|
11
|
+
%% API
|
12
|
+
-export([start_link/0]).
|
13
|
+
|
14
|
+
%% gen_server callbacks
|
15
|
+
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
16
|
+
terminate/2, code_change/3]).
|
17
|
+
-record(state, {}).
|
18
|
+
-define(SERVER, ?MODULE).
|
19
|
+
|
20
|
+
% Client function definitions
|
21
|
+
-export ([stop/0]).
|
22
|
+
-export ([get_load_for_type/1, fire_cmd/1, run_reconfig/0]).
|
23
|
+
|
24
|
+
%%====================================================================
|
25
|
+
%% API
|
26
|
+
%%====================================================================
|
27
|
+
%%--------------------------------------------------------------------
|
28
|
+
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
29
|
+
%% Description: Starts the server
|
30
|
+
%%
|
31
|
+
%% Starts the timer to fire off a ping to the master to let the master
|
32
|
+
%% know that it is alive
|
33
|
+
%%
|
34
|
+
%% Fires a ping every 10 seconds
|
35
|
+
%%--------------------------------------------------------------------
|
36
|
+
start_link() ->
|
37
|
+
utils:start_timer(10000, fun() -> net_adm:ping(master) end),
|
38
|
+
gen_server:start_link({global, ?SERVER}, ?MODULE, [], []).
|
39
|
+
|
40
|
+
%%====================================================================
|
41
|
+
%% gen_server callbacks
|
42
|
+
%%====================================================================
|
43
|
+
|
44
|
+
%%--------------------------------------------------------------------
|
45
|
+
%% Function: init(Args) -> {ok, State} |
|
46
|
+
%% {ok, State, Timeout} |
|
47
|
+
%% ignore |
|
48
|
+
%% {stop, Reason}
|
49
|
+
%% Description: Initiates the server
|
50
|
+
%%--------------------------------------------------------------------
|
51
|
+
init([]) ->
|
52
|
+
process_flag(trap_exit, true),
|
53
|
+
{ok, #state{}}.
|
54
|
+
|
55
|
+
%%--------------------------------------------------------------------
|
56
|
+
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
57
|
+
%% {reply, Reply, State, Timeout} |
|
58
|
+
%% {noreply, State} |
|
59
|
+
%% {noreply, State, Timeout} |
|
60
|
+
%% {stop, Reason, Reply, State} |
|
61
|
+
%% {stop, Reason, State}
|
62
|
+
%% Description: Handling call messages
|
63
|
+
%%--------------------------------------------------------------------
|
64
|
+
handle_call(_Request, _From, State) ->
|
65
|
+
Reply = ok,
|
66
|
+
{reply, Reply, State}.
|
67
|
+
|
68
|
+
%%--------------------------------------------------------------------
|
69
|
+
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
70
|
+
%% {noreply, State, Timeout} |
|
71
|
+
%% {stop, Reason, State}
|
72
|
+
%% Description: Handling cast messages
|
73
|
+
%%--------------------------------------------------------------------
|
74
|
+
handle_cast(_Msg, State) ->
|
75
|
+
{noreply, State}.
|
76
|
+
|
77
|
+
%%--------------------------------------------------------------------
|
78
|
+
%% Function: handle_info(Info, State) -> {noreply, State} |
|
79
|
+
%% {noreply, State, Timeout} |
|
80
|
+
%% {stop, Reason, State}
|
81
|
+
%% Description: Handling all non call/cast messages
|
82
|
+
%%--------------------------------------------------------------------
|
83
|
+
handle_info(_Info, State) ->
|
84
|
+
io:format("Info message received from: ~p~n", [_Info]),
|
85
|
+
{noreply, State}.
|
86
|
+
|
87
|
+
%%--------------------------------------------------------------------
|
88
|
+
%% Function: terminate(Reason, State) -> void()
|
89
|
+
%% Description: This function is called by a gen_server when it is about to
|
90
|
+
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
91
|
+
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
92
|
+
%% The return value is ignored.
|
93
|
+
%%--------------------------------------------------------------------
|
94
|
+
terminate(_Reason, _State) ->
|
95
|
+
utils:stop_timer(),
|
96
|
+
ok.
|
97
|
+
|
98
|
+
%%--------------------------------------------------------------------
|
99
|
+
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
100
|
+
%% Description: Convert process state when code is changed
|
101
|
+
%%--------------------------------------------------------------------
|
102
|
+
code_change(_OldVsn, State, _Extra) ->
|
103
|
+
{ok, State}.
|
104
|
+
|
105
|
+
%%--------------------------------------------------------------------
|
106
|
+
%%% Internal functions
|
107
|
+
%%--------------------------------------------------------------------
|
108
|
+
|
109
|
+
% Get the load for the type sent...
|
110
|
+
get_load_for_type(Type) ->
|
111
|
+
String = string:concat(". /etc/profile && server-get-load -m ",Type),
|
112
|
+
{os:cmd(String)}.
|
113
|
+
|
114
|
+
% Rerun the configuration
|
115
|
+
run_reconfig() -> {os:cmd(". /etc/profile && server-rerun")}.
|
116
|
+
|
117
|
+
% Allows us to fire off any command (allowed by poolparty on the check)
|
118
|
+
fire_cmd(Cmd) ->
|
119
|
+
String = ". /etc/profile && server-fire-cmd \""++Cmd++"\"",
|
120
|
+
{os:cmd(String)}.
|
121
|
+
|
122
|
+
% Stop the pm_node entirely
|
123
|
+
stop() ->
|
124
|
+
gen_server:cast(?MODULE, stop).
|
@@ -0,0 +1,40 @@
|
|
1
|
+
% This supervisor is responsible for monitoring the
|
2
|
+
% client service
|
3
|
+
|
4
|
+
-module (pm_node_supervisor).
|
5
|
+
-behaviour(supervisor).
|
6
|
+
|
7
|
+
-export([start/0, start_in_shell_for_testing/0, start_link/1, init/1]).
|
8
|
+
|
9
|
+
-ifdef(EUNIT).
|
10
|
+
-include_lib("eunit/include/eunit.hrl").
|
11
|
+
-endif.
|
12
|
+
|
13
|
+
start() ->
|
14
|
+
spawn(fun() ->
|
15
|
+
supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = [])
|
16
|
+
end).
|
17
|
+
|
18
|
+
start_in_shell_for_testing() ->
|
19
|
+
{ok, Pid} = supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = []),
|
20
|
+
unlink(Pid).
|
21
|
+
|
22
|
+
start_link(Args) ->
|
23
|
+
supervisor:start_link({local, ?MODULE}, ?MODULE, Args).
|
24
|
+
|
25
|
+
init([]) ->
|
26
|
+
RestartStrategy = one_for_one,
|
27
|
+
MaxRestarts = 3, % 1000
|
28
|
+
MaxTimeBetRestarts = 30, % 3600
|
29
|
+
|
30
|
+
SupFlags = {RestartStrategy, MaxRestarts, MaxTimeBetRestarts},
|
31
|
+
|
32
|
+
LoadServers = [
|
33
|
+
{pm_node1,
|
34
|
+
{pm_node, start_link, []},
|
35
|
+
permanent, 5000, worker,
|
36
|
+
[pm_node]
|
37
|
+
}
|
38
|
+
],
|
39
|
+
|
40
|
+
{ok, {SupFlags, LoadServers}}.
|
@@ -0,0 +1,73 @@
|
|
1
|
+
-module (pm_packager).
|
2
|
+
-compile(export_all).
|
3
|
+
-behaviour(application).
|
4
|
+
|
5
|
+
%% Application callbacks
|
6
|
+
-export([start/2, stop/1]).
|
7
|
+
|
8
|
+
start() ->
|
9
|
+
start("", "").
|
10
|
+
%%====================================================================
|
11
|
+
%% Application callbacks
|
12
|
+
%%====================================================================
|
13
|
+
%%--------------------------------------------------------------------
|
14
|
+
%% Function: start(Type, StartArgs) -> {ok, Pid} |
|
15
|
+
%% {ok, Pid, State} |
|
16
|
+
%% {error, Reason}
|
17
|
+
%% Description: This function is called whenever an application
|
18
|
+
%% is started using application:start/1,2, and should start the processes
|
19
|
+
%% of the application. If the application is structured according to the
|
20
|
+
%% OTP design principles as a supervision tree, this means starting the
|
21
|
+
%% top supervisor of the tree.
|
22
|
+
%%--------------------------------------------------------------------
|
23
|
+
start(_Type, _) ->
|
24
|
+
recompile_scripts("0.1").
|
25
|
+
|
26
|
+
%%--------------------------------------------------------------------
|
27
|
+
%% Function: stop(State) -> void()
|
28
|
+
%% Description: This function is called whenever an application
|
29
|
+
%% has stopped. It is intended to be the opposite of Module:start/2 and
|
30
|
+
%% should do any necessary cleaning up. The return value is ignored.
|
31
|
+
%%--------------------------------------------------------------------
|
32
|
+
stop(_State) ->
|
33
|
+
ok.
|
34
|
+
|
35
|
+
%%====================================================================
|
36
|
+
%% Internal functions
|
37
|
+
%%====================================================================
|
38
|
+
|
39
|
+
gen_rel(Name, Vers) ->
|
40
|
+
RelName = lists:append(["pm_",Name,"_rel-",Vers]),
|
41
|
+
F = lists:append(["{release, {\"",Name,"\",\"",Vers,"\"}, ",
|
42
|
+
"{erts,\"",erlang:system_info(version),"\"},"
|
43
|
+
"[{kernel,\"",get_vsn(kernel),"\"},",
|
44
|
+
"{stdlib,\"",get_vsn(stdlib),"\"},",
|
45
|
+
"{inets,\"",get_vsn(inets),"\"},",
|
46
|
+
"{crypto,\"",get_vsn(crypto),"\"},",
|
47
|
+
"{sasl,\"",get_vsn(sasl),"\"},",
|
48
|
+
"{",Name,",\"",Vers,"\"}]}."]),
|
49
|
+
file:write_file( lists:append(["ebin/", RelName, ".rel"]),F).
|
50
|
+
|
51
|
+
% Recompiles the boot scripts
|
52
|
+
recompile_scripts(Vers) ->
|
53
|
+
gen_rel("master", Vers),
|
54
|
+
gen_rel("node", Vers),
|
55
|
+
systools:make_script("pm_node_rel-"++Vers, [local,{path,["ebin"]}]),
|
56
|
+
systools:make_script("pm_master_rel-"++Vers, [local,{path,["ebin"]}]).
|
57
|
+
|
58
|
+
package_scripts(Vers) ->
|
59
|
+
systools:make_tar("ebin/pm_node_rel-"++Vers),
|
60
|
+
systools:make_tar("ebin/pm_master_rel-"++Vers).
|
61
|
+
|
62
|
+
get_vsn(Module) ->
|
63
|
+
AppFile = code:lib_dir(Module)++"/ebin/"++atom_to_list(Module)++".app",
|
64
|
+
{ok,[{application,_App,Attrs}]} = file:consult(AppFile),
|
65
|
+
{value,{vsn,Vsn}} = lists:keysearch(vsn,1,Attrs),
|
66
|
+
Vsn.
|
67
|
+
|
68
|
+
install_messenger(Vers) ->
|
69
|
+
Root = code:root_dir(),
|
70
|
+
io:format("~p root: "++Root, [Vers]),
|
71
|
+
ok.
|
72
|
+
|
73
|
+
% Tests
|
@@ -0,0 +1,38 @@
|
|
1
|
+
-module (utils).
|
2
|
+
-compile(export_all).
|
3
|
+
|
4
|
+
-ifdef(EUNIT).
|
5
|
+
-include_lib("eunit/include/eunit.hrl").
|
6
|
+
-endif.
|
7
|
+
|
8
|
+
% Turn a list from
|
9
|
+
% [{"0.66"}, {"0.32"}, []] -> [0.66, 0.32]
|
10
|
+
convert_responses_to_int_list(L) ->
|
11
|
+
Sum = lists:foldr( fun(Int, Sum) -> Int + Sum end, 0, [erlang:list_to_float(F) || {F} <- L] ),
|
12
|
+
average_for_list(Sum, L).
|
13
|
+
|
14
|
+
% Start a timer to fire off Fun after Time number of milliseconds
|
15
|
+
start_timer(Time, Fun) ->
|
16
|
+
register(?MODULE, spawn(fun() -> tick_timer(Time, Fun) end)).
|
17
|
+
|
18
|
+
stop_timer() -> ?MODULE ! stop.
|
19
|
+
|
20
|
+
tick_timer(Time, Fun) ->
|
21
|
+
receive
|
22
|
+
stop ->
|
23
|
+
void
|
24
|
+
after Time ->
|
25
|
+
Fun(),
|
26
|
+
tick_timer(Time, Fun)
|
27
|
+
end.
|
28
|
+
|
29
|
+
|
30
|
+
% Private
|
31
|
+
% Get the average of the list
|
32
|
+
average_for_list(Num, L) ->
|
33
|
+
case length(L) of
|
34
|
+
0 ->
|
35
|
+
0;
|
36
|
+
_ ->
|
37
|
+
Num / length(L)
|
38
|
+
end.
|
@@ -21,8 +21,15 @@ module PoolParty
|
|
21
21
|
|
22
22
|
# Tempalte variables
|
23
23
|
variable(:name => "name_haproxy", :value => "#{@parent.name}")
|
24
|
-
|
25
|
-
|
24
|
+
|
25
|
+
if @parent.provisioning?
|
26
|
+
variable(:name => "nodenames_haproxy", :value => "#{list_of_running_instances.map{|a| "#{a.send :name}" }.join("\t")}")
|
27
|
+
variable(:name => "node_ips_haproxy", :value => "#{list_of_running_instances.map{|a| "#{a.send :ip}" }.join("\t")}")
|
28
|
+
else
|
29
|
+
variable(:name => "nodenames_haproxy", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'name')")
|
30
|
+
variable(:name => "node_ips_haproxy", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'ip')")
|
31
|
+
end
|
32
|
+
|
26
33
|
variable(:name => "ports_haproxy", :value => ([(self.respond_to?(:port) ? port : Base.port)].flatten))
|
27
34
|
variable(:name => "forwarding_port", :value => (respond_to?(:forwarding_port) ? forwarding_port : Base.forwarding_port))
|
28
35
|
variable(:name => "proxy_mode", :value => (respond_to?(:proxy_mode) ? proxy_mode : Base.proxy_mode))
|
@@ -4,38 +4,50 @@ module PoolParty
|
|
4
4
|
|
5
5
|
def enable
|
6
6
|
execute_if("$hostname", "master") do
|
7
|
-
has_package(:name => "heartbeat-2", :ensure => "installed")
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
has_package(:name => "heartbeat-2", :ensure => "installed") do
|
8
|
+
# These can also be passed in via hash
|
9
|
+
has_remotefile(:name => "/etc/ha.d/ha.cf") do
|
10
|
+
mode 444
|
11
|
+
notify 'Service["heartbeat"]'
|
12
|
+
template File.join(File.dirname(__FILE__), "..", "templates/ha.cf")
|
13
|
+
end
|
14
|
+
|
15
|
+
has_remotefile(:name => "/etc/ha.d/authkeys") do
|
16
|
+
mode 400
|
17
|
+
notify 'Service["heartbeat"]'
|
18
|
+
template File.join(File.dirname(__FILE__), "..", "templates/authkeys")
|
19
|
+
end
|
20
|
+
|
21
|
+
has_remotefile(:name => "/etc/ha.d/cib.xml") do
|
22
|
+
mode 444
|
23
|
+
notify 'Exec["heartbeat-update-cib"]'
|
24
|
+
template File.join(File.dirname(__FILE__), "..", "templates/cib.xml")
|
25
|
+
end
|
26
|
+
|
27
|
+
has_service(:name => "heartbeat", :hasstatus => true)
|
28
|
+
end
|
11
29
|
|
12
30
|
has_exec(:name => "heartbeat-update-cib", :command => "/usr/sbin/cibadmin -R -x /etc/ha.d/cib.xml", :refreshonly => true)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
mode 444
|
22
|
-
requires 'Package["heartbeat-2"]'
|
23
|
-
notify 'Service["heartbeat"]'
|
24
|
-
template File.join(File.dirname(__FILE__), "..", "templates/ha.cf")
|
25
|
-
end
|
26
|
-
|
27
|
-
has_remotefile(:name => "/etc/ha.d/authkeys") do
|
28
|
-
mode 400
|
29
|
-
requires 'Package["heartbeat-2"]'
|
30
|
-
notify 'Service["heartbeat"]'
|
31
|
-
template File.join(File.dirname(__FILE__), "..", "templates/authkeys")
|
31
|
+
|
32
|
+
if @parent.provisioning?
|
33
|
+
variable(:name => "ha_nodenames", :value => "#{list_of_running_instances.map{|a| "#{a.send :name}" }.join("\t")}")
|
34
|
+
variable(:name => "ha_node_ips", :value => "#{list_of_running_instances.map{|a| "#{a.send :ip}" }.join("\t")}")
|
35
|
+
else
|
36
|
+
# variables for the templates
|
37
|
+
variable(:name => "ha_nodenames", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'name')")
|
38
|
+
variable(:name => "ha_node_ips", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'ip')")
|
32
39
|
end
|
40
|
+
|
41
|
+
has_variable({:name => "ha_timeout", :value => (self.respond_to?(:timeout) ? timeout : "5s")})
|
42
|
+
has_variable({:name => "ha_port", :value => (self.respond_to?(:port) ? port : Base.port)})
|
43
|
+
|
44
|
+
end
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
execute_if("$hostname", "master") do
|
47
|
+
if list_of_node_names.size > 1
|
48
|
+
has_exec(:name => "update pem for heartbeat", :refreshonly => true) do
|
49
|
+
command "scp /etc/puppet/ssl/ca/ca_crl.pem #{user || Base.user}@#{list_of_node_ips[1]}:/etc/puppet/ssl/ca"
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
41
53
|
|
@@ -4,29 +4,52 @@ module PoolParty
|
|
4
4
|
|
5
5
|
def enable
|
6
6
|
has_package(:name => "erlang")
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
has_package(:name => "erlang-dev")
|
8
|
+
has_package(:name => "erlang-src")
|
9
|
+
|
10
|
+
has_package(:name => "rubygems") do
|
11
|
+
# These should be installed automagically by poolparty, but just in case
|
12
|
+
# TODO: Fix the requires method with a helper
|
13
13
|
has_gempackage(:name => "logging")
|
14
|
-
has_gempackage(:name => "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
has_gempackage(:name => "
|
20
|
-
|
14
|
+
has_gempackage(:name => "xml-simple") do
|
15
|
+
has_gempackage(:name => "grempe-amazon-ec2", :source => "http://gems.github.com")
|
16
|
+
end
|
17
|
+
has_gempackage(:name => "rake")
|
18
|
+
|
19
|
+
has_gempackage(:name => "hoe") do
|
20
|
+
has_gempackage(:name => "open4")
|
21
|
+
|
22
|
+
has_gempackage(:name => "ParseTree", :version => "2.2.0") do
|
23
|
+
has_gempackage(:name => "ruby2ruby")
|
24
|
+
has_gempackage(:name => "activesupport") do
|
25
|
+
has_gempackage(:name => "auser-poolparty", :source => "http://gems.github.com") do
|
26
|
+
has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger")
|
27
|
+
has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node", :requires => 'Exec["build_messenger"]')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
has_gempackage(:name => "RubyInline")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
21
36
|
# Build hostsfile
|
22
37
|
# TODO: COME BACK AND CLEAN THIS UP
|
23
38
|
(self.respond_to?(:list_of_running_instances) ? self : parent).list_of_running_instances.each do |ri|
|
24
39
|
has_host({:name => "#{ri.name}", :ip => ri.ip })
|
25
40
|
end
|
26
41
|
|
27
|
-
|
28
|
-
|
29
|
-
|
42
|
+
# Custom run puppet to minimize footprint
|
43
|
+
# TODO: Update the offsetted times
|
44
|
+
has_cron(:name => "puppetd runner", :user => Base.user, :minute => [0,15,30,45]) do
|
45
|
+
command((self.respond_to?(:master) ? self : parent).master.puppet_runner_command)
|
46
|
+
end
|
47
|
+
|
48
|
+
# These are all requirements on the master
|
49
|
+
execute_if("$hostname", "master") do
|
50
|
+
has_cron({:command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3"})
|
51
|
+
# TODO: Update this so it only runs when needed
|
52
|
+
has_exec(:name => ". /etc/profile && server-start-master")
|
30
53
|
end
|
31
54
|
# has_host(:name => "puppet", :ip => (self.respond_to?(:master) ? self : parent).master.ip)
|
32
55
|
end
|
@@ -10,10 +10,9 @@ module PoolParty
|
|
10
10
|
has_package(:name => "libreadline-ruby1.8")
|
11
11
|
has_package(:name => "libruby1.8")
|
12
12
|
has_package(:name => "ruby1.8-dev")
|
13
|
-
has_package(:name => "ruby1.8")
|
14
|
-
has_package(:name => "rubygems")
|
13
|
+
has_package(:name => "ruby1.8")
|
15
14
|
|
16
|
-
has_line_in_file("export PATH=$PATH:/var/lib/gems/1.8/bin
|
15
|
+
has_line_in_file("export PATH=$PATH:/var/lib/gems/1.8/bin:/sbin", "/etc/profile")
|
17
16
|
|
18
17
|
# exec(:name => "update-rubygems") do
|
19
18
|
# command "gem update --system"
|
@@ -0,0 +1 @@
|
|
1
|
+
echo 'hello world' > test.del.txt
|
data/lib/poolparty/core/array.rb
CHANGED
@@ -15,10 +15,13 @@ class Array
|
|
15
15
|
def nice_runnable(quiet=true)
|
16
16
|
self.flatten.reject{|e| (e.nil? || e.empty?) }.join(" \n ").chomp.nice_runnable(quiet)
|
17
17
|
end
|
18
|
-
def to_string(
|
19
|
-
map {|a| a.to_string(
|
18
|
+
def to_string(pre="")
|
19
|
+
map {|a| a.to_string(pre)}.join("\n")
|
20
20
|
end
|
21
21
|
def get_named(str="")
|
22
22
|
map {|a| a.name == str ? a : nil }.reject {|a| a.nil? }
|
23
23
|
end
|
24
|
+
def to_option_string(ns=[])
|
25
|
+
"[ #{map {|e| e.to_option_string }.join(", ")} ]"
|
26
|
+
end
|
24
27
|
end
|
data/lib/poolparty/core/hash.rb
CHANGED
@@ -12,14 +12,28 @@ class Hash
|
|
12
12
|
o.keys.each {|k| self.delete(k) }
|
13
13
|
o
|
14
14
|
end
|
15
|
+
def append(other_hash)
|
16
|
+
returning Hash.new do |h|
|
17
|
+
h.merge!(self)
|
18
|
+
other_hash.each do |k,v|
|
19
|
+
h[k] = has_key?(k) ? [self[k], v].flatten : v
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
def append!(other_hash)
|
24
|
+
other_hash.each do |k,v|
|
25
|
+
self[k] = has_key?(k) ? [self[k], v].flatten : v
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
15
29
|
def safe_merge(other_hash)
|
16
30
|
merge(other_hash.delete_if {|k,v| has_key?(k) })
|
17
31
|
end
|
18
32
|
def safe_merge!(other_hash)
|
19
33
|
merge!(other_hash.delete_if {|k,v| has_key?(k) && !v.nil? })
|
20
34
|
end
|
21
|
-
def flush_out(
|
22
|
-
map {|k,v| "#{
|
35
|
+
def flush_out(pre="", post="")
|
36
|
+
map {|k,v| "#{pre}#{k} => #{v.to_option_string}#{post}"}
|
23
37
|
end
|
24
38
|
def to_os
|
25
39
|
m={}
|
@@ -25,15 +25,22 @@ class String
|
|
25
25
|
self.split("::")[-1].downcase rescue self
|
26
26
|
end
|
27
27
|
def sanitize
|
28
|
-
self.gsub(/[
|
28
|
+
self.gsub(/[\.\/]*/, '')
|
29
29
|
end
|
30
30
|
def nice_runnable(quite=true)
|
31
31
|
self.split(/ && /).join("\n")
|
32
32
|
end
|
33
|
+
# This is the method we use to turn the options into a string to build the main
|
34
|
+
# manifests
|
33
35
|
def to_option_string(ns=[])
|
34
36
|
a_template = (self =~ /template/) == 0
|
35
37
|
a_service = self =~ /^[A-Z][a-zA-Z]*\[[a-zA-Z0-9\-\.\"\'_\$\{\}\/]*\]/
|
36
|
-
|
38
|
+
a_function = self =~/(.)*\((.)*\)(.)*/
|
39
|
+
if is_a?(PoolParty::Resources::Resource)
|
40
|
+
self.to_s
|
41
|
+
else
|
42
|
+
(a_service || a_template || a_function) ? self : "'#{self}'"
|
43
|
+
end
|
37
44
|
end
|
38
45
|
# Refactor this guy to get the class if the class is defined, and not always create a new one
|
39
46
|
# although, it doesn't really matter as ruby will just reopen the class
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module PoolParty
|
2
|
+
module DependencyResolutions
|
3
|
+
module Puppet
|
4
|
+
|
5
|
+
def pretty_print_resources(pre=" ")
|
6
|
+
returning Array.new do |out|
|
7
|
+
resources.each do |name, res|
|
8
|
+
out << "#{pre}#{name}"
|
9
|
+
out << "#{pre*2}#{res.map {|a| a.name}}"
|
10
|
+
res.each do |r|
|
11
|
+
out << "#{pre*2}#{r.pretty_print_resources(pre*2)}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end.join("\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Generic to_s
|
18
|
+
# Most Resources won't need to extend this
|
19
|
+
def to_string(pre="")
|
20
|
+
opts = get_modified_options
|
21
|
+
returning Array.new do |output|
|
22
|
+
unless cancelled?
|
23
|
+
output << @prestring || ""
|
24
|
+
|
25
|
+
if resources && !resources.empty?
|
26
|
+
@cp = classpackage_with_self(self)
|
27
|
+
output << @cp.to_string
|
28
|
+
output << "include #{@cp.name.sanitize}"
|
29
|
+
end
|
30
|
+
|
31
|
+
unless virtual_resource?
|
32
|
+
output << "#{pre}#{class_type_name.downcase} {"
|
33
|
+
output << "#{pre}\"#{self.key}\":"
|
34
|
+
output << opts.flush_out("#{pre*2}").join(",\n")
|
35
|
+
output << "#{pre}}"
|
36
|
+
end
|
37
|
+
|
38
|
+
output << @poststring || ""
|
39
|
+
end
|
40
|
+
end.join("\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
"#{class_type_name.capitalize}['#{key}']"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -7,8 +7,9 @@ module PoolParty
|
|
7
7
|
|
8
8
|
# Load a file that contains a pool into memory
|
9
9
|
def load_pool(filename)
|
10
|
-
|
11
|
-
|
10
|
+
filename = filename.chomp
|
11
|
+
unless filename && ::File.readable?(filename)
|
12
|
+
puts "Could not load pool: #{filename}"
|
12
13
|
exit
|
13
14
|
else
|
14
15
|
PoolParty::Script.inflate(open(filename).read, File.dirname(filename))
|
@@ -7,10 +7,10 @@ module PoolParty
|
|
7
7
|
print v.pretty_print
|
8
8
|
end
|
9
9
|
else
|
10
|
-
|
10
|
+
pre = "\t"
|
11
11
|
clouds.each do |name, cl|
|
12
|
-
puts cl.pretty_name(
|
13
|
-
puts cl.pretty_options(
|
12
|
+
puts cl.pretty_name(pre*2, cl)
|
13
|
+
puts cl.pretty_options(pre*2, cl) #cl.pretty_print("#{pre}\t")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|