Switching to oslo importutils in the stress tests
The importutils is helper module for dynamic class and module,
loading.
The importutils is compatible with python 2.6 and it is
used in multiple other openstack projects.
The previously used importlib defined with python 2.7.
Change-Id: I4e99ccf9d51cea28584c9d28a4aceab633b3f998
diff --git a/openstack-common.conf b/openstack-common.conf
index 8568f22..ff84404 100644
--- a/openstack-common.conf
+++ b/openstack-common.conf
@@ -4,6 +4,7 @@
module=install_venv_common
module=lockutils
module=log
+module=importlib
# The base module to hold the copy of openstack.common
base=tempest
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index d170eb8..c4c2041 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import importlib
import logging
import multiprocessing
import time
@@ -21,6 +20,7 @@
from tempest.common import ssh
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
+from tempest.openstack.common import importutils
from tempest.stress import cleanup
admin_manager = clients.AdminManager()
@@ -93,11 +93,6 @@
return None
-def get_action_object(path):
- (module_part, _, obj_name) = path.rpartition('.')
- return getattr(importlib.import_module(module_part), obj_name)
-
-
def stress_openstack(tests, duration, max_runs=None):
"""
Workload driver. Executes an action function against a nova-cluster.
@@ -131,7 +126,7 @@
password="pass",
tenant_name=tenant_name)
- test_obj = get_action_object(test['action'])
+ test_obj = importutils.import_class(test['action'])
test_run = test_obj(manager, logger, max_runs)
kwargs = test.get('kwargs', {})