Skip to content

Commit

Permalink
print node info a bit more intelligently
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Watson committed May 31, 2012
1 parent f7b0262 commit 0433f5d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/systest_cluster.erl
Expand Up @@ -94,27 +94,10 @@ with_cluster(ClusterId, NodeHandler, Config) ->
end.

%% TODO: make a Handler:status call to get detailed information back...
print_status_info({#'systest.node_info'{host=Host,
id=Name,
handler=Type,
flags=Flags,
apps=Apps,
os_pid=Proc,
on_start=OnStart,
on_stop=OnStop,
owner=Port}, Status}) ->
io_lib:format("Node Info~n"
" name: ~p (status=~p)~n"
" host: ~p~n"
" type: ~p~n"
" args: ~p~n"
" apps: ~p~n"
" proc: ~p~n"
" xtra: ~p~n"
" port: ~p~n"
"----------------------------------------------------~n",
[Name, Status, Host, Type, Flags, Apps,
Proc, [{on_start, OnStart}, {on_stop, OnStop}], Port]).
print_status_info({Node, Status}) ->
Lines = [{status, Status}|systest_utils:node_to_plist(Node)],
lists:flatten("Node Info~n" ++ systest_utils:proplist_format(Lines) ++
"~n----------------------------------------------------").

build_nodes(Cluster, {Host, Nodes}, Config) ->
[systest_node:make_node(Cluster, N, [{host, Host}, {scope, Cluster},
Expand Down
15 changes: 15 additions & 0 deletions src/systest_utils.erl
Expand Up @@ -27,9 +27,23 @@
-include_lib("kernel/include/inet.hrl").

-export([is_epmd_contactable/2, temp_dir/0]).
-export([node_to_plist/1, proplist_format/1]).

-define(DEFAULT_EPMD_PORT, 4369).

node_to_plist(N) ->
Attrs = systest_node:info_node_info(fields) -- [private, config],
[{K, systest_node:get_node_info(K, N)} || K <- Attrs].

proplist_format(L) ->
lists:flatten(
[begin
Fmt = if is_list(V) andalso
is_integer(hd(V)) -> "~s~n";
true -> "~p~n"
end,
io_lib:format(" ~p: " ++ Fmt, [K, V])
end || {K, V} <- L]).
%%
%% @doc returns the atom 'true' if epmd running on Host is visible
%% from the calling node, otherwise {false, Reason::term()}.
Expand Down Expand Up @@ -77,3 +91,4 @@ epmd_port() ->
false -> ?DEFAULT_EPMD_PORT;
PortNum -> list_to_integer(PortNum)
end.

0 comments on commit 0433f5d

Please sign in to comment.