Bug 2316: Fix for Unable to do vertical scaling when VM is in Shutdown state
[osm/RO.git] / NG-RO / osm_ng_ro / ns_thread.py
index bca21e0..08edcd1 100644 (file)
@@ -285,9 +285,11 @@ class VimInteractionNet(VimInteractionBase):
                     ro_task["target_id"],
                     vim_id,
                     ro_vim_item_update.get("vim_status"),
-                    ro_vim_item_update.get("vim_message")
-                    if ro_vim_item_update.get("vim_status") != "ACTIVE"
-                    else "",
+                    (
+                        ro_vim_item_update.get("vim_message")
+                        if ro_vim_item_update.get("vim_status") != "ACTIVE"
+                        else ""
+                    ),
                 )
             )
 
@@ -969,9 +971,11 @@ class VimInteractionVdu(VimInteractionBase):
                     ro_task["target_id"],
                     vim_id,
                     ro_vim_item_update.get("vim_status"),
-                    ro_vim_item_update.get("vim_message")
-                    if ro_vim_item_update.get("vim_status") != "ACTIVE"
-                    else "",
+                    (
+                        ro_vim_item_update.get("vim_message")
+                        if ro_vim_item_update.get("vim_status") != "ACTIVE"
+                        else ""
+                    ),
                 )
             )
 
@@ -1400,8 +1404,6 @@ class VimInteractionUpdateVdu(VimInteractionBase):
         task = ro_task["tasks"][task_index]
         task_id = task["task_id"]
         db_task_update = {"retries": 0}
-        created = False
-        created_items = {}
         target_vim = self.my_vims[ro_task["target_id"]]
 
         try:
@@ -1415,10 +1417,6 @@ class VimInteractionUpdateVdu(VimInteractionBase):
             ro_vim_item_update = {
                 "vim_id": vim_vm_id,
                 "vim_status": "ACTIVE",
-                "created": created,
-                "created_items": created_items,
-                "vim_details": None,
-                "vim_message": None,
             }
             self.logger.debug(
                 "task={} {} vm-migration done".format(task_id, ro_task["target_id"])
@@ -1431,7 +1429,6 @@ class VimInteractionUpdateVdu(VimInteractionBase):
             )
             ro_vim_item_update = {
                 "vim_status": "VIM_ERROR",
-                "created": created,
                 "vim_message": str(e),
             }
 
@@ -1635,9 +1632,9 @@ class VimInteractionSdnNet(VimInteractionBase):
                 new_port = {
                     "service_endpoint_id": pmap.get("service_endpoint_id")
                     or service_endpoint_id,
-                    "service_endpoint_encapsulation_type": "dot1q"
-                    if port["type"] == "SR-IOV"
-                    else None,
+                    "service_endpoint_encapsulation_type": (
+                        "dot1q" if port["type"] == "SR-IOV" else None
+                    ),
                     "service_endpoint_encapsulation_info": {
                         "vlan": port.get("vlan"),
                         "mac": port.get("mac-address"),
@@ -1841,8 +1838,6 @@ class VimInteractionMigration(VimInteractionBase):
         db_task_update = {"retries": 0}
         target_vim = self.my_vims[ro_task["target_id"]]
         vim_interfaces = []
-        created = False
-        created_items = {}
         refreshed_vim_info = {}
 
         try:
@@ -1881,8 +1876,6 @@ class VimInteractionMigration(VimInteractionBase):
             ro_vim_item_update = {
                 "vim_id": vim_vm_id,
                 "vim_status": "ACTIVE",
-                "created": created,
-                "created_items": created_items,
                 "vim_details": None,
                 "vim_message": None,
             }
@@ -1909,7 +1902,6 @@ class VimInteractionMigration(VimInteractionBase):
             )
             ro_vim_item_update = {
                 "vim_status": "VIM_ERROR",
-                "created": created,
                 "vim_message": str(e),
             }
 
@@ -1921,9 +1913,7 @@ class VimInteractionResize(VimInteractionBase):
         task = ro_task["tasks"][task_index]
         task_id = task["task_id"]
         db_task_update = {"retries": 0}
-        created = False
         target_flavor_uuid = None
-        created_items = {}
         refreshed_vim_info = {}
         target_vim = self.my_vims[ro_task["target_id"]]
 
@@ -1949,8 +1939,6 @@ class VimInteractionResize(VimInteractionBase):
             ro_vim_item_update = {
                 "vim_id": vim_vm_id,
                 "vim_status": "ACTIVE",
-                "created": created,
-                "created_items": created_items,
                 "vim_details": None,
                 "vim_message": None,
             }
@@ -1971,7 +1959,6 @@ class VimInteractionResize(VimInteractionBase):
             )
             ro_vim_item_update = {
                 "vim_status": "VIM_ERROR",
-                "created": created,
                 "vim_message": str(e),
             }
 
@@ -2183,9 +2170,7 @@ class NsWorker(threading.Thread):
         target_database = (
             "vim_accounts"
             if target == "vim"
-            else "wim_accounts"
-            if target == "wim"
-            else "sdns"
+            else "wim_accounts" if target == "wim" else "sdns"
         )
         error_text = ""
 
@@ -2291,9 +2276,7 @@ class NsWorker(threading.Thread):
         target_database = (
             "vim_accounts"
             if target == "vim"
-            else "wim_accounts"
-            if target == "wim"
-            else "sdns"
+            else "wim_accounts" if target == "wim" else "sdns"
         )
         plugin_name = ""
         vim = None
@@ -2474,9 +2457,9 @@ class NsWorker(threading.Thread):
                     and task["action"] == "CREATE"
                 ):
                     # set to finished
-                    db_update["tasks.{}.status".format(index)] = task[
-                        "status"
-                    ] = "FINISHED"
+                    db_update["tasks.{}.status".format(index)] = task["status"] = (
+                        "FINISHED"
+                    )
                 elif task["action"] == "CREATE" and task["status"] not in (
                     "FINISHED",
                     "SUPERSEDED",
@@ -2789,9 +2772,9 @@ class NsWorker(threading.Thread):
                                 task_depends[dependency_task_id] = dependency_ro_task[
                                     "vim_info"
                                 ]["vim_id"]
-                                task_depends[
-                                    "TASK-{}".format(dependency_task_id)
-                                ] = dependency_ro_task["vim_info"]["vim_id"]
+                                task_depends["TASK-{}".format(dependency_task_id)] = (
+                                    dependency_ro_task["vim_info"]["vim_id"]
+                                )
 
                             if dependency_not_completed:
                                 self.logger.warning(