MB-8801 ability to specify the password in cbreset_password

also:
- removed duplicate password validation code
- moved reset_admin_password to menelaus_web to reuse the validation code

Change-Id: I15015b934b4e82a3cdc4c1fc182a84b04328f6cd
Reviewed-on: http://review.couchbase.org/28238
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5904 remove passwords from xdc status logging

Change-Id: I5a02b6c8a841176cb837dc6e1f01559b7a82e24f
Reviewed-on: http://review.couchbase.org/28277
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: removed dead sasl password validation code

Change-Id: I8b18943423be1d65bc3718d3e88bcc6da035cc7e
Reviewed-on: http://review.couchbase.org/28305
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
MB-8731: disallow non-utf8 passwords

Because otherwise they cannot be sent over json

Change-Id: I53241a20d3426932f9edd248dd1503939522fa3c
Reviewed-on: http://review.couchbase.org/28306
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
MB-8787 Use correct parameter in get_replication_batch_size().

worker_batch_size is the batch size in items not in kilobytes.

Change-Id: Id4b0a5ce24dc1de304ad5fe664cd0a0a93f63f59
Reviewed-on: http://review.couchbase.org/28161
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Remove useless function.

It didn't do what it stated in it's name. And what it actually did is
already done by ensure_rep_db_exists called from changes_feed_loop.

Change-Id: Ie7c146427ab78cc6607ad30c48e9cffe372fae90
Reviewed-on: http://review.couchbase.org/28163
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Make xdcr logging don't repeat itself.

Change-Id: I9ee6b338db022d8ffeaf54f22d19291955e95b50
Reviewed-on: http://review.couchbase.org/28315
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Always grab options for databases from rep document.

Change-Id: Ib442302a2e5e8be51ff33588ce3ada760dbf65b7
Reviewed-on: http://review.couchbase.org/28165
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Don't parse fields that we never put to rep document.

Or those that are not actually read.

Change-Id: If18397f786a789eac770437943884c3b29d80f53
Reviewed-on: http://review.couchbase.org/28166
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Don't use couch_config where it makes no sense.

Particularly:
  1. don't ask for replicator db name because in many places we just
  assume its name is _replicator anyway
  2. currently our replications are always continuous and xdcr code
  doesn't even bother to check the value of 'continuous' parameter; so
  I got rid of it too

Change-Id: I6ceb802329bb678c435c51706784ef5c904cefe1
Reviewed-on: http://review.couchbase.org/28167
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Remove dump_parameters.

Parameters can be changed dynamically so it doesn't make sense to dump
them only once on xdc_rep_manager start.

Besides, all the #rep records are going to have a complete list of
parameters for the replication. And whenever replication gets
started, this record will be logged by standard erlang mechanisms.

Change-Id: I3b8f103960da708528050bebd59dc9566e0d8eeb
Reviewed-on: http://review.couchbase.org/28168
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Name global parameters similarly to the per rep ones.

To avoid additional confusion.

Change-Id: Ibab7c02a3cff6bff1a85228bb4b723557ebb5464
Reviewed-on: http://review.couchbase.org/28169
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Let users choose between xmem/capi replications.

I just added 'type' parameter to the ones understood by
createReplication REST endpoint. Valid values are capi and xmem. They
translate to type=xdc and type=xdc-xmem in replicator document
correspondingly.

Change-Id: Iacacd51d7525cf9c66259bcce72037eedd1667cd
Reviewed-on: http://review.couchbase.org/28170
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Use type from replicator document to decide on rep mode.

Change-Id: Ia856cdbacfefc25179e8d26af7083a6a94a626ee
Reviewed-on: http://review.couchbase.org/28171
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Expose replication type in xdcr task.

Change-Id: I55f11c066d6916a8a588287d2c4b79a53eed0163
Reviewed-on: http://review.couchbase.org/28172
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Don't torture ns_config for every single replicated doc.

Change-Id: I39745fcb32725356955c8abde05e38691e1602f2
Reviewed-on: http://review.couchbase.org/28173
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8787 Account for worker_batch_size parameter too.

Change-Id: If22de82cbe3254680def894ff2fdd7c26cd40634
Reviewed-on: http://review.couchbase.org/28174
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Add xdc_rdoc_replication_srv:get_full_replicator_doc.

It returns a replicator document by id. Contrary to
find_all_replication_docs it doesn't strip any fields from the
document body and ensures that the field names are binaries.

Change-Id: I6e7b95332a5d332e50b29550d16d009e37978bc8
Reviewed-on: http://review.couchbase.org/28176
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Add xdc_settings module.

Its responsibility is to more or less abstract working with both
global and per replication settings.

Per replication settings are stored in replicator document body. I
chose to store them in the replicator document for several reasons:
  1. this mechanism already exists and it was originally supposed to
  be used exactly this way
  2. storing them in ns_config would pose certain questions:
      - coordination between ns_config and replicator db is hard
        (that's the reason we don't really delete cluster references
        but just mark them as deleted)
      - there're two ways the settings for different replications
        could have been stored in ns_config: as a list under one
        key (like buckets) or as an independent keys; the former has a
        problem of conflicts when different replications are edited
        from different places and higher gossiping rate because every
        minor change would require to replicate all the settings, the
        latter doesn't have a way of deleting settings for
        replications that no longer exist

Global settings are stored in ns_config indexed by tuples {xdcr,
parameter_name}.

Change-Id: I034456bb84268e018ea869a4677e1416bb1eb74d
Reviewed-on: http://review.couchbase.org/28177
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Consolidation of replication parameters grabbing.

There are only few places left where ns_config is accessed directly.
Namely:
  - xdc_rep_utils:make_options
  - xdc_rep_utils:update_options
  - xdc_rep_utils:get_trace_dump_invprob
  - xdc_rep_manager:init
  - xdc_replication:handle_call({check_tokens...

It will make easier consequent integration of new replication settings
feature.

Change-Id: Ic8dd3d41215475036e2ca1ae48bb9f2c2b26dce1
Reviewed-on: http://review.couchbase.org/28178
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>