diff mbox

[ovs-dev,v1] ovs python: add set type for from_python

Message ID 1468918779-32030-1-git-send-email-zealokii@gmail.com
State Superseded
Headers show

Commit Message

Zong Kai LI July 19, 2016, 8:59 a.m. UTC
In method from_python, when parameter 'value' is in list type or tuple
type, it will process per each element in 'value'. And indeed, it just
needs a iterable sequence here, no matter it's a list or tuple.
So set type should be considered too, it's also a basic, common iterable
sequence type from python.

Signed-off-by: Zong Kai LI <zealokii@gmail.com>
---
 python/ovs/db/data.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ryan Moats July 25, 2016, 12:58 p.m. UTC | #1
"dev" <dev-bounces@openvswitch.org> wrote on 07/19/2016 03:59:39 AM:

> From: Zong Kai LI <zealokii@gmail.com>
> To: dev@openvswitch.org
> Date: 07/19/2016 04:03 AM
> Subject: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type for
from_python
> Sent by: "dev" <dev-bounces@openvswitch.org>
>
> In method from_python, when parameter 'value' is in list type or tuple
> type, it will process per each element in 'value'. And indeed, it just
> needs a iterable sequence here, no matter it's a list or tuple.
> So set type should be considered too, it's also a basic, common iterable
> sequence type from python.
>
> Signed-off-by: Zong Kai LI <zealokii@gmail.com>

From Richard Theis <rtheis@us.ibm.com>:

  This patch is need to avoid the revert [1] in networking-ovn.  Without
  this patch or the revert, networking-ovn is experiencing the bug
  described in [2].

Acked-by: Richard Theis <rtheis@us.ibm.com>

[1] http://review.openstack.org/344078
[2] https://bugs.launchpad.net/networking-ovn/+bug/1605573

Ryan Moats
Richard Theis July 25, 2016, 1:47 p.m. UTC | #2
"dev" <dev-bounces@openvswitch.org> wrote on 07/25/2016 07:58:03 AM:

> From: Ryan Moats/Omaha/IBM@IBMUS
> To: Zong Kai LI <zealokii@gmail.com>
> Cc: dev@openvswitch.org
> Date: 07/25/2016 07:58 AM
> Subject: Re: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type 
> forfrom_python
> Sent by: "dev" <dev-bounces@openvswitch.org>
> 
> "dev" <dev-bounces@openvswitch.org> wrote on 07/19/2016 03:59:39 AM:
> 
> > From: Zong Kai LI <zealokii@gmail.com>
> > To: dev@openvswitch.org
> > Date: 07/19/2016 04:03 AM
> > Subject: [ovs-dev] [PATCH] [PATCH v1] ovs python: add set type for
> from_python
> > Sent by: "dev" <dev-bounces@openvswitch.org>
> >
> > In method from_python, when parameter 'value' is in list type or tuple
> > type, it will process per each element in 'value'. And indeed, it just
> > needs a iterable sequence here, no matter it's a list or tuple.
> > So set type should be considered too, it's also a basic, common 
iterable
> > sequence type from python.
> >
> > Signed-off-by: Zong Kai LI <zealokii@gmail.com>
> 
> From Richard Theis <rtheis@us.ibm.com>:
> 
>   This patch is need to avoid the revert [1] in networking-ovn.  Without
>   this patch or the revert, networking-ovn is experiencing the bug
>   described in [2].
> 
> Acked-by: Richard Theis <rtheis@us.ibm.com>
> 
> [1] http://review.openstack.org/344078
> [2] https://bugs.launchpad.net/networking-ovn/+bug/1605573
> 
> Ryan Moats

I ran the test reported in [2] to confirm the bug.  After applying the
revert [1], the reported bug was fixed.  That is, I was able to ssh 
between
my instances with the router setup described in [2].  I also confirmed 
that
the networks field was properly set for the logical router ports.  I then
removed the revert [1] and applied this patch.   This patch also worked.

Tested-by: Richard Theis <rtheis@us.ibm.com>
> 
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
index 747acd5..6d87f89 100644
--- a/python/ovs/db/data.py
+++ b/python/ovs/db/data.py
@@ -521,7 +521,7 @@  class Datum(object):
                 ka = Atom.from_python(type_.key, row_to_uuid(k))
                 va = Atom.from_python(type_.value, row_to_uuid(v))
                 d[ka] = va
-        elif isinstance(value, (list, tuple)):
+        elif isinstance(value, (list, set, tuple)):
             for k in value:
                 ka = Atom.from_python(type_.key, row_to_uuid(k))
                 d[ka] = None