+ return encapsulation
+
+ def edit_connectivity_service(self, service_uuid, conn_info = None, connection_points = None, **kwargs):
+ self.logger.debug("edit connectivity service, service_uuid: {}, conn_info: {}, "
+ "connection points: {} ".format(service_uuid, conn_info, connection_points))
+
+ conn_info = conn_info or []
+ # Obtain current configuration
+ onos_config_orig = self._get_onos_netconfig()
+ onos_config = copy.deepcopy(onos_config_orig)
+
+ # get current service data and check if it does not exists
+ for vpls in onos_config.get('apps', {}).get('org.onosproject.vpls', {}).get('vpls', {}).get('vplsList', {}):
+ if vpls['name'] == service_uuid:
+ self.logger.debug("service exists")
+ curr_interfaces = vpls.get("interfaces", [])
+ curr_encapsulation = vpls.get("encapsulation")
+ break
+ else:
+ raise SdnConnectorError("service uuid: {} does not exist".format(service_uuid))
+
+ self.logger.debug("current interfaces: {}".format(curr_interfaces))
+ self.logger.debug("current encapsulation: {}".format(curr_encapsulation))
+
+ # new interfaces names
+ new_interfaces = [port['service_endpoint_id'] for port in new_connection_points]
+
+ # obtain interfaces to delete, list will contain port
+ ifs_delete = list(set(curr_interfaces) - set(new_interfaces))
+ ifs_add = list(set(new_interfaces) - set(curr_interfaces))
+ self.logger.debug("interfaces to delete: {}".format(ifs_delete))
+ self.logger.debug("interfaces to add: {}".format(ifs_add))
+
+ # check if some data of the interfaces that already existed has changed
+ # in that case delete it and add it again
+ ifs_remain = list(set(new_interfaces) & set(curr_interfaces))
+ for port in connection_points:
+ if port['service_endpoint_id'] in ifs_remain:
+ # check if there are some changes
+ curr_port_name, curr_vlan = self._get_current_port_data(onos_config, port['service_endpoint_id'])
+ new_port_name = 'of:{}/{}'.format(port['service_endpoint_encapsulation_info']['switch_dpid'],
+ port['service_endpoint_encapsulation_info']['switch_port'])
+ new_vlan = port['service_endpoint_encapsulation_info']['vlan']
+ if (curr_port_name != new_port_name or curr_vlan != new_vlan):
+ self.logger.debug("TODO: must update data interface: {}".format(port['service_endpoint_id']))
+ ifs_delete.append(port['service_endpoint_id'])
+ ifs_add.append(port['service_endpoint_id'])
+
+ new_encapsulation = self._get_encapsulation(connection_points)
+
+ try:
+ # Delete interfaces, only will delete interfaces that are in provided conn_info
+ # because these are the ones that have been created for this service
+ if ifs_delete:
+ for port in onos_config['ports'].values():
+ for port_interface in port['interfaces']:
+ interface_name = port_interface['name']
+ self.logger.debug("interface name: {}".format(port_interface['name']))
+ if interface_name in ifs_delete and interface_name in conn_info:
+ self.logger.debug("delete interface name: {}".format(interface_name))
+ port['interfaces'].remove(port_interface)
+ conn_info.remove(interface_name)
+
+ # Add new interfaces
+ for port in connection_points:
+ if port['service_endpoint_id'] in ifs_add:
+ created_ifz = self._append_port_to_onos_config(port, onos_config)
+ if created_ifz:
+ conn_info.append(created_ifz[1])
+ self._pop_last_update_time(onos_config)
+ self._post_onos_netconfig(onos_config)
+
+ self.logger.debug("onos config after updating interfaces: {}".format(onos_config))
+ self.logger.debug("conn_info after updating interfaces: {}".format(conn_info))
+
+ # Update interfaces list in vpls service
+ for vpls in onos_config.get('apps', {}).get('org.onosproject.vpls', {}).get('vpls', {}).get('vplsList', {}):