Currently, rest_qos.py will raise AttributeError when deleting OVSDB
server address because rest_qos.py will try to split the given address
string but the address is None when deleting.

This patch checks if the given address is None or not before the string
manipulation and fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com>
---
 ryu/app/rest_qos.py | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/ryu/app/rest_qos.py b/ryu/app/rest_qos.py
index d17b0e1..c5bac29 100644
--- a/ryu/app/rest_qos.py
+++ b/ryu/app/rest_qos.py
@@ -425,7 +425,8 @@ class QoSController(ControllerBase):
     @staticmethod
     def delete_ovsdb_addr(dpid):
         ofs = QoSController._OFS_LIST.get(dpid, None)
-        ofs.set_ovsdb_addr(dpid, None)
+        if ofs is not None:
+            ofs.set_ovsdb_addr(dpid, None)
 
     @route('qos_switch', BASE_URL + '/queue/{switchid}',
            methods=['GET'], requirements=REQUIREMENTS)
@@ -600,25 +601,22 @@ class QoS(object):
         self.ofctl.mod_flow_entry(self.dp, flow, cmd)
 
     def set_ovsdb_addr(self, dpid, ovsdb_addr):
-        # easy check if the address format valid
-        _proto, _host, _port = ovsdb_addr.split(':')
-
         old_address = self.ovsdb_addr
         if old_address == ovsdb_addr:
             return
-        if ovsdb_addr is None:
+        elif ovsdb_addr is None:
+            # Determine deleting OVSDB address was requested.
             if self.ovs_bridge:
-                self.ovs_bridge.del_controller()
                 self.ovs_bridge = None
             return
+
+        ovs_bridge = bridge.OVSBridge(self.CONF, dpid, ovsdb_addr)
+        try:
+            ovs_bridge.init()
+        except:
+            raise ValueError('ovsdb addr is not available.')
         self.ovsdb_addr = ovsdb_addr
-        if self.ovs_bridge is None:
-            ovs_bridge = bridge.OVSBridge(self.CONF, dpid, ovsdb_addr)
-            self.ovs_bridge = ovs_bridge
-            try:
-                ovs_bridge.init()
-            except:
-                raise ValueError('ovsdb addr is not available.')
+        self.ovs_bridge = ovs_bridge
 
     def _update_vlan_list(self, vlan_list):
         for vlan_id in self.vlan_list.keys():
-- 
2.7.4


------------------------------------------------------------------------------
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
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to