Reformat files according to new black validation 26/12926/1
authorGulsum Atici <gulsum.atici@canonical.com>
Mon, 6 Feb 2023 19:06:44 +0000 (22:06 +0300)
committerGulsum Atici <gulsum.atici@canonical.com>
Mon, 6 Feb 2023 19:06:44 +0000 (22:06 +0300)
Change-Id: I065d8bfcc2520b296cee3903cb76a98d74185a1c
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
osm_lcm/data_utils/database/database.py
osm_lcm/data_utils/filesystem/filesystem.py
osm_lcm/lcm.py
osm_lcm/lcm_helm_conn.py
osm_lcm/lcm_utils.py
osm_lcm/netslice.py
osm_lcm/ns.py
osm_lcm/tests/test_lcm_utils.py
osm_lcm/vim_sdn.py

index dc7c8d9..0f46807 100644 (file)
@@ -45,7 +45,7 @@ class Database:
                             config["database"]["driver"]
                         )
                     )
-            except (DbException) as e:
+            except DbException as e:
                 self.logger.critical(str(e), exc_info=True)
                 raise Exception(str(e))
 
index c0110ef..f33a41b 100644 (file)
@@ -44,7 +44,7 @@ class Filesystem:
                             config["storage"]["driver"]
                         )
                     )
-            except (FsException) as e:
+            except FsException as e:
                 self.logger.critical(str(e), exc_info=True)
                 raise Exception(str(e))
 
index 4bffba9..723ca7a 100644 (file)
@@ -63,7 +63,6 @@ min_common_version = "0.1.19"
 
 
 class Lcm:
-
     ping_interval_pace = (
         120  # how many time ping is send once is confirmed all is running
     )
@@ -707,7 +706,6 @@ class Lcm:
         self.logger.debug("Task kafka_read exit")
 
     def start(self):
-
         # check RO version
         self.loop.run_until_complete(self.check_RO_version())
 
@@ -804,7 +802,6 @@ def usage():
 
 
 if __name__ == "__main__":
-
     try:
         # print("SYS.PATH='{}'".format(sys.path))
         # load parameters and configuration
index b8817a5..4d1bfb2 100644 (file)
@@ -674,7 +674,6 @@ class LCMHelmConn(N2VCConnector, LcmBase):
             )
 
         try:
-
             # Obtain cluster_uuid
             system_cluster_uuid = await self._get_system_cluster_id()
 
@@ -799,7 +798,6 @@ class LCMHelmConn(N2VCConnector, LcmBase):
             channel.close()
 
     def _write_op_detailed_status(self, db_dict, status, detailed_message):
-
         # write ee_id to database: _admin.deployed.VCA.x
         try:
             the_table = db_dict["collection"]
index 956e44f..7ce1841 100644 (file)
@@ -269,7 +269,6 @@ class LcmBase:
             target_charm = self.fs.path + target_charm_path
 
             if os.path.exists(current_charm) and os.path.exists(target_charm):
-
                 # Compare the hash of .charm files
                 if current_charm.endswith(".charm"):
                     return LcmBase.compare_charm_hash(current_charm, target_charm)
@@ -383,7 +382,6 @@ class LcmBase:
 
             # Get the NSD package path
             if revision:
-
                 nsd_package_path = db_nsr["nsd-id"] + ":" + str(revision)
                 db_nsd = self.db.get_one("nsds_revisions", {"_id": nsd_package_path})
 
index 2256540..47e3f19 100644 (file)
@@ -75,7 +75,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:
@@ -572,7 +571,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:
index 73bea40..915581f 100644 (file)
@@ -245,7 +245,6 @@ class NsLcm(LcmBase):
         return None
 
     def _on_update_ro_db(self, nsrs_id, ro_descriptor):
-
         # self.logger.debug('_on_update_ro_db(nsrs_id={}'.format(nsrs_id))
 
         try:
@@ -263,7 +262,6 @@ class NsLcm(LcmBase):
             )
 
     async def _on_update_n2vc_db(self, table, filter, path, updated_data, vca_id=None):
-
         # remove last dot from path (if exists)
         if path.endswith("."):
             path = path[:-1]
