projects
/
osm
/
RO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug 1149 1150: improve exceptions error message
[osm/RO.git]
/
RO-SDN-arista_cloudvision
/
osm_rosdn_arista_cloudvision
/
wimconn_arista.py
diff --git
a/RO-SDN-arista_cloudvision/osm_rosdn_arista_cloudvision/wimconn_arista.py
b/RO-SDN-arista_cloudvision/osm_rosdn_arista_cloudvision/wimconn_arista.py
index
4708a7c
..
01c8682
100644
(file)
--- a/
RO-SDN-arista_cloudvision/osm_rosdn_arista_cloudvision/wimconn_arista.py
+++ b/
RO-SDN-arista_cloudvision/osm_rosdn_arista_cloudvision/wimconn_arista.py
@@
-38,8
+38,7
@@
import difflib
import logging
import uuid
from enum import Enum
import logging
import uuid
from enum import Enum
-from requests import RequestException
-
+from requests import RequestException, ConnectionError, ConnectTimeout, Timeout
from cvprac.cvp_client import CvpClient
from cvprac.cvp_api import CvpApi
from cvprac.cvp_client_errors import CvpLoginError, CvpSessionLogOutError, CvpApiError
from cvprac.cvp_client import CvpClient
from cvprac.cvp_api import CvpApi
from cvprac.cvp_client_errors import CvpLoginError, CvpSessionLogOutError, CvpApiError
@@
-50,15
+49,16
@@
from osm_rosdn_arista_cloudvision.aristaTask import AristaCVPTask
class SdnError(Enum):
class SdnError(Enum):
- UNREACHABLE = 'Unable to reach the WIM.',
+ UNREACHABLE = 'Unable to reach the WIM url, connect error.',
+ TIMEOUT = 'Unable to reach the WIM url, timeout.',
VLAN_INCONSISTENT = \
'VLAN value inconsistent between the connection points',
VLAN_NOT_PROVIDED = 'VLAN value not provided',
CONNECTION_POINTS_SIZE = \
'Unexpected number of connection points: 2 expected.',
ENCAPSULATION_TYPE = \
VLAN_INCONSISTENT = \
'VLAN value inconsistent between the connection points',
VLAN_NOT_PROVIDED = 'VLAN value not provided',
CONNECTION_POINTS_SIZE = \
'Unexpected number of connection points: 2 expected.',
ENCAPSULATION_TYPE = \
- 'Unexpected service_endpoint_encapsulation_type. \
-
Only "dotq1" is accepted.',
+ 'Unexpected service_endpoint_encapsulation_type.
'
\
+
'
Only "dotq1" is accepted.',
BANDWIDTH = 'Unable to get the bandwidth.',
STATUS = 'Unable to get the status for the service.',
DELETE = 'Unable to delete service.',
BANDWIDTH = 'Unable to get the bandwidth.',
STATUS = 'Unable to get the status for the service.',
DELETE = 'Unable to delete service.',
@@
-188,10
+188,16
@@
class AristaSdnConnector(SdnConnectorBase):
try:
self.__load_topology()
self.__load_switches()
try:
self.__load_topology()
self.__load_switches()
+ except (ConnectTimeout, Timeout) as ct:
+ raise SdnConnectorError(message=SdnError.TIMEOUT + " " + str(ct), http_code=408)
+ except ConnectionError as ce:
+ raise SdnConnectorError(message=SdnError.UNREACHABLE + " " + str(ce), http_code=404)
except SdnConnectorError as sc:
raise sc
except SdnConnectorError as sc:
raise sc
+ except CvpLoginError as le:
+ raise SdnConnectorError(message=le.msg, http_code=500) from le
except Exception as e:
except Exception as e:
- raise SdnConnectorError(message="Unable to load switches from CVP",
+ raise SdnConnectorError(message="Unable to load switches from CVP"
+ " " + str(e)
,
http_code=500) from e
self.logger.debug("Using topology {} in Arista Leaf switches: {}".format(
self.topology,
http_code=500) from e
self.logger.debug("Using topology {} in Arista Leaf switches: {}".format(
self.topology,
@@
-354,12
+360,12
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except Exception as ex:
self.client = None
self.logger.error(str(ex))
http_code=401) from e
except Exception as ex:
self.client = None
self.logger.error(str(ex))
- raise SdnConnectorError(message=SdnError.INTERNAL_ERROR,
+ raise SdnConnectorError(message=SdnError.INTERNAL_ERROR
+ " " + str(ex)
,
http_code=500) from ex
def get_connectivity_service_status(self, service_uuid, conn_info=None):
http_code=500) from ex
def get_connectivity_service_status(self, service_uuid, conn_info=None):
@@
-463,12
+469,12
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except Exception as ex:
self.client = None
self.logger.error(str(ex), exc_info=True)
http_code=401) from e
except Exception as ex:
self.client = None
self.logger.error(str(ex), exc_info=True)
- raise SdnConnectorError(message=str(ex),
+ raise SdnConnectorError(message=str(ex)
+ " " + str(ex)
,
http_code=500) from ex
def create_connectivity_service(self, service_type, connection_points,
http_code=500) from ex
def create_connectivity_service(self, service_type, connection_points,
@@
-547,7
+553,7
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except SdnConnectorError as sde:
raise sde
http_code=401) from e
except SdnConnectorError as sde:
raise sde
@@
-737,7
+743,7
@@
class AristaSdnConnector(SdnConnectorBase):
if not (cls_perSw.get(s) and cls_perSw[s][0].get('config')):
# when there is no configuration, means that there is no interface
# in the switch to be connected, so the configLet has to be removed from CloudVision
if not (cls_perSw.get(s) and cls_perSw[s][0].get('config')):
# when there is no configuration, means that there is no interface
# in the switch to be connected, so the configLet has to be removed from CloudVision
- # after removing the ConfigLet fro
n
the switch if it was already there
+ # after removing the ConfigLet fro
m
the switch if it was already there
# get config let name and key
cl = cls_perSw[s]
# get config let name and key
cl = cls_perSw[s]
@@
-1141,7
+1147,7
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except SdnConnectorError as sde:
raise sde
http_code=401) from e
except SdnConnectorError as sde:
raise sde
@@
-1150,7
+1156,7
@@
class AristaSdnConnector(SdnConnectorBase):
self.logger.error(ex)
if self.raiseException:
raise ex
self.logger.error(ex)
if self.raiseException:
raise ex
- raise SdnConnectorError(message=SdnError.INTERNAL_ERROR,
+ raise SdnConnectorError(message=SdnError.INTERNAL_ERROR
+ " " + str(ex)
,
http_code=500) from ex
def __addMetadata(self, service_uuid, service_type, vlan_id):
http_code=500) from ex
def __addMetadata(self, service_uuid, service_type, vlan_id):
@@
-1269,7
+1275,7
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except SdnConnectorError as sde:
raise sde
http_code=401) from e
except SdnConnectorError as sde:
raise sde
@@
-1305,7
+1311,7
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except SdnConnectorError as sde:
raise sde
http_code=401) from e
except SdnConnectorError as sde:
raise sde
@@
-1314,7
+1320,7
@@
class AristaSdnConnector(SdnConnectorBase):
self.logger.error(ex)
if self.raiseException:
raise ex
self.logger.error(ex)
if self.raiseException:
raise ex
- raise SdnConnectorError(message=SdnError.INTERNAL_ERROR,
+ raise SdnConnectorError(message=SdnError.INTERNAL_ERROR
+ " " + str(ex)
,
http_code=500) from ex
def get_all_active_connectivity_services(self):
http_code=500) from ex
def get_all_active_connectivity_services(self):
@@
-1340,7
+1346,7
@@
class AristaSdnConnector(SdnConnectorBase):
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
except CvpLoginError as e:
self.logger.info(str(e))
self.client = None
- raise SdnConnectorError(message=SdnError.UNAUTHORIZED,
+ raise SdnConnectorError(message=SdnError.UNAUTHORIZED
+ " " + str(e)
,
http_code=401) from e
except SdnConnectorError as sde:
raise sde
http_code=401) from e
except SdnConnectorError as sde:
raise sde