'Send replication update
Send replication update to the target appliance and then wait for
it to complete.'

def send_repl_update(self, action_id):

    svc = ('/api/storage/v1/replication/actions/%s/sendupdate' % action_id)
    ret = self.rclient.put(svc)
    if (ret.status != restclient.Status.ACCEPTED):
        exception_msg = (_('Error    sending    replication    update    for    action    id:    %(id)s    .    Return    code:    %(ret.status)d    Message:    %(ret.data)s    .') % {'id': action_id, 'ret.status': ret.status, 'ret.data': ret.data})
        LOG.error(exception_msg)
        raise exception.VolumeBackendAPIException(data=exception_msg)
    def _loop_func():
        svc = ('/api/storage/v1/replication/actions/%s' % action_id)
        ret = self.rclient.get(svc)
        if (ret.status != restclient.Status.OK):
            exception_msg = (_('Error    getting    replication    action:    %(id)s.    Return    code:    %(ret.status)d    Message:    %(ret.data)s    .') % {'id': action_id, 'ret.status': ret.status, 'ret.data': ret.data})
            LOG.error(exception_msg)
            raise exception.VolumeBackendAPIException(data=exception_msg)
        val = json.loads(ret.data)
        if (val['action']['last_result'] == 'success'):
            raise loopingcall.LoopingCallDone()
        elif ((val['action']['last_result'] == '<unknown>') and (val['action']['state'] == 'sending')):
            pass
        else:
            exception_msg = (_('Error    sending    replication    update.    Returned    error:    %(err)s.    Action:    %(id)s.') % {'err': val['action']['last_result'], 'id': action_id})
            LOG.error(exception_msg)
            raise exception.VolumeBackendAPIException(data=exception_msg)
    timer = loopingcall.FixedIntervalLoopingCall(_loop_func)
    timer.start(interval=5).wait()
