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
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 <alfonso.tiernosepulveda@telefonica.com>"
min_common_version = "0.1.16"
"""
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")
}
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,
)
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"] = {
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)
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
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:
)
# 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:
},
fail_on_empty=False,
)
-
+
step = "Updating database, Appending tasks to ro_tasks"
self.upload_recreate_tasks(
db_new_tasks=db_new_tasks,
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
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
] = 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
--- /dev/null
+#######################################################################################
+# 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