Capture more exceptions for SDN floodlight plugin 34/6334/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 13 Jul 2018 13:11:44 +0000 (15:11 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 13 Jul 2018 13:11:44 +0000 (15:11 +0200)
Change-Id: Ib3f7f51e9b963d1f07205c3297511b1dd450d6ab
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_openvim/floodlight.py
osm_openvim/ovim.py

index 826e300..810572b 100644 (file)
@@ -137,8 +137,8 @@ class OF_conn(openflow_conn.OpenflowConn):
             if self.version == None:
                 if 'dpid' in info[0] and 'inetAddress' in info[0]:
                     self._set_version("0.9")
-                elif 'switchDPID' in info[0] and 'inetAddress' in info[0]:
-                    self._set_version("1.X")
+                elif 'switchDPID' in info[0] and 'inetAddress' in info[0]:
+                    self._set_version("1.X")
                 else:
                     self.logger.error(
                         "get_of_switches. Unexpected response, not found 'dpid' or 'switchDPID' field: %s",
@@ -154,7 +154,7 @@ class OF_conn(openflow_conn.OpenflowConn):
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("get_of_switches " + error_text)
             raise openflow_conn.OpenflowconnConnectionException(error_text)
-        except ValueError as e:
+        except Exception as e:
             # ValueError in the case that JSON can not be decoded
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("get_of_switches " + error_text)
@@ -267,7 +267,7 @@ class OF_conn(openflow_conn.OpenflowConn):
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("get_of_rules " + error_text)
             raise openflow_conn.OpenflowconnConnectionException(error_text)
-        except ValueError as e:
+        except Exception as e:
             # ValueError in the case that JSON can not be decoded
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("get_of_rules " + error_text)
@@ -345,7 +345,7 @@ class OF_conn(openflow_conn.OpenflowConn):
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("obtain_port_correspondence " + error_text)
             raise openflow_conn.OpenflowconnConnectionException(error_text)
-        except ValueError as e:
+        except Exception as e:
             # ValueError in the case that JSON can not be decoded
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("obtain_port_correspondence " + error_text)
@@ -381,6 +381,11 @@ class OF_conn(openflow_conn.OpenflowConn):
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("del_flow " + error_text)
             raise openflow_conn.OpenflowconnConnectionException(error_text)
+        except Exception as e:
+            # ValueError in the case that JSON can not be decoded
+            error_text = type(e).__name__ + ": " + str(e)
+            self.logger.error("del_flow " + error_text)
+            raise openflow_conn.OpenflowconnUnexpectedResponse(error_text)
 
     def new_flow(self, data):
         """
@@ -443,6 +448,11 @@ class OF_conn(openflow_conn.OpenflowConn):
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("new_flow " + error_text)
             raise openflow_conn.OpenflowconnConnectionException(error_text)
+        except Exception as e:
+            # ValueError in the case that JSON can not be decoded
+            error_text = type(e).__name__ + ": " + str(e)
+            self.logger.error("new_flow " + error_text)
+            raise openflow_conn.OpenflowconnUnexpectedResponse(error_text)
 
     def clear_all_flows(self):
         """
@@ -470,4 +480,8 @@ class OF_conn(openflow_conn.OpenflowConn):
             error_text = type(e).__name__ + ": " + str(e)
             self.logger.error("clear_all_flows " + error_text)
             raise openflow_conn.OpenflowconnConnectionException(error_text)
-
+        except Exception as e:
+            # ValueError in the case that JSON can not be decoded
+            error_text = type(e).__name__ + ": " + str(e)
+            self.logger.error("clear_all_flows " + error_text)
+            raise openflow_conn.OpenflowconnUnexpectedResponse(error_text)
index 6b95456..9cfecca 100755 (executable)
@@ -43,7 +43,7 @@ import openflow_conn
 
 __author__ = "Alfonso Tierno, Leonardo Mirabal"
 __date__ = "$06-Feb-2017 12:07:15$"
-__version__ = "0.5.25-r545"
+__version__ = "0.5.26-r546"
 version_date = "Jul 2018"
 database_version = 23      #needed database schema version