Patchwork [1/5] wic: Add command to list available source plugins

login
register
mail settings
Submitter tom.zanussi@linux.intel.com
Date July 8, 2014, 2:51 p.m.
Message ID <62d5079dcc2b71362fb5930ca600e8936a040049.1404830754.git.tom.zanussi@linux.intel.com>
Download mbox | patch
Permalink /patch/75187/
State Accepted
Commit 40769b7cc0cd94ce6f8ee93f01d64c76d9b8578e
Headers show

Comments

tom.zanussi@linux.intel.com - July 8, 2014, 2:51 p.m.
Add a 'wic list source-plugins' command enabling users to get a list
of valid partition --sources.  This is useful not only for determining
sources to use in .wks partition statements, but also for making sense
of errors in .wks partition processing.

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 scripts/lib/image/engine.py | 13 +++++++++++++
 scripts/lib/mic/plugin.py   | 16 ++++++++++++++++
 2 files changed, 29 insertions(+)

Patch

diff --git a/scripts/lib/image/engine.py b/scripts/lib/image/engine.py
index 1256236..b850bb9 100644
--- a/scripts/lib/image/engine.py
+++ b/scripts/lib/image/engine.py
@@ -174,6 +174,16 @@  def list_canned_image_help(scripts_path, fullpath):
             break
 
 
+def list_source_plugins():
+    """
+    List the available source plugins i.e. plugins available for --source.
+    """
+    plugins = pluginmgr.get_source_plugins()
+
+    for plugin in plugins:
+        print "  %s" % plugin
+
+
 def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
                native_sysroot, hdddir, staging_data_dir, scripts_path,
                image_output_dir, debug, properties_file, properties=None):
@@ -258,6 +268,9 @@  def wic_list(args, scripts_path, properties_file):
         if args[0] == "images":
             list_canned_images(scripts_path)
             return True
+        elif args[0] == "source-plugins":
+            list_source_plugins()
+            return True
         elif args[0] == "properties":
             return True
         else:
diff --git a/scripts/lib/mic/plugin.py b/scripts/lib/mic/plugin.py
index 585fd6d..f836950 100644
--- a/scripts/lib/mic/plugin.py
+++ b/scripts/lib/mic/plugin.py
@@ -117,6 +117,22 @@  class PluginMgr(object):
 
         return pluginbase.get_plugins(ptype)
 
+    def get_source_plugins(self):
+        """
+        Return list of available source plugins.
+        """
+        plugins_dir = self._build_plugin_dir_list(self.plugin_dir, 'source')
+
+        self.append_dirs(plugins_dir)
+
+        plugins = []
+
+        for _source_name, klass in self.get_plugins('source').iteritems():
+            plugins.append(_source_name)
+
+        return plugins
+
+
     def get_source_plugin_methods(self, source_name, methods):
         """
         The methods param is a dict with the method names to find.  On