def get_plugin_modules(group):
    """Find plugin entry points"""
    mod_list = []
    for ep in pkg_resources.iter_entry_points(group):
        LOG.debug('Found plugin %s', ep.name)

        try:
            __import__(ep.module_name)
        except Exception:
            sys.stderr.write("WARNING: Failed to import plugin %s.\n" %
                             ep.name)
            continue

        module = sys.modules[ep.module_name]
        mod_list.append(module)
        init_func = getattr(module, 'Initialize', None)
        if init_func:
            init_func('x')

        # Add the plugin to the ClientManager
        setattr(
            clientmanager.ClientManager,
            module.API_NAME,
            clientmanager.ClientCache(
                getattr(sys.modules[ep.module_name], 'make_client', None)),
        )
    return mod_list
Ejemplo n.º 2
0
    def initialize_app(self, argv):
        self.LOG.debug('initialize_app')
        super(HOSTCLI, self).initialize_app(argv)
        try:
            self.cloud_config = cloud_config.OSC_Config(
                override_defaults={
                    'interface': None,
                    'auth_type': self._auth_type,
                },
                pw_func=shell.prompt_for_password,
            )
        except (IOError, OSError):
            self.log.critical("Could not read clouds.yaml configuration file")
            self.print_help_if_requested()
            raise
        if not self.options.debug:
            self.options.debug = None

        setattr(
            clientmanager.ClientManager, resthandler.API_NAME,
            clientmanager.ClientCache(getattr(resthandler, 'make_instance')))
        self.client_manager = clientmanager.ClientManager(
            cli_options=self.cloud,
            api_version=self.api_version,
            pw_func=shell.prompt_for_password,
        )
Ejemplo n.º 3
0
def get_plugin_modules(group):
    """Find plugin entry points"""
    mod_list = []
    for ep in pkg_resources.iter_entry_points(group):
        LOG.debug('Found plugin %r', ep.name)

        __import__(ep.module_name)
        module = sys.modules[ep.module_name]
        mod_list.append(module)
        init_func = getattr(module, 'Initialize', None)
        if init_func:
            init_func('x')

        # Add the plugin to the ClientManager
        setattr(
            clientmanager.ClientManager,
            module.API_NAME,
            clientmanager.ClientCache(
                getattr(sys.modules[ep.module_name], 'make_client', None)),
        )
    return mod_list
Ejemplo n.º 4
0
def get_plugin_modules(group):
    """Find plugin entry points"""
    mod_list = []
    mgr = stevedore.ExtensionManager(group)
    for ep in mgr:
        LOG.debug('Found plugin %s', ep.name)

        # Different versions of stevedore use different
        # implementations of EntryPoint from other libraries, which
        # are not API-compatible.
        try:
            module_name = ep.entry_point.module_name
        except AttributeError:
            try:
                module_name = ep.entry_point.module
            except AttributeError:
                module_name = ep.entry_point.value

        try:
            module = importlib.import_module(module_name)
        except Exception as err:
            sys.stderr.write(
                "WARNING: Failed to import plugin %s: %s.\n" % (ep.name, err))
            continue

        mod_list.append(module)
        init_func = getattr(module, 'Initialize', None)
        if init_func:
            init_func('x')

        # Add the plugin to the ClientManager
        setattr(
            clientmanager.ClientManager,
            module.API_NAME,
            clientmanager.ClientCache(
                getattr(sys.modules[module_name], 'make_client', None)
            ),
        )
    return mod_list
Ejemplo n.º 5
0
class Container(object):
    attr = clientmanager.ClientCache(lambda x: object())
    buggy_attr = clientmanager.ClientCache(lambda x: x.foo)

    def __init__(self):
        pass