From patchwork Thu Jul 21 10:21:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 651140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rw8vm0Y7yz9sdg for ; Thu, 21 Jul 2016 20:21:39 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7C6C61076F; Thu, 21 Jul 2016 03:21:37 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id A729F1076E for ; Thu, 21 Jul 2016 03:21:35 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 2CE161621D9 for ; Thu, 21 Jul 2016 04:21:35 -0600 (MDT) X-ASG-Debug-ID: 1469096493-0b3237452c1823e0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id RB6TBOGmhkEpkl0r (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 21 Jul 2016 04:21:33 -0600 (MDT) X-Barracuda-Envelope-From: nusiddiq@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 21 Jul 2016 10:21:32 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3313461A11 for ; Thu, 21 Jul 2016 10:21:31 +0000 (UTC) Received: from nusiddiq.blr.redhat.com (dhcp-0-65.blr.redhat.com [10.70.1.65]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6LALT1c019899 for ; Thu, 21 Jul 2016 06:21:30 -0400 X-CudaMail-Envelope-Sender: nusiddiq@redhat.com From: Numan Siddique X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-720004430 X-CudaMail-DTE: 072116 X-CudaMail-Originating-IP: 209.132.183.28 To: "dev >> ovs dev" X-ASG-Orig-Subj: [##CM-E1-720004430##][PATCH] python: Send old values of the updated cols in notify for update2 Organization: Red Hat Message-ID: Date: Thu, 21 Jul 2016 15:51:29 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Jul 2016 10:21:31 +0000 (UTC) X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1469096493 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH] python: Send old values of the updated cols in notify for update2 X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" When python IDL calls the "notify" function after processing the "update2" message from ovsdb-server, it is suppose to send the old values of the updated columns as the last parameter. But the recent commit "897c8064" sends the updated values. This breaks the behaviour. This patch fixes this issue. It also updates the description of the 'updates' param of the notify function to make it more clear. Fixes: 897c8064 ("python: move Python idl to work with monitor_cond") Signed-off-by: Numan Siddique --- python/ovs/db/idl.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 437e9b0..92a7382 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -333,7 +333,8 @@ class Idl(object): :type event: ROW_CREATE, ROW_UPDATE, or ROW_DELETE :param row: The row as it is after the operation has occured :type row: Row - :param updates: For updates, row with only updated columns + :param updates: For updates, row with only old values of the changed + columns :type updates: Row """ @@ -511,9 +512,10 @@ class Idl(object): if not row: raise error.Error('Modify non-existing row') - self.__apply_diff(table, row, row_update['modify']) + old_row_diff_json = self.__apply_diff(table, row, + row_update['modify']) self.notify(ROW_UPDATE, row, - Row.from_json(self, table, uuid, row_update['modify'])) + Row.from_json(self, table, uuid, old_row_diff_json)) changed = True else: raise error.Error(' unknown operation', @@ -576,7 +578,8 @@ class Idl(object): row_update[column.name] = self.__column_name(column) def __apply_diff(self, table, row, row_diff): - for column_name, datum_json in six.iteritems(row_diff): + old_row_diff_json = {} + for column_name, datum_diff_json in six.iteritems(row_diff): column = table.columns.get(column_name) if not column: # XXX rate-limit @@ -585,17 +588,21 @@ class Idl(object): continue try: - datum = ovs.db.data.Datum.from_json(column.type, datum_json) + datum_diff = ovs.db.data.Datum.from_json(column.type, + datum_diff_json) except error.Error as e: # XXX rate-limit vlog.warn("error parsing column %s in table %s: %s" % (column_name, table.name, e)) continue - datum = row._data[column_name].diff(datum) + old_row_diff_json[column_name] = row._data[column_name].to_json() + datum = row._data[column_name].diff(datum_diff) if datum != row._data[column_name]: row._data[column_name] = datum + return old_row_diff_json + def __row_update(self, table, row, row_json): changed = False for column_name, datum_json in six.iteritems(row_json):