コード例 #1
0
def _load_plugins(plugins, debug=True):
    """
    Do not use - will be removed in the next release!

    Merge this into StarClusterConfig._load_plugins in a future release.
    Currently used to provide backwards compatibility for the plugin kwarg for
    Cluster. Cluster now expects the plugins kwarg to be a list of plugin
    objects not a list of dicts. This should be merged into
    StarClusterConfig._load_plugins in a future release after warning about the
    change in a previous release.
    """
    plugs = []
    for plugin in plugins:
        setup_class = plugin.get('setup_class')
        plugin_name = plugin.get('__name__').split()[-1]
        mod_name = '.'.join(setup_class.split('.')[:-1])
        class_name = setup_class.split('.')[-1]
        try:
            mod = __import__(mod_name, globals(), locals(), [class_name])
        except SyntaxError, e:
            raise exception.PluginSyntaxError(
                "Plugin %s (%s) contains a syntax error at line %s" %
                (plugin_name, e.filename, e.lineno))
        except ImportError, e:
            raise exception.PluginLoadError("Failed to import plugin %s: %s" %
                                            (plugin_name, e[0]))
コード例 #2
0
ファイル: node.py プロジェクト: theoryno3/StarCluster
 def get_plugins(self):
     plugstxt = self.user_data.get(static.UD_PLUGINS_FNAME)
     payload = plugstxt.split('\n', 2)[2]
     plugins_metadata = utils.decode_uncompress_load(payload)
     plugs = []
     for klass, args, kwargs in plugins_metadata:
         mod_path, klass_name = klass.rsplit('.', 1)
         try:
             mod = __import__(mod_path, fromlist=[klass_name])
             plug = getattr(mod, klass_name)(*args, **kwargs)
         except SyntaxError, e:
             raise exception.PluginSyntaxError(
                 "Plugin %s (%s) contains a syntax error at line %s" %
                 (klass_name, e.filename, e.lineno))
         except ImportError, e:
             raise exception.PluginLoadError(
                 "Failed to import plugin %s: %s" % (klass_name, e[0]))
コード例 #3
0
 def get_plugins(self, order, plugins_metadata=None):
     if plugins_metadata is None:
         plugins_metadata = self.get_plugins_full_metadata(order)
     plugs = []
     for klass, args, kwargs in plugins_metadata:
         mod_path, klass_name = klass.rsplit('.', 1)
         try:
             mod = __import__(mod_path, fromlist=[klass_name])
             plug = getattr(mod, klass_name)(*args, **kwargs)
         except SyntaxError, e:
             raise exception.PluginSyntaxError(
                 "Plugin %s (%s) contains a syntax error at line %s" %
                 (klass_name, e.filename, e.lineno))
         except ImportError, e:
             raise exception.PluginLoadError(
                 "Failed to import plugin %s: %s" %
                 (klass_name, e[0]))
コード例 #4
0
ファイル: node.py プロジェクト: gabekron/StarCluster
            mod_path, klass_name = klass.rsplit('.', 1)
            try:
                mod = __import__(mod_path, fromlist=[klass_name])
                plug = getattr(mod, klass_name)(*args, **kwargs)
            except SyntaxError, e:
                raise exception.PluginSyntaxError(
                    "Plugin %s (%s) contains a syntax error at line %s" %
                    (klass_name, e.filename, e.lineno))
            except ImportError, e:
                raise exception.PluginLoadError(
                    "Failed to import plugin %s: %s" %
                    (klass_name, e[0]))
            except Exception as exc:
                log.error("Error occured:", exc_info=True)
                raise exception.PluginLoadError(
                    "Failed to load plugin %s with "
                    "the following error: %s - %s" %
                    (klass_name, exc.__class__.__name__, exc.message))
            plugs.append(plug)
        return plugs

    def get_volumes(self):
        volstxt = self.user_data.get(static.UD_VOLUMES_FNAME)
        payload = volstxt.split('\n', 2)[2]
        return utils.decode_uncompress_load(payload)

    def _remove_all_tags(self):
        tags = self.tags.keys()[:]
        for t in tags:
            self.remove_tag(t)

    @property