+
+ # 1 - Filter connection_points (transform cp to a dictionary with no duplicates)
+ # This data will be returned even if no cp can be created if something is created
+ vlans = set()
+ work_cps = {}
+ for cp in connection_points:
+ switch_id = cp.get("service_endpoint_encapsulation_info").get("switch_dpid")
+ switch_port = cp.get("service_endpoint_encapsulation_info").get("switch_port")
+ service_endpoint_id = cp.get("service_endpoint_id")
+ vlans.add(cp.get("service_endpoint_encapsulation_info").get("vlan"))
+ cp_name = self.underlay_api.get_vpg_name(switch_id, switch_port)
+ add_cp = work_cps.get(cp_name)
+ if not add_cp:
+ # add cp to dict
+ service_endpoint_ids = []
+ service_endpoint_ids.append(service_endpoint_id)
+ add_cp = {"service_endpoint_ids": service_endpoint_ids,
+ "switch_dpid": switch_id,
+ "switch_port": switch_port}
+ work_cps[cp_name] = add_cp
+ else:
+ # add service_endpoint_id to list
+ service_endpoint_ids = add_cp["service_endpoint_ids"]
+ service_endpoint_ids.append(service_endpoint_id)
+
+ # check vlan
+ if len(vlans) == 1:
+ vlan = vlans.pop()
+ self.logger.debug("Provided vlan: {}".format(vlan))
+ else:
+ raise SdnConnectorError("Provided more than one vlan")