Arista SDN. Skip configuring repeated cps
[osm/RO.git] / RO-SDN-arista / osm_rosdn_arista / wimconn_arista.py
index b0e5b13..0b49cb0 100644 (file)
@@ -38,6 +38,7 @@ import difflib
 import logging
 import uuid
 from enum import Enum
+from requests import RequestException
 
 from cvprac.cvp_client import CvpClient
 from cvprac.cvp_client_errors import CvpLoginError,  CvpSessionLogOutError, CvpApiError
@@ -497,6 +498,8 @@ class AristaSdnConnector(SdnConnectorBase):
             Provide the parameter http_code
         """
         try:
+            self.logger.debug("invoked create_connectivity_service '{}' ports: {}".
+                              format(service_type, connection_points))
             self.__get_Connection()
             self.__check_service(service_type,
                                  connection_points,
@@ -558,6 +561,7 @@ class AristaSdnConnector(SdnConnectorBase):
             vlan_processed = False
             vlan_id = ''
             i = 0
+            processed_connection_points = []
             for cp in connection_points:
                 i += 1
                 encap_info = cp.get(self.__ENCAPSULATION_INFO_PARAM)
@@ -603,6 +607,12 @@ class AristaSdnConnector(SdnConnectorBase):
                     if not interface:
                         raise SdnConnectorError(message="Connection point switch port empty for switch_dpid {}".format(switch_id),
                                                 http_code=406)
+                # remove those connections that are equal. This happens when several sriovs are located in the same
+                # compute node interface, that is, in the same switch and interface
+                switches = [x for x in switches if x not in processed_connection_points]
+                if not switches:
+                    continue
+                processed_connection_points += switches
                 for switch in switches:
                     # it should be only one switch where the mac is attached
                     if encap_type == 'dot1q':
@@ -1200,7 +1210,8 @@ class AristaSdnConnector(SdnConnectorBase):
             SdnConnectorError: In case of error.
         """
         try:
-            self.logger.debug('invoked edit_connectivity_service for service {}'.format(service_uuid))
+            self.logger.debug('invoked edit_connectivity_service for service {}. ports: {}'.format(service_uuid,
+                                                                                                   connection_points))
 
             if not service_uuid:
                 raise SdnConnectorError(message='Unable to perform operation, missing or empty uuid',
@@ -1408,7 +1419,8 @@ class AristaSdnConnector(SdnConnectorBase):
             if self.client is None:
                 self.client = self.__connect()
             self.client.api.get_cvp_info()
-        except CvpSessionLogOutError:
+        except (CvpSessionLogOutError, RequestException) as e:
+            self.logger.debug("Connection error '{}'. Reconnencting".format(e))
             self.client = self.__connect()
             self.client.api.get_cvp_info()