@rest_initialiser(cluster_init_check=True, version_check=True, enterprise_check=False)
def execute(self, opts):
    if (sum([opts.set, opts.get, opts.cancel, opts.pending_info]) != 1):
        _exit_if_errors(['Provide either --set, --get, --cancel or --pending-info'])
    if opts.get:
        (settings, err) = self.rest.get_settings_rebalance()
        _exit_if_errors(err)
        if self.enterprise:
            (retry_settings, err) = self.rest.get_settings_rebalance_retry()
            _exit_if_errors(err)
            settings.update(retry_settings)
        if (opts.output == 'json'):
            print(json.dumps(settings))
        else:
            if self.enterprise:
                print(f"Automatic rebalance retry {('enabled' if settings['enabled'] else 'disabled')}")
                print(f"Retry wait time: {settings['afterTimePeriod']}")
                print(f"Maximum number of retries: {settings['maxAttempts']}")
            print(f"Maximum number of vBucket move per node: {settings['rebalanceMovesPerNode']}")
    elif opts.set:
        if ((not self.enterprise) and ((opts.enable is not None) or (opts.wait_for is not None) or (opts.max_attempts is not None))):
            _exit_if_errors(['Automatic rebalance retry configuration is an Enterprise Edition only feature'])
        if (opts.enable == '1'):
            opts.enable = 'true'
        else:
            opts.enable = 'false'
        if ((opts.wait_for is not None) and ((opts.wait_for < 5) or (opts.wait_for > 3600))):
            _exit_if_errors(['--wait-for must be a value between 5 and 3600'])
        if ((opts.max_attempts is not None) and ((opts.max_attempts < 1) or (opts.max_attempts > 3))):
            _exit_if_errors(['--max-attempts must be a value between 1 and 3'])
        if self.enterprise:
            (_, err) = self.rest.set_settings_rebalance_retry(opts.enable, opts.wait_for, opts.max_attempts)
            _exit_if_errors(err)
        if (opts.moves_per_node is not None):
            if (not (1 <= opts.moves_per_node <= 64)):
                _exit_if_errors(['--moves-per-node must be a value between 1 and 64'])
            (_, err) = self.rest.set_settings_rebalance(opts.moves_per_node)
            _exit_if_errors(err)
        _success('Rebalance settings updated')
    elif (opts.cancel and (not self.enterprise)):
        _exit_if_errors(['Automatic rebalance retry configuration is an Enterprise Edition only feature'])
        if (opts.rebalance_id is None):
            _exit_if_errors(['Provide the failed rebalance id using --rebalance-id <id>'])
        (_, err) = self.rest.cancel_rebalance_retry(opts.rebalance_id)
        _exit_if_errors(err)
        _success('Rebalance retry canceled')
    else:
        if (not self.enterprise):
            _exit_if_errors(['Automatic rebalance retry configuration is an Enterprise Edition only feature'])
        (rebalance_info, err) = self.rest.get_rebalance_info()
        _exit_if_errors(err)
        print(json.dumps(rebalance_info))
@rest_initialiser(cluster_init_check=True, version_check=True, enterprise_check=False)
def execute(self, opts):
    if (sum([opts.set, opts.get, opts.cancel, opts.pending_info]) != 1):
        _exit_if_errors(['Provide either --set, --get, --cancel or --pending-info'])
    if opts.get:
        (settings, err) = self.rest.get_settings_rebalance()
        _exit_if_errors(err)
        if self.enterprise:
            (retry_settings, err) = self.rest.get_settings_rebalance_retry()
            _exit_if_errors(err)
            settings.update(retry_settings)
        if (opts.output == 'json'):
            print(json.dumps(settings))
        else:
            if self.enterprise:
                print(f"Automatic rebalance retry {('enabled' if settings['enabled'] else 'disabled')}")
                print(f"Retry wait time: {settings['afterTimePeriod']}")
                print(f"Maximum number of retries: {settings['maxAttempts']}")
            print(f"Maximum number of vBucket move per node: {settings['rebalanceMovesPerNode']}")
    elif opts.set:
        if ((not self.enterprise) and ((opts.enable is not None) or (opts.wait_for is not None) or (opts.max_attempts is not None))):
            _exit_if_errors(['Automatic rebalance retry configuration is an Enterprise Edition only feature'])
        if (opts.enable == '1'):
            opts.enable = 'true'
        else:
            opts.enable = 'false'
        if ((opts.wait_for is not None) and ((opts.wait_for < 5) or (opts.wait_for > 3600))):
            _exit_if_errors(['--wait-for must be a value between 5 and 3600'])
        if ((opts.max_attempts is not None) and ((opts.max_attempts < 1) or (opts.max_attempts > 3))):
            _exit_if_errors(['--max-attempts must be a value between 1 and 3'])
        if self.enterprise:
            (_, err) = self.rest.set_settings_rebalance_retry(opts.enable, opts.wait_for, opts.max_attempts)
            _exit_if_errors(err)
        if (opts.moves_per_node is not None):
            if (not (1 <= opts.moves_per_node <= 64)):
                _exit_if_errors(['--moves-per-node must be a value between 1 and 64'])
            (_, err) = self.rest.set_settings_rebalance(opts.moves_per_node)
            _exit_if_errors(err)
        _success('Rebalance settings updated')
    elif (opts.cancel and (not self.enterprise)):
        _exit_if_errors(['Automatic rebalance retry configuration is an Enterprise Edition only feature'])
        if (opts.rebalance_id is None):
            _exit_if_errors(['Provide the failed rebalance id using --rebalance-id <id>'])
        (_, err) = self.rest.cancel_rebalance_retry(opts.rebalance_id)
        _exit_if_errors(err)
        _success('Rebalance retry canceled')
    else:
        if (not self.enterprise):
            _exit_if_errors(['Automatic rebalance retry configuration is an Enterprise Edition only feature'])
        (rebalance_info, err) = self.rest.get_rebalance_info()
        _exit_if_errors(err)
        print(json.dumps(rebalance_info))