def _pause_resume(self, opts):
    if (opts.replicator_id is None):
        _exit_if_errors(['--xdcr-replicator is needed to pause or resume a replication'])
    (tasks, errors) = self.rest.get_tasks()
    _exit_if_errors(errors)
    for task in tasks:
        if ((task['type'] == 'xdcr') and (task['id'] == opts.replicator_id)):
            if (opts.pause and (task['status'] == 'notRunning')):
                _exit_if_errors(['The replication is not running yet. Pause is not needed'])
            if (opts.resume and (task['status'] == 'running')):
                _exit_if_errors(['The replication is running already. Resume is not needed'])
            break
    if opts.pause:
        (_, errors) = self.rest.pause_xdcr_replication(opts.replicator_id)
        _exit_if_errors(errors)
        _success('XDCR replication paused')
    elif opts.resume:
        (_, errors) = self.rest.resume_xdcr_replication(opts.replicator_id)
        _exit_if_errors(errors)
        _success('XDCR replication resume')
def _pause_resume(self, opts):
    if (opts.replicator_id is None):
        _exit_if_errors(['--xdcr-replicator is needed to pause or resume a replication'])
    (tasks, errors) = self.rest.get_tasks()
    _exit_if_errors(errors)
    for task in tasks:
        if ((task['type'] == 'xdcr') and (task['id'] == opts.replicator_id)):
            if (opts.pause and (task['status'] == 'notRunning')):
                _exit_if_errors(['The replication is not running yet. Pause is not needed'])
            if (opts.resume and (task['status'] == 'running')):
                _exit_if_errors(['The replication is running already. Resume is not needed'])
            break
    if opts.pause:
        (_, errors) = self.rest.pause_xdcr_replication(opts.replicator_id)
        _exit_if_errors(errors)
        _success('XDCR replication paused')
    elif opts.resume:
        (_, errors) = self.rest.resume_xdcr_replication(opts.replicator_id)
        _exit_if_errors(errors)
        _success('XDCR replication resume')