diff options
author | Joan Touzet <wohali@users.noreply.github.com> | 2018-11-07 16:23:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 16:23:01 -0500 |
commit | 33c39a9f1d9bfffdefb263953de704e1a5a1b1eb (patch) | |
tree | 3999e04f3b5388b6431cdd3ebd11eeca18a60f9b | |
parent | b0f65e8b3b036ea5acde07847fb28a8754527980 (diff) | |
download | couchdb-33c39a9f1d9bfffdefb263953de704e1a5a1b1eb.tar.gz |
Copy _security object in couchup; python3 fix (#1721)
-rwxr-xr-x | rel/overlay/bin/couchup | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/rel/overlay/bin/couchup b/rel/overlay/bin/couchup index 6532170aa..75b7d7e94 100755 --- a/rel/overlay/bin/couchup +++ b/rel/overlay/bin/couchup @@ -172,6 +172,25 @@ def _put_filter(args, db=None): print(exc.response.text) exit(1) +def _do_security(args, db=None): + """Copies the _security object from source to target DB.""" + try: + req = requests.get( + 'http://127.0.0.1:{}/{}/_security'.format( + args['local_port'], db), + auth=args['creds']) + req.raise_for_status() + security_doc = _tojson(req) + req = requests.put( + 'http://127.0.0.1:{}/{}/_security'.format( + args['clustered_port'], db), + data=json.dumps(security_doc), + auth=args['creds']) + req.raise_for_status() + except requests.exceptions.HTTPError as exc: + print(exc.response.text) + exit(1) + def _replicate(args): args = _args(args) if args['all_dbs']: @@ -229,6 +248,11 @@ def _replicate(args): if req.get('no_changes'): if not args['quiet']: print("No changes, replication is caught up.") + + if not args['quiet']: + print('Copying _security object for ' + db + '...') + _do_security(args, db) + if not args['quiet']: print("Replication complete.") @@ -474,7 +498,11 @@ def main(argv): parser_delete.set_defaults(func=_delete) args = parser.parse_args(argv[1:]) - args.func(args) + try: + args.func(args) + except AttributeError: + parser.print_help() + sys.exit(0) if __name__ == '__main__': main(sys.argv) |