Esempio n. 1
0
    def consume_index(
            opts, sink_spec: str, sink_map, source_bucket, source_map,
            source_design: Union[str, bytes]) -> couchbaseConstants.PUMP_ERROR:
        if not source_design:
            return 0

        try:
            sd = json.loads(source_design)
            if not sd:
                return 0
        except ValueError as e:
            return f'error: could not parse source design; exception: {e!s}'

        try:
            sink_bucket = sink_map['buckets'][0]
            username = opts.username
            password = opts.password
            if opts.username_dest is not None and opts.password_dest is not None:
                username = opts.username_dest
                password = opts.password_dest
            rest = ClusterManager(sink_spec, username, password, opts.ssl,
                                  opts.no_ssl_verify, opts.cacert, False)
            _, errors = rest.restore_index_metadata(sink_bucket['name'], sd)
            return errors
        except ServiceNotAvailableException as e:
            return "No index service in cluster, skipping restore of indexes"
Esempio n. 2
0
    def consume_index(opts, sink_spec: str, sink_map, source_bucket,
                      source_map, source_design: Union[str, bytes]) -> couchbaseConstants.PUMP_ERROR:
        if not source_design:
            return 0

        try:
            sd = json.loads(source_design)
            if not sd:
               return 0
        except ValueError as e:
            return f'error: could not parse source design; exception: {e!s}'

        try:
            sink_bucket = sink_map['buckets'][0]
            username = opts.username
            password = opts.password
            if opts.username_dest is not None and opts.password_dest is not None:
                username = opts.username_dest
                password = opts.password_dest
            rest = ClusterManager(sink_spec, username, password, opts.ssl, opts.no_ssl_verify,
                                  opts.cacert, False)
            _, errors = rest.restore_index_metadata(sink_bucket['name'], sd)
            return errors
        except ServiceNotAvailableException as e:
            return "No index service in cluster, skipping restore of indexes"
Esempio n. 3
0
                      source_design):
        if not source_design:
            return 0

        try:
            sd = json.loads(source_design)
            if not sd:
                return 0
        except ValueError, e:
            return "error: could not parse source design; exception: %s" % (e)

        try:
            sink_bucket = sink_map['buckets'][0]
            rest = ClusterManager(sink_spec, opts.username, opts.password,
                                  opts.ssl, False, None, False)
            _, errors = rest.restore_index_metadata(sink_bucket['name'], sd)
            return errors
        except ServiceNotAvailableException, e:
            return "No index service in cluster, skipping restore of indexes"

    @staticmethod
    def consume_design(opts, sink_spec, sink_map, source_bucket, source_map,
                       source_design):
        if not source_design:
            return 0
        try:
            sd = json.loads(source_design)
        except ValueError, e:
            return "error: could not parse source design; exception: %s" % (e)
        if not sd:
            return 0
Esempio n. 4
0
    def consume_index(opts, sink_spec, sink_map, source_bucket, source_map, source_design):
        if not source_design:
            return 0

        try:
            sd = json.loads(source_design)
            if not sd:
               return 0
        except ValueError, e:
            return "error: could not parse source design; exception: %s" % (e)

        try:
            sink_bucket = sink_map['buckets'][0]
            rest = ClusterManager(sink_spec, opts.username, opts.password, opts.ssl, False,
                                  None, False)
            _, errors = rest.restore_index_metadata(sink_bucket['name'], sd)
            return errors
        except ServiceNotAvailableException, e:
            return "No index service in cluster, skipping restore of indexes"

    @staticmethod
    def consume_design(opts, sink_spec, sink_map,
                       source_bucket, source_map, source_design):
        if not source_design:
            return 0
        try:
            sd = json.loads(source_design)
        except ValueError, e:
            return "error: could not parse source design; exception: %s" % (e)
        if not sd:
            return 0