summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kowalski <robertkowalski@apache.org>2015-09-16 15:05:39 +0200
committerRobert Kowalski <robertkowalski@apache.org>2015-09-18 12:35:24 +0200
commit647ffbc4a1216239045af1e210863b9086f71cf4 (patch)
treee71fe02d99e3a13bec20e8cbac1e7e9f290525ff
parentbdb8a0c19e95316912488b986de8d113690b0cd6 (diff)
downloadcouchdb-647ffbc4a1216239045af1e210863b9086f71cf4.tar.gz
fix enable_cluster_http for admin-party clusters
PR: #7 PR-URL: https://github.com/apache/couchdb-setup/pull/7 Reviewed-By: Robert Newson <rnewson@apache.org>
-rw-r--r--src/setup.erl28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/setup.erl b/src/setup.erl
index 40679561e..34cbdffcc 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -69,14 +69,22 @@ enable_cluster(Options) ->
enable_cluster_http(Options)
end.
+get_remote_request_options(Options) ->
+ case couch_util:get_value(remote_current_user, Options, undefined) of
+ undefined ->
+ [];
+ _ ->
+ [
+ {basic_auth, {
+ binary_to_list(couch_util:get_value(remote_current_user, Options)),
+ binary_to_list(couch_util:get_value(remote_current_password, Options))
+ }}
+ ]
+ end.
+
enable_cluster_http(Options) ->
% POST to nodeB/_setup
- RequestOptions = [
- {basic_auth, {
- binary_to_list(couch_util:get_value(remote_current_user, Options)),
- binary_to_list(couch_util:get_value(remote_current_password, Options))
- }}
- ],
+ RequestOptions = get_remote_request_options(Options),
Body = ?JSON_ENCODE({[
{<<"action">>, <<"enable_cluster">>},
@@ -138,8 +146,10 @@ enable_cluster_int(Options, no) ->
case Port of
undefined ->
ok;
- Port ->
- config:set("chttpd", "port", integer_to_list(Port))
+ Port when is_binary(Port) ->
+ config:set("chttpd", "port", binary_to_list(Port));
+ Port when is_integer(Port) ->
+ config:set_integer("chttpd", "port", Port)
end,
couch_log:notice("Enable Cluster: ~p~n", [Options]).
%cluster_state:set(enabled).
@@ -168,7 +178,7 @@ add_node(Options) ->
add_node_int(_Options, no) ->
{error, cluster_not_enabled};
add_node_int(Options, ok) ->
- couch_log:notice("add node: ~p~n", [Options]),
+ couch_log:notice("add node_int: ~p~n", [Options]),
ErlangCookie = erlang:get_cookie(),
% POST to nodeB/_setup