X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=blobdiff_plain;f=RO%2Fosm_ro%2Fvim_thread.py;h=587c0600c899d8f497e66beaf8fcb1f78f7a1306;hp=728b659b6aec2456d355bc4398b5b23ee6f90867;hb=4126d05e24ada55226bb13a9d556655811cedadc;hpb=ed3e4d4fc2819e425bb8b165e43fcbac259d3f1b diff --git a/RO/osm_ro/vim_thread.py b/RO/osm_ro/vim_thread.py index 728b659b..587c0600 100644 --- a/RO/osm_ro/vim_thread.py +++ b/RO/osm_ro/vim_thread.py @@ -606,9 +606,10 @@ class vim_thread(threading.Thread): elif not self.vim and not self.sdnconnector: task["status"] = "FAILED" task["error_msg"] = self.error_status - database_update = {"status": "VIM_ERROR", "error_msg": task["error_msg"]} + database_update = {"status": "VIM_ERROR" if self.datacenter_tenant_id else "WIM_ERROR", + "error_msg": task["error_msg"]} elif task["item_id"] != related_tasks[0]["item_id"] and task["action"] in ("FIND", "CREATE"): - # Do nothing, just copy values from one to another and updata database + # Do nothing, just copy values from one to another and update database task["status"] = related_tasks[0]["status"] task["error_msg"] = related_tasks[0]["error_msg"] task["vim_id"] = related_tasks[0]["vim_id"] @@ -712,7 +713,7 @@ class vim_thread(threading.Thread): next_refresh = time.time() if task["extra"].get("vim_status") == "BUILD": next_refresh += self.REFRESH_BUILD - elif task["extra"].get("vim_status") in ("ERROR", "VIM_ERROR"): + elif task["extra"].get("vim_status") in ("ERROR", "VIM_ERROR", "WIM_ERROR"): next_refresh += self.REFRESH_ERROR elif task["extra"].get("vim_status") == "DELETED": next_refresh += self.REFRESH_DELETE @@ -1006,13 +1007,14 @@ class vim_thread(threading.Thread): # CREATE params = task["params"] action_text = "creating VIM" - vim_net_id, created_items = self.vim.new_network(*params[0:3]) + + vim_net_id, created_items = self.vim.new_network(*params[0:5]) # net_name = params[0] # net_type = params[1] # wim_account_name = None - # if len(params) >= 4: - # wim_account_name = params[3] + # if len(params) >= 6: + # wim_account_name = params[5] # TODO fix at nfvo adding external port # if wim_account_name and self.vim.config["wim_external_ports"]: @@ -1193,7 +1195,7 @@ class vim_thread(threading.Thread): task["status"] = "DONE" task["extra"]["vim_info"] = {} # task["extra"]["sdn_net_id"] = sdn_net_id - task["extra"]["vim_status"] = "BUILD" + task["extra"]["vim_status"] = sdn_status task["extra"]["created"] = True task["extra"]["created_items"] = created_items task["extra"]["connected_ports"] = connected_ports @@ -1368,12 +1370,27 @@ class vim_thread(threading.Thread): task_id = task["instance_action_id"] + "." + str(task["task_index"]) dep_id = "TASK-" + str(task["extra"]["depends_on"][0]) error_text = "" - interfaces = task.get("depends").get(dep_id).get("extra").get("interfaces").keys() + interfaces = task.get("depends").get(dep_id).get("extra").get("interfaces") # Bear in mind that different VIM connectors might support Classifications differently. # In the case of OpenStack, only the first VNF attached to the classifier will be used # to create the Classification(s) (the "logical source port" of the "Flow Classifier"). # Since the VNFFG classifier match lacks the ethertype, classification defaults to # using the IPv4 flow classifier. + logical_source_port_vim_id = None + logical_source_port_id = params.get("logical_source_port") + for vim_interface, interface_data in interfaces.items(): + if interface_data.get("interface_id") == logical_source_port_id: + logical_source_port_vim_id = vim_interface + break + if not logical_source_port_vim_id: + error_text = "Error creating Flow Classifier, Logical Source Port id {}".format( + logical_source_port_id) + self.logger.error(error_text) + task["error_msg"] = error_text + task["status"] = "FAILED" + task["vim_id"] = None + return None + name = "c-{}".format(task["item_id"][:8]) # if not CIDR is given for the IP addresses, add /32: ip_proto = int(params.get("ip_proto")) @@ -1381,7 +1398,7 @@ class vim_thread(threading.Thread): destination_ip = params.get("destination_ip") source_port = params.get("source_port") destination_port = params.get("destination_port") - definition = {"logical_source_port": interfaces[0]} + definition = {"logical_source_port": logical_source_port_vim_id} if ip_proto: if ip_proto == 1: ip_proto = 'icmp'