From fb1e25f7c0dcd13084dc3cc751eb10f7bb14331e Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Fri, 18 Nov 2022 14:36:22 +0100 Subject: [PATCH] Fix black issues and run tox properly in stage-test Change-Id: Ie08f3029df03f97f1df1461a564c24ce024974fe Signed-off-by: garciadeblas --- devops-stages/stage-test.sh | 5 +- osm_lcm/ns.py | 97 +++++++++++++++++------------ osm_lcm/tests/test_lcm_helm_conn.py | 7 ++- requirements-dev.txt | 5 +- requirements.txt | 2 +- tox.ini | 1 + 6 files changed, 70 insertions(+), 47 deletions(-) diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index 141fa55..45a6b1c 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -14,5 +14,6 @@ # under the License. ## -OUTPUT=$(TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto) -printf "$OUTPUT" +echo "Launching tox" +TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto + diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 2b2cadc..56d87cf 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -5288,7 +5288,9 @@ class NsLcm(LcmBase): if len(parts) == 2: kdu_model = parts[0] if desc_params.get("kdu_atomic_upgrade"): - atomic_upgrade = desc_params.get("kdu_atomic_upgrade").lower() in ("yes", "true", "1") + atomic_upgrade = desc_params.get( + "kdu_atomic_upgrade" + ).lower() in ("yes", "true", "1") del desc_params["kdu_atomic_upgrade"] else: atomic_upgrade = True @@ -5843,7 +5845,7 @@ class NsLcm(LcmBase): current_charm_artifact_path, target_charm_artifact_path, charm_artifact_paths, - helm_artifacts + helm_artifacts, ) = ([], [], [], []) step = "Checking if revision has changed in VNFD" @@ -5923,29 +5925,34 @@ class NsLcm(LcmBase): # add chart to list and all parameters step = "Getting helm chart name" chart_name = ee_item.get("helm-chart") - if ee_item.get("helm-version") and ee_item.get("helm-version") == "v2": + if ( + ee_item.get("helm-version") + and ee_item.get("helm-version") == "v2" + ): vca_type = "helm" else: vca_type = "helm-v3" step = "Setting Helm chart artifact paths" - helm_artifacts.append({ - "current_artifact_path": get_charm_artifact_path( - current_base_folder, - chart_name, - vca_type, - current_vnf_revision, - ), - "target_artifact_path": get_charm_artifact_path( - latest_base_folder, - chart_name, - vca_type, - latest_vnfd_revision, - ), - "ee_id": ee_id, - "vca_index": vca_index, - "vdu_index": vdu_count_index, - }) + helm_artifacts.append( + { + "current_artifact_path": get_charm_artifact_path( + current_base_folder, + chart_name, + vca_type, + current_vnf_revision, + ), + "target_artifact_path": get_charm_artifact_path( + latest_base_folder, + chart_name, + vca_type, + latest_vnfd_revision, + ), + "ee_id": ee_id, + "vca_index": vca_index, + "vdu_index": vdu_count_index, + } + ) charm_artifact_paths = zip( current_charm_artifact_path, target_charm_artifact_path @@ -6040,17 +6047,18 @@ class NsLcm(LcmBase): # helm base EE for item in helm_artifacts: - if ( - not ( - item["current_artifact_path"] - and item["target_artifact_path"] - and self.check_charm_hash_changed( - item["current_artifact_path"], item["target_artifact_path"] - ) - ) + if not ( + item["current_artifact_path"] + and item["target_artifact_path"] + and self.check_charm_hash_changed( + item["current_artifact_path"], + item["target_artifact_path"], + ) ): continue - db_update_entry = "_admin.deployed.VCA.{}.".format(item["vca_index"]) + db_update_entry = "_admin.deployed.VCA.{}.".format( + item["vca_index"] + ) vnfr_id = db_vnfr["_id"] osm_config = {"osm": {"ns_id": nsr_id, "vnf_id": vnfr_id}} db_dict = { @@ -6059,9 +6067,7 @@ class NsLcm(LcmBase): "path": db_update_entry, } vca_type, namespace, helm_id = get_ee_id_parts(item["ee_id"]) - await self.vca_map[ - vca_type - ].upgrade_execution_environment( + await self.vca_map[vca_type].upgrade_execution_environment( namespace=namespace, helm_id=helm_id, db_dict=db_dict, @@ -6074,20 +6080,27 @@ class NsLcm(LcmBase): self.logger.debug("get ssh key block") rw_mgmt_ip = None if deep_get( - config_descriptor, ("config-access", "ssh-access", "required") + config_descriptor, + ("config-access", "ssh-access", "required"), ): # Needed to inject a ssh key user = deep_get( config_descriptor, ("config-access", "ssh-access", "default-user"), ) - step = "Install configuration Software, getting public ssh key" - pub_key = await self.vca_map[vca_type].get_ee_ssh_public__key( + step = ( + "Install configuration Software, getting public ssh key" + ) + pub_key = await self.vca_map[ + vca_type + ].get_ee_ssh_public__key( ee_id=ee_id, db_dict=db_dict, vca_id=vca_id ) - step = "Insert public key into VM user={} ssh_key={}".format( - user, pub_key + step = ( + "Insert public key into VM user={} ssh_key={}".format( + user, pub_key + ) ) self.logger.debug(logging_text + step) @@ -6106,7 +6119,11 @@ class NsLcm(LcmBase): "initial-config-primitive" ) config_primitive = next( - (p for p in initial_config_primitive_list if p["name"] == "config"), + ( + p + for p in initial_config_primitive_list + if p["name"] == "config" + ), None, ) if not config_primitive: @@ -6117,7 +6134,9 @@ class NsLcm(LcmBase): deploy_params["rw_mgmt_ip"] = rw_mgmt_ip if db_vnfr.get("additionalParamsForVnf"): deploy_params.update( - parse_yaml_strings(db_vnfr["additionalParamsForVnf"].copy()) + parse_yaml_strings( + db_vnfr["additionalParamsForVnf"].copy() + ) ) primitive_params_ = self._map_primitive_params( config_primitive, {}, deploy_params diff --git a/osm_lcm/tests/test_lcm_helm_conn.py b/osm_lcm/tests/test_lcm_helm_conn.py index 7116517..3730162 100644 --- a/osm_lcm/tests/test_lcm_helm_conn.py +++ b/osm_lcm/tests/test_lcm_helm_conn.py @@ -79,8 +79,11 @@ class TestLcmHelmConn(asynctest.TestCase): self.db.get_one.return_value = {"_admin": {"helm-chart-v3": {"id": "myk8s_id"}}} ee_id, _ = await self.helm_conn.create_execution_environment( - namespace, db_dict, artifact_path=artifact_path, - chart_model=chart_model, vca_type="helm-v3" + namespace, + db_dict, + artifact_path=artifact_path, + chart_model=chart_model, + vca_type="helm-v3", ) self.assertEqual( ee_id, diff --git a/requirements-dev.txt b/requirements-dev.txt index 2036d20..f46b9f9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -36,7 +36,6 @@ certifi==2022.9.24 cffi==1.15.1 # via # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master - # bcrypt # cryptography # pynacl charset-normalizer==2.1.1 @@ -149,7 +148,7 @@ pyyaml==5.4.1 # juju # jujubundlelib # kubernetes -requests==2.28.0 +requests==2.28.1 # via # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master # kubernetes @@ -162,7 +161,7 @@ requests-oauthlib==1.3.1 # kubernetes retrying-async==2.0.0 # via -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master -rsa==4.8 +rsa==4.9 # via # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master # google-auth diff --git a/requirements.txt b/requirements.txt index bcd2c46..eb66bc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,7 @@ chardet==4.0.0 # via aiohttp checksumdir==1.2.0 # via -r requirements.in -grpcio==1.49.1 +grpcio==1.50.0 # via grpcio-tools grpcio-tools==1.48.1 # via -r requirements.in diff --git a/tox.ini b/tox.ini index f1aeb9b..b014de1 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,7 @@ basepython = python3.8 setenv = VIRTUAL_ENV={envdir} PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt +parallel_show_output = true ####################################################################################### [testenv:black] -- 2.25.1