+ def net_update_ofc_thread(self, net_id, ofc_id=None):
+ """
+ Insert a update net task by net id or ofc_id for each ofc thread
+ :param net_id: network id
+ :param ofc_id: openflow controller id
+ :return:
+ """
+ if not net_id:
+ raise ovimException("No net_id received", HTTP_Internal_Server_Error)
+
+ switch_dpid = None
+ r = -1
+ c = 'No valid ofc_id or switch_dpid received'
+
+ if not ofc_id:
+ ports = self.get_ports(filter={"net_id": net_id})
+ for port in ports:
+ port_ofc_id = port.get('ofc_id', None)
+ if port_ofc_id:
+ ofc_id = port['ofc_id']
+ switch_dpid = port['switch_dpid']
+ break
+
+ # If no ofc_id found it, default ofc_id is used.
+ if not ofc_id and not switch_dpid:
+ ofc_id = "Default"
+
+ if ofc_id and ofc_id in self.config['ofcs_thread']:
+ r, c = self.config['ofcs_thread'][ofc_id].insert_task("update-net", net_id)
+ elif switch_dpid:
+
+ ofcs_dpid_list = self.config['ofcs_thread_dpid']
+ for ofc_t in ofcs_dpid_list:
+ if switch_dpid in ofc_t:
+ r, c = ofc_t[switch_dpid].insert_task("update-net", net_id)
+
+ if r < 0:
+ message = "Cannot insert a task for updating network '{}', {}".format(net_id, c)
+ self.logger.error(message)
+ raise ovimException(message, HTTP_Internal_Server_Error)
+