@@ -271,7 +269,6 @@ class NsLcm(LcmBase):
         # self.logger.debug('_on_update_n2vc_db(table={}, filter={}, path={}, updated_data={}'
         #                   .format(table, filter, path, updated_data))
         try:
-
             nsr_id = filter.get("_id")
 
             # read ns record from database
@@ -532,7 +529,6 @@ class NsLcm(LcmBase):
             return wim_account
 
     def scale_vnfr(self, db_vnfr, vdu_create=None, vdu_delete=None, mark_delete=False):
-
         db_vdu_push_list = []
         template_vdur = []
         db_update = {"_admin.modified": time()}
@@ -820,7 +816,6 @@ class NsLcm(LcmBase):
         start_deploy,
         timeout_ns_deploy,
     ):
-
         db_vims = {}
 
         def get_vim_account(vim_account_id):
@@ -915,7 +910,6 @@ class NsLcm(LcmBase):
                             lambda v_vld: v_vld["name"] in (a_vld["name"], a_vld["id"]),
                         )
                         if target_vld:
-
                             if vnf_params.get("vimAccountId") not in a_vld.get(
                                 "vim_info", {}
                             ):
@@ -1568,7 +1562,6 @@ class NsLcm(LcmBase):
         ro_retries = 0
 
         while True:
-
             ro_retries += 1
             if ro_retries >= 360:  # 1 hour
                 raise LcmException(
@@ -1753,7 +1746,6 @@ class NsLcm(LcmBase):
         }
         step = ""
         try:
-
             element_type = "NS"
             element_under_configuration = nsr_id
 
@@ -1837,7 +1829,6 @@ class NsLcm(LcmBase):
             vca_id = self.get_vca_id(db_vnfr, db_nsr)
             # create or register execution environment in VCA
             if vca_type in ("lxc_proxy_charm", "k8s_proxy_charm", "helm", "helm-v3"):
-
                 self._write_configuration_status(
                     nsr_id=nsr_id,
                     vca_index=vca_index,
@@ -2298,7 +2289,6 @@ class NsLcm(LcmBase):
         element_type: str = None,
         other_update: dict = None,
     ):
-
         # self.logger.debug('_write_configuration_status(): vca_index={}, status={}'
         #                   .format(vca_index, status))
 
@@ -3188,7 +3178,6 @@ class NsLcm(LcmBase):
         vca_index: int,
         timeout: int = 3600,
     ) -> bool:
-
         # steps:
         # 1. find all relations for this VCA
         # 2. wait for other peers related
@@ -3266,7 +3255,6 @@ class NsLcm(LcmBase):
         timeout: int = 600,
         vca_id: str = None,
     ):
-
         try:
             k8sclustertype = k8s_instance_info["k8scluster-type"]
             # Instantiate kdu
@@ -5521,7 +5509,6 @@ class NsLcm(LcmBase):
             raise
 
         except Exception as e:
-
             self.logger.debug("Error upgrading charm {}".format(path))
 
             return "FAILED", "Error upgrading charm {}: {}".format(path, e)
@@ -5585,7 +5572,6 @@ class NsLcm(LcmBase):
             nsr_deployed = db_nsr["_admin"].get("deployed")
 
             if update_type == "CHANGE_VNFPKG":
-
                 # Get the input parameters given through update request
                 vnf_instance_id = db_nslcmop["operationParams"][
                     "changeVnfPackageData"
@@ -5625,7 +5611,6 @@ class NsLcm(LcmBase):
 
                 step = "Checking if revision has changed in VNFD"
                 if current_vnf_revision != latest_vnfd_revision:
-
                     change_type = "policy_updated"
 
                     # There is new revision of VNFD, update operation is required
@@ -5662,7 +5647,6 @@ class NsLcm(LcmBase):
 
                             step = "Getting descriptor config"
                             if current_vnfd.get("kdu"):
-
                                 search_key = "kdu_name"
                             else:
                                 search_key = "vnfd_id"
@@ -5683,7 +5667,6 @@ class NsLcm(LcmBase):
                             # There could be several charm used in the same VNF
                             for ee_item in ee_list:
                                 if ee_item.get("juju"):
-
                                     step = "Getting charm name"
                                     charm_name = ee_item["juju"].get("charm")
 
@@ -5745,7 +5728,6 @@ class NsLcm(LcmBase):
                     if find_software_version(current_vnfd) != find_software_version(
                         latest_vnfd
                     ):
-
                         step = "Checking if existing VNF has charm"
                         for current_charm_path, target_charm_path in list(
                             charm_artifact_paths
@@ -5787,10 +5769,8 @@ class NsLcm(LcmBase):
                                     current_charm_path, target_charm_path
                                 )
                             ):
