diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-10-31 14:28:39 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-11-01 23:21:11 +0900 |
commit | 98d97b992ef399c3ee1c508d0101bcdf941e31f0 (patch) | |
tree | 18b4690edacb1f14ec8322502fe406c1ac57a32a | |
parent | 253ce73b7f934f3a7e07f539d91e2201e2994d41 (diff) |
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>
-rw-r--r-- | ryu/app/rest_qos.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/ryu/app/rest_qos.py b/ryu/app/rest_qos.py index d17b0e1b..c5bac29a 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(): |