Set ZYPP_LOCKFILE_ROOT env variable for multi-instance support
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 19 Dec 2011 02:48:58 +0000 (10:48 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Mon, 19 Dec 2011 02:48:58 +0000 (10:48 +0800)
Set ZYPP_LOCKFILE_ROOT environment before loading zypp backend.

Don't load all the plugin modules in get_plugins(), but only load
required plugins.

mic/creator.py
mic/plugin.py

index 333bbfe..14da049 100644 (file)
@@ -122,6 +122,7 @@ class Creator(cmdln.Cmdln):
             configmgr.create['outdir'] = self.options.outdir
         if self.options.cachedir is not None:
             configmgr.create['cachedir'] = self.options.cachedir
+        os.environ['ZYPP_LOCKFILE_ROOT'] = configmgr.create['cachedir']
         if self.options.local_pkgs_path is not None:
             configmgr.create['local_pkgs_path'] = self.options.local_pkgs_path
 
index 6f86e7d..ae41894 100644 (file)
@@ -18,6 +18,7 @@
 import os, sys
 import msger
 import pluginbase
+from mic.utils import errors
 
 __ALL__ = ['PluginMgr', 'pluginmgr']
 
@@ -37,10 +38,7 @@ class PluginMgr(object):
         return cls._instance
 
     def __init__(self):
-
-        # default plugin directory
-        for pt in PLUGIN_TYPES:
-            self._add_plugindir(os.path.join(DEFAULT_PLUGIN_LOCATION, pt))
+        pass
 
     def append_dirs(self, dirs):
         for path in dirs:
@@ -82,9 +80,11 @@ class PluginMgr(object):
 
     def get_plugins(self, ptype):
         """ the return value is dict of name:class pairs """
-
-        # good place to load all the plugins
-        self._load_all()
+        if ptype in PLUGIN_TYPES:
+            self._add_plugindir(os.path.join(DEFAULT_PLUGIN_LOCATION, ptype))
+            self._load_all()
+        else:
+            raise errors.CreatorError('%s is not valid plugin type' % ptype)
 
         return pluginbase.get_plugins(ptype)