projects
/
osm
/
RO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Correcting invalid vcpu calculation and vcpu pinning policy evaluation.
[osm/RO.git]
/
NG-RO
/
osm_ng_ro
/
ns_thread.py
diff --git
a/NG-RO/osm_ng_ro/ns_thread.py
b/NG-RO/osm_ng_ro/ns_thread.py
index
d2b00d6
..
6e94956
100644
(file)
--- a/
NG-RO/osm_ng_ro/ns_thread.py
+++ b/
NG-RO/osm_ng_ro/ns_thread.py
@@
-27,9
+27,9
@@
A ro_task can contain several 'tasks', each one with a target, where to store th
from copy import deepcopy
from http import HTTPStatus
import logging
from copy import deepcopy
from http import HTTPStatus
import logging
-from os import mkdir
+from os import makedirs
+from os import path
import queue
import queue
-from shutil import rmtree
import threading
import time
import traceback
import threading
import time
import traceback
@@
-39,7
+39,8
@@
from unittest.mock import Mock
from importlib_metadata import entry_points
from osm_common.dbbase import DbException
from osm_ng_ro.vim_admin import LockRenew
from importlib_metadata import entry_points
from osm_common.dbbase import DbException
from osm_ng_ro.vim_admin import LockRenew
-from osm_ro_plugin import sdnconn, vimconn
+from osm_ro_plugin import sdnconn
+from osm_ro_plugin import vimconn
from osm_ro_plugin.sdn_dummy import SdnDummyConnector
from osm_ro_plugin.vim_dummy import VimDummyConnector
import yaml
from osm_ro_plugin.sdn_dummy import SdnDummyConnector
from osm_ro_plugin.vim_dummy import VimDummyConnector
import yaml
@@
-747,8
+748,10
@@
class VimInteractionFlavor(VimInteractionBase):
try:
flavor_data = task["find_params"]["flavor_data"]
vim_flavor_id = target_vim.get_flavor_id_from_data(flavor_data)
try:
flavor_data = task["find_params"]["flavor_data"]
vim_flavor_id = target_vim.get_flavor_id_from_data(flavor_data)
- except vimconn.VimConnNotFoundException:
- self.logger.warning("VimConnNotFoundException occured.")
+ except vimconn.VimConnNotFoundException as flavor_not_found_msg:
+ self.logger.warning(
+ f"VimConnNotFoundException occured: {flavor_not_found_msg}"
+ )
if not vim_flavor_id and task.get("params"):
# CREATE
if not vim_flavor_id and task.get("params"):
# CREATE
@@
-1587,7
+1590,7
@@
class NsWorker(threading.Thread):
self.task_lock.release()
return False
self.task_lock.release()
return False
- def _process_vim_config(self, target_id
, db_vim)
:
+ def _process_vim_config(self, target_id
: str, db_vim: dict) -> None
:
"""
Process vim config, creating vim configuration files as ca_cert
:param target_id: vim/sdn/wim + id
"""
Process vim config, creating vim configuration files as ca_cert
:param target_id: vim/sdn/wim + id
@@
-1598,17
+1601,14
@@
class NsWorker(threading.Thread):
return
file_name = ""
return
file_name = ""
+ work_dir = "/app/osm_ro/certs"
try:
if db_vim["config"].get("ca_cert_content"):
try:
if db_vim["config"].get("ca_cert_content"):
- file_name =
"{}:{}".format(target_id, self.worker_index)
+ file_name =
f"{work_dir}/{target_id}:{self.worker_index}"
- try:
- mkdir(file_name)
- except FileExistsError:
- self.logger.exception(
- "FileExistsError occured while processing vim_config."
- )
+ if not path.isdir(file_name):
+ makedirs(file_name)
file_name = file_name + "/ca_cert"
file_name = file_name + "/ca_cert"
@@
-1659,10
+1659,6
@@
class NsWorker(threading.Thread):
self.vim_targets.remove(target_id)
self.logger.info("Unloaded {}".format(target_id))
self.vim_targets.remove(target_id)
self.logger.info("Unloaded {}".format(target_id))
- rmtree("{}:{}".format(target_id, self.worker_index))
- except FileNotFoundError:
- # This is raised by rmtree if folder does not exist.
- self.logger.exception("FileNotFoundError occured while unloading VIM.")
except Exception as e:
self.logger.error("Cannot unload {}: {}".format(target_id, e))
except Exception as e:
self.logger.error("Cannot unload {}: {}".format(target_id, e))
@@
-1795,9
+1791,9
@@
class NsWorker(threading.Thread):
)
plugin_name = ""
vim = None
)
plugin_name = ""
vim = None
+ step = "Getting {}={} from db".format(target, _id)
try:
try:
- step = "Getting {}={} from db".format(target, _id)
# TODO process for wim, sdnc, ...
vim = self.db.get_one(target_database, {"_id": _id})
# TODO process for wim, sdnc, ...
vim = self.db.get_one(target_database, {"_id": _id})
@@
-1841,7
+1837,10
@@
class NsWorker(threading.Thread):
wim = deepcopy(vim)
wim_config = wim.pop("config", {}) or {}
wim["uuid"] = wim["_id"]
wim = deepcopy(vim)
wim_config = wim.pop("config", {}) or {}
wim["uuid"] = wim["_id"]
- wim["wim_url"] = wim["url"]
+ if "url" in wim and "wim_url" not in wim:
+ wim["wim_url"] = wim["url"]
+ elif "url" not in wim and "wim_url" in wim:
+ wim["url"] = wim["wim_url"]
if wim.get("dpid"):
wim_config["dpid"] = wim.pop("dpid")
if wim.get("dpid"):
wim_config["dpid"] = wim.pop("dpid")