Bug 2317: Fix for Able to scale-in parent VM after a failed scale-out and NS update...
[osm/LCM.git] / osm_lcm / netslice.py
index 42b634e..8fe291b 100644 (file)
@@ -34,10 +34,7 @@ __author__ = "Felipe Vicens, Pol Alemany, Alfonso Tierno"
 
 
 class NetsliceLcm(LcmBase):
-
-    timeout_nsi_deploy = 2 * 3600  # default global timeout for deployment a nsi
-
-    def __init__(self, msg, lcm_tasks, config, loop, ns):
+    def __init__(self, msg, lcm_tasks, config, ns):
         """
         Init, Connect to database, filesystem storage, and messaging
         :param config: two level dictionary with configuration. Top level should contain 'database', 'storage',
@@ -45,7 +42,6 @@ class NetsliceLcm(LcmBase):
         """
         # logging
         self.logger = logging.getLogger("lcm.netslice")
-        self.loop = loop
         self.lcm_tasks = lcm_tasks
         self.ns = ns
         self.ro_config = config["RO"]
@@ -78,7 +74,6 @@ class NetsliceLcm(LcmBase):
                 )
 
     async def instantiate(self, nsir_id, nsilcmop_id):
-
         # Try to lock HA task here
         task_is_locked_by_me = self.lcm_tasks.lock_HA("nsi", "nsilcmops", nsilcmop_id)
         if not task_is_locked_by_me:
@@ -94,7 +89,7 @@ class NetsliceLcm(LcmBase):
         db_nsilcmop_update = {}
         nsilcmop_operation_state = None
         vim_2_RO = {}
-        RO = ROclient.ROClient(self.loop, **self.ro_config)
+        RO = ROclient.ROClient(**self.ro_config)
         nsi_vld_instantiationi_params = {}
 
         def ip_profile_2_RO(ip_profile):
@@ -392,9 +387,7 @@ class NetsliceLcm(LcmBase):
             if nsi_params and nsi_params.get("timeout_nsi_deploy"):
                 timeout_nsi_deploy = nsi_params["timeout_nsi_deploy"]
             else:
-                timeout_nsi_deploy = self.timeout.get(
-                    "nsi_deploy", self.timeout_nsi_deploy
-                )
+                timeout_nsi_deploy = self.timeout.get("nsi_deploy")
 
             # Empty list to keep track of network service records status in the netslice
             nsir_admin = db_nsir_admin = db_nsir.get("_admin")
@@ -504,7 +497,7 @@ class NetsliceLcm(LcmBase):
                     break
 
                 # TODO: future improvement due to synchronism -> await asyncio.wait(vca_task_list, timeout=300)
-                await asyncio.sleep(5, loop=self.loop)
+                await asyncio.sleep(5)
 
             else:  # timeout_nsi_deploy reached:
                 raise LcmException("Timeout waiting nsi to be ready.")
@@ -577,7 +570,6 @@ class NetsliceLcm(LcmBase):
             self.lcm_tasks.remove("nsi", nsir_id, nsilcmop_id, "nsi_instantiate")
 
     async def terminate(self, nsir_id, nsilcmop_id):
-
         # Try to lock HA task here
         task_is_locked_by_me = self.lcm_tasks.lock_HA("nsi", "nsilcmops", nsilcmop_id)
         if not task_is_locked_by_me:
@@ -590,7 +582,7 @@ class NetsliceLcm(LcmBase):
         db_nsilcmop = None
         db_nsir_update = {"_admin.nsilcmop": nsilcmop_id}
         db_nsilcmop_update = {}
-        RO = ROclient.ROClient(self.loop, **self.ro_config)
+        RO = ROclient.ROClient(**self.ro_config)
         nsir_deployed = None
         failed_detail = []  # annotates all failed error messages
         nsilcmop_operation_state = None
@@ -731,7 +723,7 @@ class NetsliceLcm(LcmBase):
                             )
                     break
 
-                await asyncio.sleep(5, loop=self.loop)
+                await asyncio.sleep(5)
                 termination_timeout -= 5
 
             if termination_timeout <= 0:
@@ -864,7 +856,6 @@ class NetsliceLcm(LcmBase):
                             "operationState": nsilcmop_operation_state,
                             "autoremove": autoremove,
                         },
-                        loop=self.loop,
                     )
                 except Exception as e:
                     self.logger.error(