VCD feature 7193-provider_nerwork
[osm/RO.git] / osm_ro / vim_thread.py
index ffe721c..733dfc2 100644 (file)
@@ -576,7 +576,7 @@ class vim_thread(threading.Thread):
                 task["error_msg"] = related_tasks[0]["error_msg"]
                 task["vim_id"] = related_tasks[0]["vim_id"]
                 extra = yaml.load(related_tasks[0]["extra"])
-                task["extra"]["vim_status"] = extra["vim_status"]
+                task["extra"]["vim_status"] = extra.get("vim_status")
                 next_refresh = related_tasks[0]["modified_at"] + 0.001
                 database_update = {"status": task["extra"].get("vim_status", "VIM_ERROR"),
                                    "error_msg": task["error_msg"]}
@@ -958,13 +958,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) >= 5:
+                wim_account_name = params[5]
 
             sdn_controller = self.vim.config.get('sdn-controller')
             if sdn_controller and (net_type == "data" or net_type == "ptp"):
@@ -983,8 +984,7 @@ class vim_thread(threading.Thread):
                 if wim_account_name and self.vim.config["wim_external_ports"]:
                     # add external port to connect WIM. Try with compute node __WIM:wim_name and __WIM
                     action_text = "attaching external port to ovim network"
-                    sdn_port_name = sdn_net_id + "." + task["vim_id"]
-                    sdn_port_name = sdn_port_name[:63]
+                    sdn_port_name = "external_port"
                     sdn_port_data = {
                         "compute_node": "__WIM:" + wim_account_name[0:58],
                         "pci": None,
@@ -1027,6 +1027,8 @@ class vim_thread(threading.Thread):
         net_vim_id = task["vim_id"]
         sdn_net_id = task["extra"].get("sdn_net_id")
         try:
+            if net_vim_id:
+                self.vim.delete_network(net_vim_id, task["extra"].get("created_items"))
             if sdn_net_id:
                 # Delete any attached port to this sdn network. There can be ports associated to this network in case
                 # it was manually done using 'openmano vim-net-sdn-attach'
@@ -1036,8 +1038,6 @@ class vim_thread(threading.Thread):
                     for port in port_list:
                         self.ovim.delete_port(port['uuid'], idempotent=True)
                     self.ovim.delete_network(sdn_net_id, idempotent=True)
-            if net_vim_id:
-                self.vim.delete_network(net_vim_id, task["extra"].get("created_items"))
             task["status"] = "FINISHED"  # with FINISHED instead of DONE it will not be refreshing
             task["error_msg"] = None
             return None