From: aticig Date: Mon, 2 May 2022 18:23:48 +0000 (+0300) Subject: Fixing Black and Flake8 errors in RO master X-Git-Tag: v12.0.0rc1~22 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=285185ec765bd1db4444d36834ab771c9104b1d8;p=osm%2FRO.git Fixing Black and Flake8 errors in RO master Change-Id: I401c94bc8bd67e03e2f039d69237187fd77c10f4 Signed-off-by: aticig --- diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 68d2a721..3bbb207f 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -19,8 +19,6 @@ from http import HTTPStatus import logging from random import choice as random_choice - -import yaml from threading import Lock from time import time from traceback import format_exc as traceback_format_exc @@ -51,6 +49,7 @@ from osm_common.fsbase import FsBase, FsException from osm_common.msgbase import MsgException from osm_ng_ro.ns_thread import deep_get, NsWorker, NsWorkerException from osm_ng_ro.validation import deploy_schema, validate_input +import yaml __author__ = "Alfonso Tierno " min_common_version = "0.1.16" @@ -1195,7 +1194,7 @@ class Ns(object): """ vnfr = kwargs.get("vnfr") vdu2cloud_init = kwargs.get("vdu2cloud_init") - #logger = kwargs.get("logger") + # logger = kwargs.get("logger") db = kwargs.get("db") fs = kwargs.get("fs") ro_nsr_public_key = kwargs.get("ro_nsr_public_key") @@ -1232,7 +1231,11 @@ class Ns(object): } existing_ifaces = existing_vdu["vim_info"][target_id].get("interfaces", []) net_id = next( - (i["vim_net_id"] for i in existing_ifaces if i["ip_address"] == interface["ip-address"]), + ( + i["vim_net_id"] + for i in existing_ifaces + if i["ip_address"] == interface["ip-address"] + ), None, ) @@ -1311,8 +1314,13 @@ class Ns(object): affinity_group = {} for affinity_group_id in existing_vdu["affinity-or-anti-affinity-group-id"]: for group in db_nsr.get("affinity-or-anti-affinity-group"): - if group["id"] == affinity_group_id and group["vim_info"][target_id].get("vim_id", None) is not None: - affinity_group["affinity_group_id"] = group["vim_info"][target_id].get("vim_id", None) + if ( + group["id"] == affinity_group_id + and group["vim_info"][target_id].get("vim_id", None) is not None + ): + affinity_group["affinity_group_id"] = group["vim_info"][ + target_id + ].get("vim_id", None) affinity_group_list.append(affinity_group) extra_dict["params"] = { @@ -1658,9 +1666,7 @@ class Ns(object): extra_dict=change.get("extra_dict", None), ) - self.logger.warning( - "ns.define_all_tasks task={}".format(task) - ) + self.logger.warning("ns.define_all_tasks task={}".format(task)) tasks_by_target_record_id[change["target_record_id"]] = task db_new_tasks.append(task) @@ -1746,11 +1752,13 @@ class Ns(object): self.logger.debug("Updating database, Creating ro_tasks") db_ro_task = Ns._create_ro_task(target_id, db_task) - # If DELETE task: the associated created items shoud be removed + # If DELETE task: the associated created items should be removed # (except persistent volumes): if action == "DELETE": db_ro_task["vim_info"]["created"] = True - db_ro_task["vim_info"]["created_items"] = db_task.get("created_items", {}) + db_ro_task["vim_info"]["created_items"] = db_task.get( + "created_items", {} + ) db_ro_task["vim_info"]["vim_id"] = db_task.get("vim_id", None) nb_ro_tasks += 1 @@ -1837,7 +1845,10 @@ class Ns(object): item_index = 0 existing_instance = None for instance in existing_vnf.get("vdur", None): - if (instance["vdu-name"] == vdu_name and instance["count-index"] == count_index): + if ( + instance["vdu-name"] == vdu_name + and instance["count-index"] == count_index + ): existing_instance = instance break else: @@ -1992,7 +2003,7 @@ class Ns(object): ) # Delete all ro_tasks registered for the targets vdurs (target_record) - # If task of type CREATE exist then vim will try to get info form deleted VMs. + # If task of type CREATE exist then vim will try to get info form deleted VMs. # So remove all task related to target record. ro_tasks = self.db.get_list("ro_tasks", {"tasks.nsr_id": nsr_id}) for change in changes_list: @@ -2007,7 +2018,7 @@ class Ns(object): }, fail_on_empty=False, ) - + step = "Updating database, Appending tasks to ro_tasks" self.upload_recreate_tasks( db_new_tasks=db_new_tasks, diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 51d206ef..2950aa9b 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -1849,7 +1849,9 @@ class NsWorker(threading.Thread): needed_delete = False if needed_delete: - self.logger.warning("Deleting ro_task={} task_index={}".format(ro_task, task_index)) + self.logger.warning( + "Deleting ro_task={} task_index={}".format(ro_task, task_index) + ) return self.item2class[my_task["item"]].delete(ro_task, task_index) else: return "SUPERSEDED", None @@ -2054,7 +2056,11 @@ class NsWorker(threading.Thread): dependency_task = dependency_ro_task["tasks"][ dependency_task_index ] - self.logger.warning("dependency_ro_task={} dependency_task_index={}".format(dependency_ro_task, dependency_task_index)) + self.logger.warning( + "dependency_ro_task={} dependency_task_index={}".format( + dependency_ro_task, dependency_task_index + ) + ) if dependency_task["status"] == "SCHEDULED": dependency_not_completed = True @@ -2091,7 +2097,11 @@ class NsWorker(threading.Thread): ] = dependency_ro_task["vim_info"]["vim_id"] if dependency_not_completed: - self.logger.warning("DEPENDENCY NOT COMPLETED {}".format(dependency_ro_task["vim_info"]["vim_id"])) + self.logger.warning( + "DEPENDENCY NOT COMPLETED {}".format( + dependency_ro_task["vim_info"]["vim_id"] + ) + ) # TODO set at vim_info.vim_details that it is waiting continue diff --git a/releasenotes/notes/fixing_black_errors-ac95adca43cf884c.yaml b/releasenotes/notes/fixing_black_errors-ac95adca43cf884c.yaml new file mode 100644 index 00000000..79a8bab3 --- /dev/null +++ b/releasenotes/notes/fixing_black_errors-ac95adca43cf884c.yaml @@ -0,0 +1,20 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +other: + - | + Fixing Black and Flake8 errors in RO master