Fix black errors 27/13127/1 v13.0.1
authorGabriel Cuba <gcuba@whitestack.com>
Fri, 31 Mar 2023 03:59:58 +0000 (22:59 -0500)
committerGabriel Cuba <gcuba@whitestack.com>
Fri, 31 Mar 2023 03:59:58 +0000 (22:59 -0500)
Change-Id: I75f99cfd82a82c9aa3689635213b56aa934851f3
Signed-off-by: Gabriel Cuba <gcuba@whitestack.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/tests/test_ns.py
osm_lcm/vim_sdn.py
tox.ini

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 5638943..4f6f3a1 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
     )
@@ -695,7 +694,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())
 
@@ -792,7 +790,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 b6cc9a9..f0dcd8d 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", {}
                             ):
@@ -1569,7 +1563,6 @@ class NsLcm(LcmBase):
         ro_retries = 0
 
         while True:
-
             ro_retries += 1
             if ro_retries >= 360:  # 1 hour
                 raise LcmException(
@@ -1803,7 +1796,6 @@ class NsLcm(LcmBase):
         }
         step = ""
         try:
-
             element_type = "NS"
             element_under_configuration = nsr_id
 
@@ -1887,7 +1879,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,
@@ -2339,7 +2330,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))
 
@@ -3214,7 +3204,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
@@ -3292,7 +3281,6 @@ class NsLcm(LcmBase):
         timeout: int = 600,
         vca_id: str = None,
     ):
-
         try:
             k8sclustertype = k8s_instance_info["k8scluster-type"]
             # Instantiate kdu
@@ -5750,7 +5738,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)
@@ -5813,7 +5800,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"
@@ -5853,7 +5839,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
@@ -5890,7 +5875,6 @@ class NsLcm(LcmBase):
 
                             step = "Getting descriptor config"
                             if current_vnfd.get("kdu"):
-
                                 search_key = "kdu_name"
                             else:
                                 search_key = "vnfd_id"
@@ -5911,7 +5895,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")
 
@@ -5973,7 +5956,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
@@ -6015,10 +5997,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(
@@ -8307,7 +8287,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 1082648..3578786 100644 (file)
@@ -185,7 +185,6 @@ class TestMyNS(asynctest.TestCase):
         return str(uuid4())
 
     async def setUp(self):
-
         # Mock DB
         if not getenv("OSMLCMTEST_DB_NOMOCK"):
             # Cleanup singleton Database instance
index 0c22305..272aad1 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,7 +1289,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.
@@ -1537,7 +1525,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.
@@ -1614,7 +1601,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.
@@ -1679,7 +1665,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.
diff --git a/tox.ini b/tox.ini
index 83207a2..ba37407 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -50,7 +50,7 @@ commands =
         coverage report --omit='*tests*'
         coverage html -d ./cover --omit='*tests*'
         coverage xml -o coverage.xml --omit=*tests*
-whitelist_externals = sh
+allowlist_externals = sh
 
 
 #######################################################################################
@@ -85,7 +85,7 @@ commands =
 [testenv:pip-compile]
 deps =  pip-tools==6.6.2
 skip_install = true
-whitelist_externals = bash
+allowlist_externals = bash
         [
 commands =
         - bash -c "for file in requirements*.in ; do \
@@ -109,7 +109,7 @@ commands =
         python3 setup.py --command-packages=stdeb.command sdist_dsc
         sh -c 'cd deb_dist/osm-lcm*/ && dpkg-buildpackage -rfakeroot -uc -us'
         sh -c 'rm osm_lcm/requirements.txt'
-whitelist_externals = sh
+allowlist_externals = sh
 
 #######################################################################################
 [flake8]