auser-poolparty 0.2.45 → 0.2.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +2 -145
- data/Rakefile +6 -1
- data/bin/cloud +2 -1
- data/bin/pool +2 -1
- data/bin/server-build-messenger +2 -1
- data/bin/server-start-node +5 -8
- data/config/hoe.rb +4 -2
- data/lib/erlang/messenger/Rakefile +6 -0
- data/lib/erlang/messenger/include/defines.hrl +7 -1
- data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.script +7 -3
- data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.script +7 -3
- data/lib/erlang/messenger/src/pm_master.erl +104 -20
- data/lib/erlang/messenger/src/pm_node.erl +51 -30
- data/lib/erlang/messenger/src/pm_node_supervisor.erl +7 -7
- data/lib/erlang/messenger/src/utils.erl +3 -1
- data/lib/erlang/messenger/useful_snippets +2 -2
- data/lib/poolparty/base_packages/haproxy.rb +1 -3
- data/lib/poolparty/base_packages/poolparty.rb +4 -3
- data/lib/poolparty/helpers/optioner.rb +27 -25
- data/lib/poolparty/helpers/provisioners/master.rb +1 -0
- data/lib/poolparty/helpers/provisioners/slave.rb +9 -1
- data/lib/poolparty/monitors/base_monitor.rb +1 -1
- data/lib/poolparty/monitors/monitors/memory_monitor.rb +29 -2
- data/lib/poolparty/monitors/monitors/web_monitor.rb +18 -0
- data/lib/poolparty/net/messenger.rb +5 -2
- data/lib/poolparty/net/remoter_base.rb +15 -1
- data/lib/poolparty/plugins/git.rb +2 -2
- data/lib/poolparty/pool/loggable.rb +1 -3
- data/lib/poolparty/pool/resources/sshkey.rb +1 -1
- data/lib/poolparty/version.rb +1 -1
- data/lib/poolparty.rb +7 -0
- data/lib/poolpartycl.rb +4 -0
- data/poolparty.gemspec +6 -149
- data/spec/poolparty/helpers/binary_spec.rb +2 -2
- data/spec/poolparty/helpers/optioner_spec.rb +1 -4
- data/spec/poolparty/monitors/monitors/memory_monitor_spec.rb +47 -0
- data/spec/poolparty/net/remoter_base_spec.rb +1 -1
- data/spec/poolparty/pool/base_spec.rb +3 -4
- data/tasks/deployment.rake +6 -2
- metadata +6 -149
- data/lib/erlang/cloudpanel/EMakefile +0 -1
- data/lib/erlang/cloudpanel/Makefile +0 -8
- data/lib/erlang/cloudpanel/cloudpanel.rb +0 -15
- data/lib/erlang/cloudpanel/doc/cloudpanel.html +0 -39
- data/lib/erlang/cloudpanel/doc/cloudpanel_app.html +0 -40
- data/lib/erlang/cloudpanel/doc/cloudpanel_deps.html +0 -89
- data/lib/erlang/cloudpanel/doc/cloudpanel_sup.html +0 -46
- data/lib/erlang/cloudpanel/doc/cloudpanel_web.html +0 -45
- data/lib/erlang/cloudpanel/doc/string.html +0 -222
- data/lib/erlang/cloudpanel/ebin/cloudpanel.app +0 -14
- data/lib/erlang/cloudpanel/priv/www/images/bg_content.gif +0 -0
- data/lib/erlang/cloudpanel/priv/www/index.html +0 -35
- data/lib/erlang/cloudpanel/priv/www/javascripts/jquery.js +0 -32
- data/lib/erlang/cloudpanel/priv/www/javascripts/site.js +0 -2
- data/lib/erlang/cloudpanel/priv/www/pages/index.html +0 -1
- data/lib/erlang/cloudpanel/priv/www/pages/tail.html +0 -1
- data/lib/erlang/cloudpanel/priv/www/partials/error.html +0 -3
- data/lib/erlang/cloudpanel/priv/www/partials/footer.html +0 -6
- data/lib/erlang/cloudpanel/priv/www/partials/header.html +0 -13
- data/lib/erlang/cloudpanel/priv/www/partials/menu.html +0 -13
- data/lib/erlang/cloudpanel/priv/www/stylesheets/application.css +0 -48
- data/lib/erlang/cloudpanel/priv/www/stylesheets/classes.css +0 -2
- data/lib/erlang/cloudpanel/priv/www/stylesheets/colors.css +0 -8
- data/lib/erlang/cloudpanel/priv/www/stylesheets/nav.css +0 -18
- data/lib/erlang/cloudpanel/src/Makefile +0 -9
- data/lib/erlang/cloudpanel/src/cloudpanel.app +0 -14
- data/lib/erlang/cloudpanel/src/cloudpanel.erl +0 -30
- data/lib/erlang/cloudpanel/src/cloudpanel.hrl +0 -2
- data/lib/erlang/cloudpanel/src/cloudpanel_app.erl +0 -22
- data/lib/erlang/cloudpanel/src/cloudpanel_deps.erl +0 -84
- data/lib/erlang/cloudpanel/src/cloudpanel_sup.erl +0 -54
- data/lib/erlang/cloudpanel/src/cloudpanel_web.erl +0 -39
- data/lib/erlang/cloudpanel/src/string.erl +0 -387
- data/lib/erlang/cloudpanel/src/tail_log.erl +0 -66
- data/lib/erlang/cloudpanel/src/tailor.erl +0 -31
- data/lib/erlang/cloudpanel/src/utils.erl +0 -9
- data/lib/erlang/cloudpanel/src/views.erl +0 -44
- data/lib/erlang/cloudpanel/start-dev.sh +0 -3
- data/lib/erlang/cloudpanel/start.sh +0 -3
- data/lib/erlang/cloudpanel/support/include.mk +0 -46
- data/lib/erlang/cloudpanel/yaws.conf +0 -20
- data/lib/erlang/messenger/ebin/master_app.beam +0 -0
- data/lib/erlang/messenger/ebin/node_app.beam +0 -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_manager.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master_event_handler.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -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/pm_master.beam +0 -0
- data/lib/erlang/messenger/pm_node.beam +0 -0
|
@@ -11,20 +11,23 @@
|
|
|
11
11
|
-include_lib("../include/defines.hrl").
|
|
12
12
|
|
|
13
13
|
%% API
|
|
14
|
-
-export([start_link/0]).
|
|
14
|
+
-export([start_link/1, start_link/0]).
|
|
15
15
|
|
|
16
16
|
%% gen_server callbacks
|
|
17
17
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
|
18
18
|
terminate/2, code_change/3]).
|
|
19
19
|
|
|
20
|
-
-record(state, {
|
|
20
|
+
-record(state, {
|
|
21
|
+
monitors = {} % Tuple of monitors
|
|
22
|
+
}).
|
|
21
23
|
-define(SERVER, ?MODULE).
|
|
24
|
+
-define (UPDATE_TIME, 2000).
|
|
22
25
|
|
|
23
26
|
% Client function definitions
|
|
24
27
|
-export ([stop/0]).
|
|
25
28
|
-export ([get_load_for_type/1, run_cmd/1, fire_cmd/1]).
|
|
26
|
-
-export ([run_reconfig/0]).
|
|
27
|
-
|
|
29
|
+
-export ([run_reconfig/0, local_update/1, still_here/0, print_monitors/0]).
|
|
30
|
+
-export ([server_location/0]).
|
|
28
31
|
%%====================================================================
|
|
29
32
|
%% API
|
|
30
33
|
%%====================================================================
|
|
@@ -39,16 +42,24 @@ get_load_for_type(Type) ->
|
|
|
39
42
|
{os:cmd(String)}.
|
|
40
43
|
|
|
41
44
|
% Rerun the configuration
|
|
42
|
-
run_reconfig() ->
|
|
43
|
-
|
|
45
|
+
run_reconfig() -> gen_server:cast(server_location(), {run_reconfig}).
|
|
46
|
+
print_monitors() -> gen_server:call(server_location(), {print_monitors}).
|
|
44
47
|
|
|
45
48
|
% Allows us to fire off any command (allowed by poolparty on the check)
|
|
46
|
-
run_cmd(Cmd) -> gen_server:call(
|
|
47
|
-
fire_cmd(Cmd) -> gen_server:cast(
|
|
49
|
+
run_cmd(Cmd) -> gen_server:call(server_location(), {run_command, Cmd}).
|
|
50
|
+
fire_cmd(Cmd) -> gen_server:cast(server_location(), {fire_command, Cmd}).
|
|
51
|
+
|
|
52
|
+
still_here() -> gen_server:call(server_location(), {still_there}).
|
|
48
53
|
|
|
49
54
|
% Stop the pm_node entirely
|
|
50
|
-
stop() ->
|
|
51
|
-
|
|
55
|
+
stop() -> gen_server:cast(server_location(), stop).
|
|
56
|
+
|
|
57
|
+
% Run every UPDATE_TIME seconds
|
|
58
|
+
local_update(Types) ->
|
|
59
|
+
?TRACE("Updating", [?MASTER_LOCATION]),
|
|
60
|
+
net_adm:ping(?MASTER_LOCATION),
|
|
61
|
+
Load = [{Ty, element(1, get_load_for_type(Ty))} || Ty <- Types],
|
|
62
|
+
gen_server:cast(?MASTER_SERVER, {update_node_load, node(), Load}).
|
|
52
63
|
|
|
53
64
|
%%--------------------------------------------------------------------
|
|
54
65
|
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
@@ -59,10 +70,8 @@ stop() ->
|
|
|
59
70
|
%%
|
|
60
71
|
%% Fires a ping every 10 seconds
|
|
61
72
|
%%--------------------------------------------------------------------
|
|
62
|
-
start_link() ->
|
|
63
|
-
|
|
64
|
-
utils:start_timer(10000, fun() -> net_adm:ping(?MASTER_LOCATION) end),
|
|
65
|
-
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
|
73
|
+
start_link() -> start_link(erlang:get_plain_arguments()).
|
|
74
|
+
start_link(Args) -> gen_server:start_link({global, node()}, ?MODULE, Args, Args).
|
|
66
75
|
|
|
67
76
|
%%====================================================================
|
|
68
77
|
%% gen_server callbacks
|
|
@@ -75,9 +84,13 @@ start_link() ->
|
|
|
75
84
|
%% {stop, Reason}
|
|
76
85
|
%% Description: Initiates the server
|
|
77
86
|
%%--------------------------------------------------------------------
|
|
78
|
-
init(
|
|
87
|
+
init(Args) ->
|
|
88
|
+
io:format("Master location ~p~n", [?MASTER_LOCATION]),
|
|
79
89
|
process_flag(trap_exit, true),
|
|
80
|
-
|
|
90
|
+
utils:start_timer(?UPDATE_TIME, fun() -> pm_node:local_update(Args) end),
|
|
91
|
+
{ok, #state{
|
|
92
|
+
monitors=Args
|
|
93
|
+
}}.
|
|
81
94
|
|
|
82
95
|
%%--------------------------------------------------------------------
|
|
83
96
|
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
@@ -91,6 +104,13 @@ init([]) ->
|
|
|
91
104
|
handle_call({run_command, Cmd}, _From, State) ->
|
|
92
105
|
Reply = os:cmd(". /etc/profile && server-fire-cmd \""++Cmd++"\""),
|
|
93
106
|
{reply, Reply, State};
|
|
107
|
+
handle_call({still_there}, _From, State) ->
|
|
108
|
+
Reply = still_here,
|
|
109
|
+
{reply, Reply, State};
|
|
110
|
+
handle_call({print_monitors}, _From, State) ->
|
|
111
|
+
[ io:format("Type: ~p ", [Monitor]) || Monitor <- State#state.monitors ],
|
|
112
|
+
io:format("~n"),
|
|
113
|
+
{reply, ok, State};
|
|
94
114
|
handle_call(_Request, _From, State) ->
|
|
95
115
|
Reply = ok,
|
|
96
116
|
{reply, Reply, State}.
|
|
@@ -101,19 +121,16 @@ handle_call(_Request, _From, State) ->
|
|
|
101
121
|
%% {stop, Reason, State}
|
|
102
122
|
%% Description: Handling cast messages
|
|
103
123
|
%%--------------------------------------------------------------------
|
|
104
|
-
handle_cast({
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
_ ->
|
|
115
|
-
{ok, State}
|
|
116
|
-
end.
|
|
124
|
+
handle_cast({fire_command, Cmd}, State) ->
|
|
125
|
+
?TRACE("Running command: ~p~n", [Cmd]),
|
|
126
|
+
os:cmd(". /etc/profile && server-fire-cmd \""++Cmd++"\" 2>&1 > /dev/null"),
|
|
127
|
+
{noreply, State};
|
|
128
|
+
handle_cast({run_reconfig}, State) ->
|
|
129
|
+
?TRACE("Running Reconfig", ["server-rerun"]),
|
|
130
|
+
os:cmd(". /etc/profile && server-rerun"),
|
|
131
|
+
{noreply, State};
|
|
132
|
+
handle_cast(_Msg, State) ->
|
|
133
|
+
{noreply, State}.
|
|
117
134
|
|
|
118
135
|
%%--------------------------------------------------------------------
|
|
119
136
|
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
@@ -141,4 +158,8 @@ terminate(_Reason, _State) ->
|
|
|
141
158
|
%% Description: Convert process state when code is changed
|
|
142
159
|
%%--------------------------------------------------------------------
|
|
143
160
|
code_change(_OldVsn, State, _Extra) ->
|
|
144
|
-
{ok, State}.
|
|
161
|
+
{ok, State}.
|
|
162
|
+
|
|
163
|
+
% Private
|
|
164
|
+
server_location() ->
|
|
165
|
+
global:whereis_name(node()).
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
-module (pm_node_supervisor).
|
|
5
5
|
-behaviour(supervisor).
|
|
6
6
|
|
|
7
|
-
-export([start/0,
|
|
7
|
+
-export ([start/0, start/1]).
|
|
8
|
+
-export([start_in_shell_for_testing/0, start_link/1, init/1]).
|
|
8
9
|
|
|
9
10
|
-ifdef(EUNIT).
|
|
10
11
|
-include_lib("eunit/include/eunit.hrl").
|
|
11
12
|
-endif.
|
|
12
13
|
|
|
13
|
-
start() ->
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end).
|
|
14
|
+
start() -> spawn(fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = []) end).
|
|
15
|
+
start(Args) -> spawn(fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, Args) end).
|
|
16
|
+
|
|
17
17
|
|
|
18
18
|
start_in_shell_for_testing() ->
|
|
19
19
|
{ok, Pid} = supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = []),
|
|
@@ -22,7 +22,7 @@ start_in_shell_for_testing() ->
|
|
|
22
22
|
start_link(Args) ->
|
|
23
23
|
supervisor:start_link({local, ?MODULE}, ?MODULE, Args).
|
|
24
24
|
|
|
25
|
-
init(
|
|
25
|
+
init(Args) ->
|
|
26
26
|
RestartStrategy = one_for_one,
|
|
27
27
|
MaxRestarts = 1000,
|
|
28
28
|
MaxTimeBetRestarts = 3600,
|
|
@@ -31,7 +31,7 @@ init([]) ->
|
|
|
31
31
|
SupFlags = {RestartStrategy, MaxRestarts, MaxTimeBetRestarts},
|
|
32
32
|
|
|
33
33
|
EventManager = {pm_event_manager, {pm_event_manager, start_link, []}, permanent, TimeoutTime, worker, dynamic},
|
|
34
|
-
NodeServer = {pm_node1, {pm_node, start_link,
|
|
34
|
+
NodeServer = {pm_node1, {pm_node, start_link, Args}, permanent, TimeoutTime, worker, [pm_node]},
|
|
35
35
|
|
|
36
36
|
LoadServers = [EventManager, NodeServer],
|
|
37
37
|
|
|
@@ -26,8 +26,10 @@ tick_timer(Time, Fun) ->
|
|
|
26
26
|
tick_timer(Time, Fun)
|
|
27
27
|
end.
|
|
28
28
|
|
|
29
|
+
average_of_list(L) ->
|
|
30
|
+
Sum = lists:foldr( fun(Int, Sum) -> Int + Sum end, 0, [F || F <- L] ),
|
|
31
|
+
average_for_list(Sum, L).
|
|
29
32
|
|
|
30
|
-
% Private
|
|
31
33
|
% Get the average of the list
|
|
32
34
|
average_for_list(Num, L) ->
|
|
33
35
|
case length(L) of
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
% erl -pa ./ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -setcookie poolparty -boot pm_node_rel-0.1 -sname node1
|
|
7
7
|
|
|
8
8
|
% Starting the client on the master
|
|
9
|
-
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.
|
|
9
|
+
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.46/lib/erlang/messenger/ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -sname client -setcookie poolparty -run pm_client start
|
|
10
10
|
|
|
11
11
|
% Get the load
|
|
12
|
-
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.
|
|
12
|
+
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.46/lib/erlang/messenger/ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -sname client -setcookie poolparty -run pm_client start
|
|
13
13
|
|
|
14
14
|
% cd /var/poolparty && gem uninstall poolparty && wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1 && gem install --no-ri --no-rdoc poolparty-latest.gem
|
|
15
15
|
|
|
@@ -7,9 +7,7 @@ module PoolParty
|
|
|
7
7
|
has_package({:name => "haproxy"})
|
|
8
8
|
|
|
9
9
|
# Restart sysklogd after we update the haproxy.log
|
|
10
|
-
has_service(:name => "sysklogd")
|
|
11
|
-
ensures "running"
|
|
12
|
-
end
|
|
10
|
+
has_service(:name => "sysklogd")
|
|
13
11
|
|
|
14
12
|
# Template variables
|
|
15
13
|
has_variable(:name => "name_haproxy", :value => "#{cloud.name}")
|
|
@@ -47,7 +47,7 @@ module PoolParty
|
|
|
47
47
|
|
|
48
48
|
# Cloud panel setup
|
|
49
49
|
|
|
50
|
-
has_directory(:name => "/var/www/cloudpanel")
|
|
50
|
+
# has_directory(:name => "/var/www/cloudpanel")
|
|
51
51
|
|
|
52
52
|
# has_file(:name => "/etc/yaws/conf.d/localhost.conf") do
|
|
53
53
|
# template File.join(File.dirname(__FILE__), "..", "templates/yaws.conf")
|
|
@@ -63,7 +63,7 @@ module PoolParty
|
|
|
63
63
|
has_cron(:name => "Load handler", :user => Base.user, :minute => "*/4") do
|
|
64
64
|
requires get_gempackage("poolparty-latest")
|
|
65
65
|
command(". /etc/profile && cloud-handle-load")
|
|
66
|
-
end
|
|
66
|
+
end
|
|
67
67
|
end
|
|
68
68
|
execute_on_node do
|
|
69
69
|
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
|
@@ -74,10 +74,11 @@ module PoolParty
|
|
|
74
74
|
|
|
75
75
|
# These are all requirements on the master
|
|
76
76
|
execute_on_master do
|
|
77
|
-
has_cron({:name => "maintain script", :command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3", :requires => get_gempackage("poolparty-latest")})
|
|
78
77
|
# TODO: Update this so it only runs when needed
|
|
79
78
|
has_exec(:name => "start master messenger", :command => ". /etc/profile && server-start-master", :requires => [get_gempackage("poolparty-latest"), get_exec("build_messenger")], :onlyif => "ps aux | grep beam | grep master")
|
|
80
79
|
|
|
80
|
+
has_cron({:name => "maintain script", :command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3", :requires => [get_gempackage("poolparty-latest"), get_cron("puppetd runner"), get_cron("Load handler"), get_exec("start master messenger"), get_service("haproxy")]})
|
|
81
|
+
|
|
81
82
|
has_remotefile(:name => "/usr/bin/puppetcleaner") do
|
|
82
83
|
mode 744
|
|
83
84
|
template File.join(File.dirname(__FILE__), "..", "templates/puppetcleaner")
|
|
@@ -33,7 +33,6 @@ module PoolParty
|
|
|
33
33
|
def set_default_options
|
|
34
34
|
self.verbose false
|
|
35
35
|
self.quiet false
|
|
36
|
-
self.version PoolParty::VERSION::STRING
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def parse_options(&blk)
|
|
@@ -42,40 +41,43 @@ module PoolParty
|
|
|
42
41
|
opts.banner = "Usage: #{progname} #{@abstract ? "[command] " : ""}[options]"
|
|
43
42
|
|
|
44
43
|
opts.separator ""
|
|
45
|
-
opts.separator "Options:"
|
|
46
|
-
|
|
47
|
-
opts.on('-V', '--version', 'Display the version') { output_version ; exit 0 }
|
|
48
|
-
opts.on('-v', '--verbose', 'Be verbose') { self.verbose true }
|
|
49
|
-
opts.on('-s [file]', '--spec-file [file]', 'Set the spec file') { |file| self.spec file }
|
|
50
|
-
opts.on('-t', '--test', 'Testing mode') { self.testing true }
|
|
51
|
-
|
|
52
|
-
blk.call(opts, self) if blk
|
|
53
44
|
|
|
54
45
|
unless @abstract
|
|
55
|
-
opts.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
opts.separator "Options:"
|
|
47
|
+
|
|
48
|
+
opts.on('-v', '--verbose', 'Be verbose') { self.verbose true }
|
|
49
|
+
opts.on('-s [file]', '--spec-file [file]', 'Set the spec file') { |file| self.spec file }
|
|
50
|
+
opts.on('-t', '--test', 'Testing mode') { self.testing true }
|
|
51
|
+
|
|
52
|
+
blk.call(opts, self) if blk
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
opts.on('-V', '--version', 'Display the version') { puts @version ; exit 0 }
|
|
56
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
57
|
+
puts opts
|
|
58
|
+
puts @extra_help
|
|
59
|
+
exit
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
opts.parse(@arguments.dup)
|
|
63
63
|
|
|
64
64
|
process_options
|
|
65
65
|
output_options if verbose
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
cl
|
|
66
|
+
unless @abstract
|
|
67
|
+
self.loaded_pool load_pool(self.spec || Binary.get_existing_spec_location)
|
|
68
|
+
|
|
69
|
+
self.loaded_clouds extract_cloud_from_options(self)
|
|
70
|
+
self.loaded_pools extract_pool_from_options(self)
|
|
71
|
+
|
|
72
|
+
reject_junk_options!
|
|
73
|
+
raise CloudNotFoundException.new("Please specify your cloud with -s, move it to ./pool.spec or in your POOL_SPEC environment variable") unless loaded_clouds && !loaded_clouds.empty?
|
|
74
|
+
loaded_clouds.each do |cl|
|
|
75
|
+
cl.configure(self.options)
|
|
76
|
+
end
|
|
75
77
|
end
|
|
76
78
|
end
|
|
77
79
|
def reject_junk_options!
|
|
78
|
-
%w(loaded_pool cloudname).each do |opt|
|
|
80
|
+
%w(loaded_pool cloudname extract_pool_from_options).each do |opt|
|
|
79
81
|
@options.delete(opt.to_sym)
|
|
80
82
|
end
|
|
81
83
|
end
|
|
@@ -83,7 +85,7 @@ module PoolParty
|
|
|
83
85
|
end
|
|
84
86
|
|
|
85
87
|
def output_version
|
|
86
|
-
puts version
|
|
88
|
+
puts @version
|
|
87
89
|
end
|
|
88
90
|
|
|
89
91
|
end
|
|
@@ -93,6 +93,7 @@ cp #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_
|
|
|
93
93
|
|
|
94
94
|
def install_poolparty
|
|
95
95
|
<<-EOE
|
|
96
|
+
#{installer_for("ruby rubygems")}
|
|
96
97
|
cd /var/poolparty
|
|
97
98
|
wget http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem -O logging.gem 2>&1
|
|
98
99
|
wget http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem -O ZenTest.gem 2>&1
|
|
@@ -5,7 +5,8 @@ module PoolParty
|
|
|
5
5
|
def install_tasks
|
|
6
6
|
[
|
|
7
7
|
setup_puppet,
|
|
8
|
-
setup_configs
|
|
8
|
+
setup_configs,
|
|
9
|
+
run_once_and_clean
|
|
9
10
|
] << configure_tasks
|
|
10
11
|
end
|
|
11
12
|
|
|
@@ -29,6 +30,13 @@ module PoolParty
|
|
|
29
30
|
# /usr/bin/puppetrerun
|
|
30
31
|
EOS
|
|
31
32
|
end
|
|
33
|
+
|
|
34
|
+
def run_once_and_clean
|
|
35
|
+
<<-EOS
|
|
36
|
+
. /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master #{unix_hide_string}
|
|
37
|
+
rm -rf /etc/puppet/ssl
|
|
38
|
+
EOS
|
|
39
|
+
end
|
|
32
40
|
|
|
33
41
|
# /etc/init.d/puppetmasterd stop
|
|
34
42
|
# puppetd --listen --fqdn #{@instance.name}
|
|
@@ -4,7 +4,35 @@ module PoolParty
|
|
|
4
4
|
class MemoryMonitor < BaseMonitor
|
|
5
5
|
|
|
6
6
|
def run
|
|
7
|
-
|
|
7
|
+
uname = %x[uname]
|
|
8
|
+
case uname.chomp
|
|
9
|
+
when "Darwin"
|
|
10
|
+
darwin_memory_usage
|
|
11
|
+
else
|
|
12
|
+
nix_memory_usage
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def darwin_memory_usage
|
|
17
|
+
str = %x[vm_stat]
|
|
18
|
+
keep_array = []
|
|
19
|
+
array_of_strings = str
|
|
20
|
+
begin
|
|
21
|
+
free_memory = array_of_strings[/free:(\W*)+([0-9]+)/, 2].to_f
|
|
22
|
+
active_memory = array_of_strings[/active:(\W*)([0-9]+)/, 2].to_f
|
|
23
|
+
inactive_memory = array_of_strings[/inactive:(\W*)([0-9]+)/, 2].to_f
|
|
24
|
+
|
|
25
|
+
used_memory = (active_memory + inactive_memory)
|
|
26
|
+
total_memory = (free_memory + active_memory + inactive_memory)
|
|
27
|
+
|
|
28
|
+
used_memory / total_memory
|
|
29
|
+
rescue Exception => e
|
|
30
|
+
0.0
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def nix_memory_usage
|
|
35
|
+
str = %x[free -m #{unix_hide_string} | grep -i mem]
|
|
8
36
|
begin
|
|
9
37
|
total_memory = str.split[1].to_f
|
|
10
38
|
used_memory = str.split[2].to_f
|
|
@@ -13,7 +41,6 @@ module PoolParty
|
|
|
13
41
|
rescue Exception => e
|
|
14
42
|
0.0
|
|
15
43
|
end
|
|
16
|
-
|
|
17
44
|
end
|
|
18
45
|
|
|
19
46
|
end
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
The connection to the messenger from poolparty, the client
|
|
3
3
|
=end
|
|
4
4
|
module PoolParty
|
|
5
|
+
def reconfigure_cloud!
|
|
6
|
+
Messenger.messenger_send!("reconfigure_cloud")
|
|
7
|
+
end
|
|
5
8
|
module Messenger
|
|
6
9
|
|
|
7
10
|
# TODO: Fix cookie setting
|
|
@@ -22,8 +25,8 @@ module PoolParty
|
|
|
22
25
|
|
|
23
26
|
# Helper methods
|
|
24
27
|
def self.startup_remote_messenger(hostname, testing=false)
|
|
25
|
-
messenger_send!("")
|
|
26
|
-
testing ? command : %x[#{command}]
|
|
28
|
+
# messenger_send!("")
|
|
29
|
+
# testing ? command : %x[#{command}]
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
end
|
|
@@ -77,7 +77,21 @@ module PoolParty
|
|
|
77
77
|
# If no keypair is passed, select them all
|
|
78
78
|
def list_of_instances(keyp=nil)
|
|
79
79
|
key = keyp ? keyp : keypair
|
|
80
|
-
@describe_instances
|
|
80
|
+
unless @describe_instances
|
|
81
|
+
tmpInstanceList = describe_instances.select {|a| key ? a[:keypair] == key : true }
|
|
82
|
+
has_master = tmpInstanceList.collect {|a| a[:name] }.include?("master")
|
|
83
|
+
if has_master
|
|
84
|
+
@describe_instances = tmpInstanceList
|
|
85
|
+
else
|
|
86
|
+
@id = 0
|
|
87
|
+
@describe_instances = tmpInstanceList.sort_by {|a| a[:status] }.map do |inst|
|
|
88
|
+
inst[:name] = (@id == 0 ? "master" : "node#{@id}")
|
|
89
|
+
@id += 1
|
|
90
|
+
inst
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
@describe_instances
|
|
81
95
|
end
|
|
82
96
|
# Instances
|
|
83
97
|
# Get the master from the cloud
|
|
@@ -16,14 +16,14 @@ module PoolParty
|
|
|
16
16
|
creates "#{::File.join( (parent.cwd ? parent.cwd : cwd), ::File.basename(parent.source, ::File.extname(parent.source)) )}/.git"
|
|
17
17
|
end
|
|
18
18
|
has_exec(:name => "update-#{name}", :requires => get_exec("git-#{name}")) do
|
|
19
|
-
cwd get_exec("git-#{parent.name}").
|
|
19
|
+
cwd ::File.dirname(get_exec("git-#{parent.name}").creates)
|
|
20
20
|
command "git pull"
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def at(dir)
|
|
25
25
|
cwd dir
|
|
26
|
-
has_directory(:name => "#{dir}", :requires => "#{::File.dirname(dir)}")
|
|
26
|
+
has_directory(:name => "#{dir}", :requires => get_directory("#{::File.dirname(dir)}"))
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Since git is not a native type, we have to say which core resource
|
data/lib/poolparty/version.rb
CHANGED
data/lib/poolparty.rb
CHANGED
|
@@ -23,6 +23,7 @@ require "#{File.dirname(__FILE__)}/poolparty/version"
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
Kernel.load_p File.dirname(__FILE__) + "/poolparty/pool"
|
|
26
|
+
Logging.init :debug, :info, :warn, :error, :fatal
|
|
26
27
|
|
|
27
28
|
module PoolParty
|
|
28
29
|
include FileWriter
|
|
@@ -31,6 +32,12 @@ module PoolParty
|
|
|
31
32
|
@logger ||= make_new_logger
|
|
32
33
|
end
|
|
33
34
|
|
|
35
|
+
class PoolParty
|
|
36
|
+
def initialize(spec)
|
|
37
|
+
Script.inflate(spec) if spec
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
34
41
|
private
|
|
35
42
|
#:nodoc:#
|
|
36
43
|
def make_new_logger
|