'Waits till a clone operation is complete or errored out.'

def _wait_for_clone_finish(self, clone_op_id, vol_uuid):

    clone_ls_st = netapp_api.NaElement('clone-list-status')
    clone_id = netapp_api.NaElement('clone-id')
    clone_ls_st.add_child_elem(clone_id)
    clone_id.add_node_with_children('clone-id-info', **{'clone-op-id': clone_op_id, 'volume-uuid': vol_uuid})
    task_running = True
    while task_running:
        result = self.connection.invoke_successfully(clone_ls_st, enable_tunneling=True)
        status = result.get_child_by_name('status')
        ops_info = status.get_children()
        if ops_info:
            state = ops_info[0].get_child_content('clone-state')
            if (state == 'completed'):
                task_running = False
            elif (state == 'failed'):
                code = ops_info[0].get_child_content('error')
                reason = ops_info[0].get_child_content('reason')
                raise netapp_api.NaApiError(code, reason)
            else:
                time.sleep(1)
        else:
            raise netapp_api.NaApiError('UnknownCloneId', ('No    clone    operation    for    clone    id    %s    found    on    the    filer' % clone_id))
