X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=NG-RO%2Fosm_ng_ro%2Fns_thread.py;h=01c894ddefb4a06fe0ee3b3e009864667d53340d;hb=refs%2Fchanges%2F03%2F11503%2F2;hp=2efdbc00c6d882727327d24e7fc640a7f22a1127;hpb=160fcad1093bd3ec9f1fe574e76850610a7f034a;p=osm%2FRO.git diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 2efdbc00..01c894dd 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -24,25 +24,23 @@ A single ro_task refers to a VIM element (flavor, image, network, ...). A ro_task can contain several 'tasks', each one with a target, where to store the results """ -import logging -import queue -import threading -import time -import yaml from copy import deepcopy from http import HTTPStatus +import logging from os import mkdir -from pkg_resources import iter_entry_points +import queue from shutil import rmtree +import threading +import time from unittest.mock import Mock -# from osm_common import dbmongo, dbmemory, fslocal, fsmongo, msglocal, msgkafka, version as common_version +from importlib_metadata import entry_points from osm_common.dbbase import DbException -from osm_ro_plugin.vim_dummy import VimDummyConnector -from osm_ro_plugin.sdn_dummy import SdnDummyConnector -from osm_ro_plugin import vimconn, sdnconn from osm_ng_ro.vim_admin import LockRenew - +from osm_ro_plugin import sdnconn, vimconn +from osm_ro_plugin.sdn_dummy import SdnDummyConnector +from osm_ro_plugin.vim_dummy import VimDummyConnector +import yaml __author__ = "Alfonso Tierno" __date__ = "$28-Sep-2017 12:07:15$" @@ -596,7 +594,7 @@ class VimInteractionImage(VimInteractionBase): ) elif len(vim_images) > 1: raise NsWorkerException( - "More than one network found with this criteria: '{}'".format( + "More than one image found with this criteria: '{}'".format( task["find_params"] ) ) @@ -1229,8 +1227,8 @@ class NsWorker(threading.Thread): return self.plugins[name] try: - for v in iter_entry_points("osm_ro{}.plugins".format(type), name): - self.plugins[name] = v.load() + for ep in entry_points(group="osm_ro{}.plugins".format(type), name=name): + self.plugins[name] = ep.load() except Exception as e: raise NsWorkerException("Cannot load plugin osm_{}: {}".format(name, e)) @@ -1758,6 +1756,11 @@ class NsWorker(threading.Thread): next_check_at = min( next_check_at, dependency_ro_task["to_check_at"] ) + # must allow dependent task to be processed first + # to do this set time after last_task_processed + next_check_at = max( + self.time_last_task_processed, next_check_at + ) break elif dependency_task["status"] == "FAILED": error_text = "Cannot {} {} because depends on failed {} {} id={}): {}".format(