aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl
diff options
context:
space:
mode:
authorjoewilliams <[email protected]>2011-10-18 10:30:56 -0700
committerHenrik Nord <[email protected]>2011-10-20 09:50:15 +0200
commit66be346a3b0f04bb010608ad6125ecec501384c2 (patch)
tree1dd3cb18a81fd5fa106e007fba0a951c55bb85ab /lib/sasl
parent02ec67177b2f5d2de371362e5bb3c9b9771fb0b8 (diff)
downloadotp-66be346a3b0f04bb010608ad6125ecec501384c2.tar.gz
otp-66be346a3b0f04bb010608ad6125ecec501384c2.tar.bz2
otp-66be346a3b0f04bb010608ad6125ecec501384c2.zip
Add release_handler:which_releases/1
This is an extension to which_releases that allows a user to specify the status of the releases they wish to be returned. For instance it allows for quickly determining which release is 'permanent' without the need of parsing the entire release list.
Diffstat (limited to 'lib/sasl')
-rw-r--r--lib/sasl/doc/src/release_handler.xml12
-rw-r--r--lib/sasl/src/release_handler.erl22
-rw-r--r--lib/sasl/test/release_handler_SUITE.erl29
3 files changed, 61 insertions, 2 deletions
diff --git a/lib/sasl/doc/src/release_handler.xml b/lib/sasl/doc/src/release_handler.xml
index 5ac0dc1acc..cf05b1a67d 100644
--- a/lib/sasl/doc/src/release_handler.xml
+++ b/lib/sasl/doc/src/release_handler.xml
@@ -431,6 +431,18 @@ release_handler:set_unpacked(RelFile, [{myapp,"1.0","/home/user"},...]).
<p>Returns all releases known to the release handler.</p>
</desc>
</func>
+ <func>
+ <name>which_releases(Status) -> [{Name, Vsn, Apps, Status}]</name>
+ <fsummary>Return all known releases of a specific status</fsummary>
+ <type>
+ <v>Name = Vsn = string()</v>
+ <v>Apps = ["App-Vsn"]</v>
+ <v>Status = unpacked | current | permanent | old</v>
+ </type>
+ <desc>
+ <p>Returns all releases known to the release handler of a specific status.</p>
+ </desc>
+ </func>
</funcs>
<section>
diff --git a/lib/sasl/src/release_handler.erl b/lib/sasl/src/release_handler.erl
index bc08f94dff..5650f1433d 100644
--- a/lib/sasl/src/release_handler.erl
+++ b/lib/sasl/src/release_handler.erl
@@ -27,7 +27,8 @@
unpack_release/1,
check_install_release/1, check_install_release/2,
install_release/1, install_release/2, remove_release/1,
- which_releases/0, make_permanent/1, reboot_old_release/1,
+ which_releases/0, which_releases/1, make_permanent/1,
+ reboot_old_release/1,
set_unpacked/2, set_removed/1, install_file/2]).
-export([upgrade_app/2, downgrade_app/2, downgrade_app/3,
upgrade_script/2, downgrade_script/3,
@@ -305,6 +306,14 @@ which_releases() ->
call(which_releases).
%%-----------------------------------------------------------------
+%% Returns: [{Name, Vsn, [LibName], Status}]
+%% Status = unpacked | current | permanent | old
+%%-----------------------------------------------------------------
+which_releases(Status) ->
+ Releases = which_releases(),
+ get_releases_with_status(Releases, Status, []).
+
+%%-----------------------------------------------------------------
%% check_script(Script, LibDirs) -> ok | {error, Reason}
%%-----------------------------------------------------------------
check_script(Script, LibDirs) ->
@@ -2010,3 +2019,14 @@ get_new_libs([{App,Vsn,_LibDir}|CurrentLibs], NewLibs) ->
end;
get_new_libs([],_) ->
[].
+
+%%-----------------------------------------------------------------
+%% Return a list of releases witch a specific status
+%%-----------------------------------------------------------------
+get_releases_with_status([], _, Acc) ->
+ Acc;
+get_releases_with_status([ {_, _, _, ReleaseStatus } = Head | Tail],
+ Status, Acc) when ReleaseStatus == Status ->
+ get_releases_with_status(Tail, Status, [Head | Acc]);
+get_releases_with_status([_ | Tail], Status, Acc) ->
+ get_releases_with_status(Tail, Status, Acc).
diff --git a/lib/sasl/test/release_handler_SUITE.erl b/lib/sasl/test/release_handler_SUITE.erl
index af2183bfff..286aff9bb0 100644
--- a/lib/sasl/test/release_handler_SUITE.erl
+++ b/lib/sasl/test/release_handler_SUITE.erl
@@ -58,7 +58,8 @@ cases() ->
[otp_2740, otp_2760, otp_5761, otp_9402, otp_9417,
otp_9395_check_old_code, otp_9395_check_and_purge,
otp_9395_update_many_mods, otp_9395_rm_many_mods,
- instructions, eval_appup, supervisor_which_children_timeout].
+ instructions, eval_appup, supervisor_which_children_timeout,
+ release_handler_which_releases].
groups() ->
[{release,[],
@@ -546,6 +547,32 @@ supervisor_which_children_timeout(cleanup, Conf) ->
stop_node(node_name(supervisor_which_children_timeout)).
%%-----------------------------------------------------------------
+%% release_handler:which_releases/0 and 1 test
+%%-----------------------------------------------------------------
+release_handler_which_releases(Conf) ->
+ PrivDir = priv_dir(Conf),
+ Dir = filename:join(PrivDir,"release_handler_which_releases"),
+ DataDir = ?config(data_dir,Conf),
+ LibDir = filename:join([DataDir,release_handler_timeouts]),
+
+ Rel1 = create_and_install_fake_first_release(Dir,[{dummy,"0.1",LibDir}]),
+
+ {ok, Node} = t_start_node(release_handler_which_releases, Rel1, []),
+ Releases0 = rpc:call(Node, release_handler, which_releases, []),
+ Releases1 = rpc:call(Node, release_handler, which_releases, [permanent]),
+ Releases2 = rpc:call(Node, release_handler, which_releases, [old]),
+
+ 1 = length(Releases0),
+ 1 = length(Releases1),
+ 0 = length(Releases2),
+
+ ?t:format("release_handler:which_releases/0: ~p~n", [Releases0]),
+ ?t:format("release_handler:which_releases/1: ~p~n", [Releases1]),
+ ?t:format("release_handler:which_releases/1: ~p~n", [Releases2]),
+
+ ok.
+
+%%-----------------------------------------------------------------
%% Ticket: OTP-2740
%% Slogan: vsn not numeric doesn't work so good in release_handling
%%-----------------------------------------------------------------