Irit Goihman has uploaded a new change for review.
Change subject: supervdsmServer: using moduleloader for dynamic imports
......................................................................
supervdsmServer: using moduleloader for dynamic imports
moduleloader utility handles dynamic imports of modules that
belong to a given package.
Change-Id: Iba05dc1433fc9c3fea53e17c1c0cae835078233d
Signed-off-by: Irit Goihman <igoihman(a)redhat.com>
---
M vdsm/supervdsmServer
1 file changed, 4 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/61313/1
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index 6fd489b..ed70a95 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -21,8 +21,6 @@
import sys
import os
import errno
-import importlib
-import pkgutil
from functools import wraps
import getopt
import resource
@@ -32,6 +30,7 @@
from contextlib import closing
from vdsm import concurrent
+from vdsm import moduleloader
from vdsm.common import sigutils
from vdsm.common import zombiereaper
@@ -257,11 +256,9 @@
for name, func in listPublicFunctions(GLUSTER_MGMT_ENABLED):
setattr(_SuperVdsm, name, bind(logDecorator(func)))
- for _, module_name, _ in pkgutil.iter_modules([supervdsm_api.__path__[0]]):
- module = importlib.import_module('%s.%s' %
- (supervdsm_api.__name__,
- module_name))
- api_funcs = [f for _, f in module.__dict__.iteritems()
+ modules = moduleloader.load_modules(supervdsm_api)
+ for module_name in modules:
+ api_funcs = [f for _, f in modules[module_name].__dict__.iteritems()
if callable(f) and getattr(f, 'exposed_api', False)]
for func in api_funcs:
setattr(_SuperVdsm, func.__name__, bind(logDecorator(func)))
--
To view, visit
https://gerrit.ovirt.org/61313
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba05dc1433fc9c3fea53e17c1c0cae835078233d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Irit Goihman <igoihman(a)redhat.com>