-
                                 step = "Checking whether VNF uses juju bundle"
                                 if check_juju_bundle_existence(current_vnfd):
-
                                     raise LcmException(
                                         "Charm upgrade is not supported for the instance which"
                                         " uses juju-bundle: {}".format(
@@ -8177,7 +8157,6 @@ class NsLcm(LcmBase):
         }
         step = ""
         try:
-
             element_type = "NS"
             element_under_configuration = nsr_id
 
index 71ebab1..32abbf5 100644 (file)
@@ -35,7 +35,6 @@ tmpfile = tempfile.mkstemp()[1]
 
 
 class TestLcmBase(TestCase):
-
     test_nsr_id = "f48163a6-c807-47bc-9682-f72caef5af85"
     test_nsd_id = "8c2f8b95-bb1b-47ee-8001-36dc090678da"
     nsd_package_path = "/" + test_nsd_id
@@ -186,7 +185,6 @@ class TestLcmBase(TestCase):
         with patch("osm_lcm.lcm_utils.LcmBase._get_charm_path", mock_charm_path), patch(
             "osm_lcm.lcm_utils.LcmBase._get_charm_metadata_file", mock_metadata_file
         ), patch("osm_lcm.lcm_utils.LcmBase.get_charm_name", mock_charm_name):
-
             result = instance.find_charm_name(db_nsr, "simple")
             self.assertEqual(result, expected_result, "Wrong charm name")
             mock_charm_path.assert_called_once()
@@ -208,9 +206,7 @@ class TestLcmBase(TestCase):
         with patch("osm_lcm.lcm_utils.LcmBase._get_charm_path", mock_charm_path), patch(
             "osm_lcm.lcm_utils.LcmBase._get_charm_metadata_file", mock_metadata_file
         ), patch("osm_lcm.lcm_utils.LcmBase.get_charm_name", mock_charm_name):
-
             with self.assertRaises(LcmException):
-
                 instance.find_charm_name(db_nsr, "simple")
                 self.assertEqual(mock_charm_path.call_count, 1)
                 self.assertEqual(mock_metadata_file.call_count, 1)
@@ -226,7 +222,6 @@ class TestLcmBase(TestCase):
         with patch("osm_lcm.lcm_utils.LcmBase._get_charm_path", mock_charm_path), patch(
             "osm_lcm.lcm_utils.LcmBase._get_charm_metadata_file", mock_metadata_file
         ), patch("osm_lcm.lcm_utils.LcmBase.get_charm_name", mock_charm_name):
-
             with self.assertRaises(LcmException):
                 instance.find_charm_name(db_nsr, "")
                 mock_charm_path.assert_not_called()
@@ -245,7 +240,6 @@ class TestLcmBase(TestCase):
         with patch("osm_lcm.lcm_utils.LcmBase._get_charm_path", mock_charm_path), patch(
             "osm_lcm.lcm_utils.LcmBase._get_charm_metadata_file", mock_metadata_file
         ), patch("osm_lcm.lcm_utils.LcmBase.get_charm_name", mock_charm_name):
-
             with self.assertRaises(LcmException):
                 instance.find_charm_name(db_nsr, "simple")
                 self.assertEqual(mock_charm_path.call_count, 1)
index 0eeb681..ea25c2b 100644 (file)
@@ -61,7 +61,6 @@ class VimLcm(LcmBase):
         super().__init__(msg, self.logger)
 
     async def create(self, vim_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, 'op_id' is None, and lock_HA() will do nothing.
@@ -214,7 +213,6 @@ class VimLcm(LcmBase):
             self.lcm_tasks.remove("vim_account", vim_id, order_id)
 
     async def edit(self, vim_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, and the HA check always returns True
@@ -370,7 +368,6 @@ class VimLcm(LcmBase):
             self.lcm_tasks.remove("vim_account", vim_id, order_id)
 
     async def delete(self, vim_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, and the HA check always returns True
@@ -483,7 +480,6 @@ class WimLcm(LcmBase):
         super().__init__(msg, self.logger)
 
     async def create(self, wim_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'wim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, 'op_id' is None, and lock_HA() will do nothing.
@@ -600,7 +596,6 @@ class WimLcm(LcmBase):
             self.lcm_tasks.remove("wim_account", wim_id, order_id)
 
     async def edit(self, wim_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'wim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, and the HA check always returns True
@@ -628,7 +623,6 @@ class WimLcm(LcmBase):
                 and db_wim["_admin"].get("deployed")
                 and db_wim["_admin"]["deployed"].get("RO")
             ):
-
                 RO_wim_id = db_wim["_admin"]["deployed"]["RO"]
                 step = "Editing wim at RO"
                 RO = ROclient.ROClient(self.loop, **self.ro_config)
@@ -721,7 +715,6 @@ class WimLcm(LcmBase):
             self.lcm_tasks.remove("wim_account", wim_id, order_id)
 
     async def delete(self, wim_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, and the HA check always returns True
@@ -831,7 +824,6 @@ class SdnLcm(LcmBase):
         super().__init__(msg, self.logger)
 
     async def create(self, sdn_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'sdn_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, 'op_id' is None, and lock_HA() will do nothing.
@@ -912,7 +904,6 @@ class SdnLcm(LcmBase):
             self.lcm_tasks.remove("sdn", sdn_id, order_id)
 
     async def edit(self, sdn_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'sdn_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, and the HA check always returns True
@@ -994,7 +985,6 @@ class SdnLcm(LcmBase):
             self.lcm_tasks.remove("sdn", sdn_id, order_id)
 
     async def delete(self, sdn_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, and the HA check always returns True
@@ -1127,7 +1117,6 @@ class K8sClusterLcm(LcmBase):
         }
 
     async def create(self, k8scluster_content, order_id):
-
         op_id = k8scluster_content.pop("op_id", None)
         if not self.lcm_tasks.lock_HA("k8scluster", "create", op_id):
             return
@@ -1300,12 +1289,12 @@ class K8sClusterLcm(LcmBase):
             self.lcm_tasks.remove("k8scluster", k8scluster_id, order_id)
 
     async def edit(self, k8scluster_content, order_id):
-
         op_id = k8scluster_content.pop("op_id", None)
         if not self.lcm_tasks.lock_HA("k8scluster", "edit", op_id):
             return
 
         k8scluster_id = k8scluster_content["_id"]
+
         logging_text = "Task k8scluster_edit={} ".format(k8scluster_id)
         self.logger.debug(logging_text + "Enter")
 
@@ -1326,7 +1315,6 @@ class K8sClusterLcm(LcmBase):
         self.lcm_tasks.remove("k8scluster", k8scluster_id, order_id)
 
     async def delete(self, k8scluster_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, 'op_id' is None, and lock_HA() will do nothing.
@@ -1645,7 +1633,6 @@ class VcaLcm(LcmBase):
             self.lcm_tasks.remove("vca", vca_id, order_id)
 
     async def delete(self, vca_content, order_id):
-
         # HA tasks and backward compatibility:
         # If "vim_content" does not include "op_id", we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, "op_id" is None, and lock_HA() will do nothing.
@@ -1724,7 +1711,6 @@ class K8sRepoLcm(LcmBase):
         )
 
     async def create(self, k8srepo_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, 'op_id' is None, and lock_HA() will do nothing.
@@ -1789,7 +1775,6 @@ class K8sRepoLcm(LcmBase):
             self.lcm_tasks.remove("k8srepo", k8srepo_id, order_id)
 
     async def delete(self, k8srepo_content, order_id):
-
         # HA tasks and backward compatibility:
         # If 'vim_content' does not include 'op_id', we a running a legacy NBI version.
         # In such a case, HA is not supported by NBI, 'op_id' is None, and lock_HA() will do nothing.