Hi,
On 2017年05月16日 10:49, 胡鼎原 wrote:
> Line 373: _uuid = controller_info.get('uuid', uuid.uuid4())
> AttributeError: 'NoneType' object has no attribute 'get'
> ---
> ryu/services/protocols/ovsdb/api.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ryu/services/protocols/ovsdb/api.py
> b/ryu/services/protocols/ovsdb/api.py
> index c1f04398..49cd6849 100644
> --- a/ryu/services/protocols/ovsdb/api.py
> +++ b/ryu/services/protocols/ovsdb/api.py
> @@ -363,7 +363,7 @@ def del_port_by_name(manager, system_id,
> bridge_name, port_name):
>
>
> def set_controller(manager, system_id, bridge_name,
> - target, controller_info=None):
> + target, controller_info=dict()):
IIRC, the default value should be immutable, and should not be dict, list or so.
e.g.,)
>>> def func(arg=dict()):
... print(arg)
... arg['foo'] = 'bar'
...
>>> func()
{}
>>> func()
{'foo': 'bar'} # <--- The previous value still exists!
The above snippet should be fixed like;
>>> def func(arg=None):
... arg = arg or {}
... print(arg)
... arg['foo'] = 'bar'
...
>>>
>>> func()
{}
>>> func()
{} # <--- Safer!
> def _set_controller(tables, insert):
> bridge = _get_bridge(tables, bridge_name)
>
In this case, how about the following?
$ git diff
diff --git a/ryu/services/protocols/ovsdb/api.py
b/ryu/services/protocols/ovsdb/api.py
index c1f0439..f0c91c6 100644
--- a/ryu/services/protocols/ovsdb/api.py
+++ b/ryu/services/protocols/ovsdb/api.py
@@ -364,6 +364,7 @@ def del_port_by_name(manager, system_id, bridge_name,
port_name):
def set_controller(manager, system_id, bridge_name,
target, controller_info=None):
+ controller_info = controller_info or {}
def _set_controller(tables, insert):
bridge = _get_bridge(tables, bridge_name)
Thanks,
Iwase
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel