projects
/
osm
/
RO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix interaction between feature 11003 and volume multiattach
[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
03255e3
..
e64db28
100644
(file)
--- a/
NG-RO/osm_ng_ro/ns_thread.py
+++ b/
NG-RO/osm_ng_ro/ns_thread.py
@@
-17,7
+17,7
@@
#
##
#
##
-"""
"
+"""
This is thread that interacts with a VIM. It processes TASKs sequentially against a single VIM.
The tasks are stored at database in table ro_tasks
A single ro_task refers to a VIM element (flavor, image, network, ...).
This is thread that interacts with a VIM. It processes TASKs sequentially against a single VIM.
The tasks are stored at database in table ro_tasks
A single ro_task refers to a VIM element (flavor, image, network, ...).
@@
-56,7
+56,7
@@
def deep_get(target_dict, *args, **kwargs):
:param target_dict: dictionary to be read
:param args: list of keys to read from target_dict
:param kwargs: only can contain default=value to return if key is not present in the nested dictionary
:param target_dict: dictionary to be read
:param args: list of keys to read from target_dict
:param kwargs: only can contain default=value to return if key is not present in the nested dictionary
- :return: The wanted value if exist, None or default otherwise
+ :return: The wanted value if exist
s
, None or default otherwise
"""
for key in args:
if not isinstance(target_dict, dict) or key not in target_dict:
"""
for key in args:
if not isinstance(target_dict, dict) or key not in target_dict:
@@
-345,7
+345,6
@@
class VimInteractionVdu(VimInteractionBase):
task = ro_task["tasks"][task_index]
task_id = task["task_id"]
created = False
task = ro_task["tasks"][task_index]
task_id = task["task_id"]
created = False
- created_items = {}
target_vim = self.my_vims[ro_task["target_id"]]
try:
created = True
target_vim = self.my_vims[ro_task["target_id"]]
try:
created = True
@@
-643,8
+642,11
@@
class VimInteractionImage(VimInteractionBase):
try:
# FIND
try:
# FIND
+ vim_image_id = ""
if task.get("find_params"):
if task.get("find_params"):
- vim_images = target_vim.get_image_list(**task["find_params"])
+ vim_images = target_vim.get_image_list(
+ task["find_params"].get("filter_dict", {})
+ )
if not vim_images:
raise NsWorkerExceptionNotFound(
if not vim_images:
raise NsWorkerExceptionNotFound(
@@
-663,7
+665,7
@@
class VimInteractionImage(VimInteractionBase):
ro_vim_item_update = {
"vim_id": vim_image_id,
ro_vim_item_update = {
"vim_id": vim_image_id,
- "vim_status": "
DON
E",
+ "vim_status": "
ACTIV
E",
"created": created,
"created_items": created_items,
"vim_details": None,
"created": created,
"created_items": created_items,
"vim_details": None,
@@
-694,12
+696,20
@@
class VimInteractionSharedVolume(VimInteractionBase):
task = ro_task["tasks"][task_index]
task_id = task["task_id"]
shared_volume_vim_id = ro_task["vim_info"]["vim_id"]
task = ro_task["tasks"][task_index]
task_id = task["task_id"]
shared_volume_vim_id = ro_task["vim_info"]["vim_id"]
+ created_items = ro_task["vim_info"]["created_items"]
ro_vim_item_update_ok = {
"vim_status": "DELETED",
"created": False,
"vim_message": "DELETED",
"vim_id": None,
}
ro_vim_item_update_ok = {
"vim_status": "DELETED",
"created": False,
"vim_message": "DELETED",
"vim_id": None,
}
+ if created_items and created_items.get(shared_volume_vim_id).get("keep"):
+ ro_vim_item_update_ok = {
+ "vim_status": "ACTIVE",
+ "created": False,
+ "vim_message": None,
+ }
+ return "DONE", ro_vim_item_update_ok
try:
if shared_volume_vim_id:
target_vim = self.my_vims[ro_task["target_id"]]
try:
if shared_volume_vim_id:
target_vim = self.my_vims[ro_task["target_id"]]
@@
-738,7
+748,6
@@
class VimInteractionSharedVolume(VimInteractionBase):
target_vim = self.my_vims[ro_task["target_id"]]
try:
target_vim = self.my_vims[ro_task["target_id"]]
try:
- shared_volume_name = None
shared_volume_vim_id = None
shared_volume_data = None
shared_volume_vim_id = None
shared_volume_data = None
@@
-754,11
+763,14
@@
class VimInteractionSharedVolume(VimInteractionBase):
shared_volume_vim_id,
) = target_vim.new_shared_volumes(shared_volume_data)
created = True
shared_volume_vim_id,
) = target_vim.new_shared_volumes(shared_volume_data)
created = True
- created_items[shared_volume_vim_id] = shared_volume_name
+ created_items[shared_volume_vim_id] = {
+ "name": shared_volume_name,
+ "keep": shared_volume_data.get("keep"),
+ }
ro_vim_item_update = {
"vim_id": shared_volume_vim_id,
ro_vim_item_update = {
"vim_id": shared_volume_vim_id,
- "vim_status": "
DON
E",
+ "vim_status": "
ACTIV
E",
"created": created,
"created_items": created_items,
"vim_details": None,
"created": created,
"created_items": created_items,
"vim_details": None,
@@
-837,7
+849,9
@@
class VimInteractionFlavor(VimInteractionBase):
# FIND
vim_flavor_id = None
# FIND
vim_flavor_id = None
- if task.get("find_params"):
+ if task.get("find_params", {}).get("vim_flavor_id"):
+ vim_flavor_id = task["find_params"]["vim_flavor_id"]
+ elif task.get("find_params", {}).get("flavor_data"):
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)
@@
-854,7
+868,7
@@
class VimInteractionFlavor(VimInteractionBase):
ro_vim_item_update = {
"vim_id": vim_flavor_id,
ro_vim_item_update = {
"vim_id": vim_flavor_id,
- "vim_status": "
DON
E",
+ "vim_status": "
ACTIV
E",
"created": created,
"created_items": created_items,
"vim_details": None,
"created": created,
"created_items": created_items,
"vim_details": None,
@@
-932,6
+946,7
@@
class VimInteractionAffinityGroup(VimInteractionBase):
try:
affinity_group_vim_id = None
affinity_group_data = None
try:
affinity_group_vim_id = None
affinity_group_data = None
+ param_affinity_group_id = ""
if task.get("params"):
affinity_group_data = task["params"].get("affinity_group_data")
if task.get("params"):
affinity_group_data = task["params"].get("affinity_group_data")
@@
-960,7
+975,7
@@
class VimInteractionAffinityGroup(VimInteractionBase):
ro_vim_item_update = {
"vim_id": affinity_group_vim_id,
ro_vim_item_update = {
"vim_id": affinity_group_vim_id,
- "vim_status": "
DON
E",
+ "vim_status": "
ACTIV
E",
"created": created,
"created_items": created_items,
"vim_details": None,
"created": created,
"created_items": created_items,
"vim_details": None,
@@
-997,6
+1012,7
@@
class VimInteractionUpdateVdu(VimInteractionBase):
target_vim = self.my_vims[ro_task["target_id"]]
try:
target_vim = self.my_vims[ro_task["target_id"]]
try:
+ vim_vm_id = ""
if task.get("params"):
vim_vm_id = task["params"].get("vim_vm_id")
action = task["params"].get("action")
if task.get("params"):
vim_vm_id = task["params"].get("vim_vm_id")
action = task["params"].get("action")
@@
-1005,7
+1021,7
@@
class VimInteractionUpdateVdu(VimInteractionBase):
# created = True
ro_vim_item_update = {
"vim_id": vim_vm_id,
# created = True
ro_vim_item_update = {
"vim_id": vim_vm_id,
- "vim_status": "
DON
E",
+ "vim_status": "
ACTIV
E",
"created": created,
"created_items": created_items,
"vim_details": None,
"created": created,
"created_items": created_items,
"vim_details": None,
@@
-1033,8
+1049,8
@@
class VimInteractionSdnNet(VimInteractionBase):
@staticmethod
def _match_pci(port_pci, mapping):
"""
@staticmethod
def _match_pci(port_pci, mapping):
"""
- Check if port_pci matches with mapping
- mapping can have brackets to indicate that several chars are accepted. e.g
+ Check if port_pci matches with mapping
.
+
The
mapping can have brackets to indicate that several chars are accepted. e.g
pci '0000:af:10.1' matches with '0000:af:1[01].[1357]'
:param port_pci: text
:param mapping: text, can contain brackets to indicate several chars are available
pci '0000:af:10.1' matches with '0000:af:1[01].[1357]'
:param port_pci: text
:param mapping: text, can contain brackets to indicate several chars are available
@@
-1149,6
+1165,7
@@
class VimInteractionSdnNet(VimInteractionBase):
try:
# CREATE
try:
# CREATE
+ db_vim = {}
params = task["params"]
vlds_to_connect = params.get("vlds", [])
associated_vim = params.get("target_vim")
params = task["params"]
vlds_to_connect = params.get("vlds", [])
associated_vim = params.get("target_vim")
@@
-1436,6
+1453,7
@@
class VimInteractionMigration(VimInteractionBase):
refreshed_vim_info = {}
try:
refreshed_vim_info = {}
try:
+ vim_vm_id = ""
if task.get("params"):
vim_vm_id = task["params"].get("vim_vm_id")
migrate_host = task["params"].get("migrate_host")
if task.get("params"):
vim_vm_id = task["params"].get("vim_vm_id")
migrate_host = task["params"].get("migrate_host")
@@
-1517,6
+1535,7
@@
class VimInteractionResize(VimInteractionBase):
target_vim = self.my_vims[ro_task["target_id"]]
try:
target_vim = self.my_vims[ro_task["target_id"]]
try:
+ vim_vm_id = ""
if task.get("params"):
vim_vm_id = task["params"].get("vim_vm_id")
flavor_dict = task["params"].get("flavor_dict")
if task.get("params"):
vim_vm_id = task["params"].get("vim_vm_id")
flavor_dict = task["params"].get("flavor_dict")
@@
-1544,7
+1563,7
@@
class VimInteractionResize(VimInteractionBase):
ro_vim_item_update = {
"vim_id": vim_vm_id,
ro_vim_item_update = {
"vim_id": vim_vm_id,
- "vim_status": "
DON
E",
+ "vim_status": "
ACTIV
E",
"created": created,
"created_items": created_items,
"vim_details": None,
"created": created,
"created_items": created_items,
"vim_details": None,
@@
-1777,6
+1796,7
@@
class NsWorker(threading.Thread):
if target == "wim"
else "sdns"
)
if target == "wim"
else "sdns"
)
+ error_text = ""
try:
step = "Getting {} from db".format(target_id)
try:
step = "Getting {} from db".format(target_id)
@@
-1871,7
+1891,7
@@
class NsWorker(threading.Thread):
"""
Load or reload a vim_account, sdn_controller or wim_account.
Read content from database, load the plugin if not loaded.
"""
Load or reload a vim_account, sdn_controller or wim_account.
Read content from database, load the plugin if not loaded.
- In case of error loading the plugin, it load a failing VIM_connector
+ In case of error loading the plugin, it load
s
a failing VIM_connector
It fills self db_vims dictionary, my_vims dictionary and vim_targets list
:param target_id: Contains type:_id; where type can be 'vim', ...
:return: None if ok, descriptive text if error
It fills self db_vims dictionary, my_vims dictionary and vim_targets list
:param target_id: Contains type:_id; where type can be 'vim', ...
:return: None if ok, descriptive text if error
@@
-2097,7
+2117,6
@@
class NsWorker(threading.Thread):
"""
my_task = ro_task["tasks"][task_index]
task_id = my_task["task_id"]
"""
my_task = ro_task["tasks"][task_index]
task_id = my_task["task_id"]
- task_status = None
if my_task["status"] == "FAILED":
return None, None # TODO need to be retry??
if my_task["status"] == "FAILED":
return None, None # TODO need to be retry??
@@
-2327,6
+2346,7
@@
class NsWorker(threading.Thread):
task_path = "tasks.{}.status".format(task_index)
try:
db_vim_info_update = None
task_path = "tasks.{}.status".format(task_index)
try:
db_vim_info_update = None
+ dependency_ro_task = {}
if task["status"] == "SCHEDULED":
# check if tasks that this depends on have been completed
if task["status"] == "SCHEDULED":
# check if tasks that this depends on have been completed
@@
-2527,7
+2547,7
@@
class NsWorker(threading.Thread):
lock_object["locked_at"],
lock_object["locked_at"] + self.task_locked_time,
]
lock_object["locked_at"],
lock_object["locked_at"] + self.task_locked_time,
]
- # locked_at contains two times to avoid race condition. In case the lock has been renew, it will
+ # locked_at contains two times to avoid race condition. In case the lock has been renew
ed
, it will
# contain exactly locked_at + self.task_locked_time
LockRenew.remove_lock_object(lock_object)
# contain exactly locked_at + self.task_locked_time
LockRenew.remove_lock_object(lock_object)
@@
-2539,7
+2559,7
@@
class NsWorker(threading.Thread):
# modify own task. Try filtering by to_next_check. For race condition if to_check_at has been modified,
# outside this task (by ro_nbi) do not update it
db_ro_task_update["locked_by"] = None
# modify own task. Try filtering by to_next_check. For race condition if to_check_at has been modified,
# outside this task (by ro_nbi) do not update it
db_ro_task_update["locked_by"] = None
- # locked_at converted to int only for debugging. When
ha
s not decimals it means it has been unlocked
+ # locked_at converted to int only for debugging. When
it i
s not decimals it means it has been unlocked
db_ro_task_update["locked_at"] = int(now - self.task_locked_time)
db_ro_task_update["modified_at"] = now
db_ro_task_update["to_check_at"] = next_check_at
db_ro_task_update["locked_at"] = int(now - self.task_locked_time)
db_ro_task_update["modified_at"] = now
db_ro_task_update["to_check_at"] = next_check_at