rest_qos: Avoid None when deleting OVSDB addr

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.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2017-10-31 14:28:39 +09:00 committed by FUJITA Tomonori
parent 253ce73b7f
commit 98d97b992e

View File

@ -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():