From dc20aebe8e0b11b07ab1d04077395c15a1795869 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Wed, 18 Jun 2014 17:08:35 +0100 Subject: rabbitmq-plugins set. --- docs/rabbitmq-plugins.1.xml | 64 +++++++++++++++++++++++++++++++++------------ src/rabbit_plugins_main.erl | 22 ++++++++++++++++ 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/docs/rabbitmq-plugins.1.xml b/docs/rabbitmq-plugins.1.xml index e891969fa4..fb5f8e2775 100644 --- a/docs/rabbitmq-plugins.1.xml +++ b/docs/rabbitmq-plugins.1.xml @@ -63,6 +63,16 @@ enabled. Implicitly enabled plugins are automatically disabled again when they are no longer required. + + + The enable, disable and + set commands will update the plugins file and + then attempt to connect to the broker and ensure it is running + all enabled plugins. By default if it is not possible to connect + to the running broker (for example if it is stopped) then a + warning is displayed. Specify --online or + --offline to change this behaviour. + @@ -150,14 +160,7 @@ - Enables the specified plugins and all their - dependencies. This will update the enabled plugins file - and then attempt to connect to the broker and ensure it is - running all enabled plugins. By default if it is not - possible to connect to the running broker (for example if - it is stopped) then a warning is displayed. Specify - --online or - --offline to change this. + Enables the specified plugins and all their dependencies. For example: @@ -188,14 +191,7 @@ - Disables the specified plugins and all their - dependencies. This will update the enabled plugins file - and then attempt to connect to the broker and ensure it is - running all enabled plugins. By default if it is not - possible to connect to the running broker (for example if - it is stopped) then a warning is displayed. Specify - --online or - --offline to change this. + Disables the specified plugins and all their dependencies. For example: @@ -206,6 +202,42 @@ + + + set --offline --online plugin ... + + + + --offline + Just modify the enabled plugins file. + + + --online + Treat failure to connect to the running broker as fatal. + + + plugin + Zero or more plugins to enable. + + + + Enables the specified plugins and all their + dependencies. Unlike rabbitmq-plugins + enable this command ignores and overwrites any + existing plugin configuration. rabbitmq-plugins + set with no plugin arguments is a legal command + meaning "disable all plugins". + + + For example: + rabbitmq-plugins set rabbitmq_management + + This command enables the management + plugin and its dependencies and disables everything else. + + + + diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index a3f12c96c8..7e9c4d60a9 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -44,6 +44,7 @@ [{list, [?VERBOSE_DEF, ?MINIMAL_DEF, ?ENABLED_DEF, ?ENABLED_ALL_DEF]}, {enable, [?OFFLINE_DEF, ?ONLINE_DEF]}, {disable, [?OFFLINE_DEF, ?ONLINE_DEF]}, + {set, [?OFFLINE_DEF, ?ONLINE_DEF]}, {sync, []}]). %%---------------------------------------------------------------------------- @@ -157,6 +158,27 @@ action(enable, Node, ToEnable0, Opts, PluginsFile, PluginsDir) -> action_change( Opts, Node, ImplicitlyEnabled, NewImplicitlyEnabled, PluginsFile); +action(set, Node, ToSet0, Opts, PluginsFile, PluginsDir) -> + ToSet = [list_to_atom(Name) || Name <- ToSet0], + AllPlugins = rabbit_plugins:list(PluginsDir), + Enabled = rabbit_plugins:read_enabled(PluginsFile), + ImplicitlyEnabled = rabbit_plugins:dependencies(false, Enabled, AllPlugins), + Missing = ToSet -- plugin_names(AllPlugins), + case Missing of + [] -> ok; + _ -> throw({error_string, fmt_missing(Missing)}) + end, + NewImplicitlyEnabled = rabbit_plugins:dependencies(false, + ToSet, AllPlugins), + write_enabled_plugins(PluginsFile, ToSet), + case NewImplicitlyEnabled of + [] -> io:format("All plugins are now disabled.~n"); + _ -> print_list("The following plugins are now enabled:", + NewImplicitlyEnabled) + end, + action_change( + Opts, Node, ImplicitlyEnabled, NewImplicitlyEnabled, PluginsFile); + action(disable, Node, ToDisable0, Opts, PluginsFile, PluginsDir) -> case ToDisable0 of [] -> throw({error_string, "Not enough arguments for 'disable'"}); -- cgit v1.2.1 From fe20643701ecc350293810a0937861f92948e7e1 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Wed, 18 Jun 2014 17:10:22 +0100 Subject: Maybe clearer. --- docs/rabbitmq-plugins.1.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rabbitmq-plugins.1.xml b/docs/rabbitmq-plugins.1.xml index fb5f8e2775..f7be2d2995 100644 --- a/docs/rabbitmq-plugins.1.xml +++ b/docs/rabbitmq-plugins.1.xml @@ -224,7 +224,7 @@ Enables the specified plugins and all their dependencies. Unlike rabbitmq-plugins enable this command ignores and overwrites any - existing plugin configuration. rabbitmq-plugins + existing enabled plugins. rabbitmq-plugins set with no plugin arguments is a legal command meaning "disable all plugins". -- cgit v1.2.1