def __init__(self, options=None, config_file=None):
        # If no options have been provided, create an empty dict
        if not options:
            options = {}

        if config_file:
            config_file = [config_file]

        self.configuration_file = find_config_file(options, config_file,
                                                   CONFIG_FILE)
        if not 'plugin_provider' in options:
            options['plugin_provider'] = \
                utils.get_plugin_from_config(self.configuration_file)
        LOG.debug("Plugin location:%s", options['plugin_provider'])

        # If the plugin can't be found let them know gracefully
        try:
            plugin_klass = utils.import_class(options['plugin_provider'])
        except ClassNotFound:
            raise Exception("Plugin not found.  You can install a " \
                            "plugin with: pip install <plugin-name>\n" \
                            "Example: pip install quantum-sample-plugin")

        if not issubclass(plugin_klass, QuantumPluginBase):
            raise Exception("Configured Quantum plug-in " \
                            "didn't pass compatibility test")
        else:
            LOG.debug("Successfully imported Quantum plug-in." \
                      "All compatibility tests passed")
        self.plugin = plugin_klass()
Пример #2
0
    def __init__(self, options=None, config_file=None):
        # If no options have been provided, create an empty dict
        if not options:
            options = {}

        if config_file:
            config_file = [config_file]

        self.configuration_file = find_config_file(options, config_file,
                                                   CONFIG_FILE)
        if not 'plugin_provider' in options:
            options['plugin_provider'] = \
                utils.get_plugin_from_config(self.configuration_file)
        LOG.debug("Plugin location:%s", options['plugin_provider'])

        # If the plugin can't be found let them know gracefully
        try:
            plugin_klass = utils.import_class(options['plugin_provider'])
        except ClassNotFound:
            raise Exception("Plugin not found.  You can install a " \
                            "plugin with: pip install <plugin-name>\n" \
                            "Example: pip install quantum-sample-plugin")

        if not issubclass(plugin_klass, QuantumPluginBase):
            raise Exception("Configured Quantum plug-in " \
                            "didn't pass compatibility test")
        else:
            LOG.debug("Successfully imported Quantum plug-in." \
                      "All compatibility tests passed")
        self.plugin = plugin_klass()
Пример #3
0
 def __init__(self, options=None, config_file=None):
     if config_file == None:
         fix_path = lambda p: os.path.abspath(os.path.expanduser(p))
         config_file_dirs = [fix_path(os.getcwd()),
                     fix_path(os.path.join(os.getcwd(), 'server', 'etc')),
                     fix_path(os.path.join('~', '.quantum')),
                     fix_path('~'),
                     '/etc/quantum/',
                     '/etc']
         for cfg_dir in config_file_dirs:
             cfg_file = os.path.join(cfg_dir, CONFIG_FILE)
             if os.path.exists(cfg_file):
                 self.configuration_file = cfg_file
     else:
         self.configuration_file = config_file
     # If no options have been provided, create an empty dict
     if not options:
         options = {}
     if not 'plugin_provider' in options:
         options['plugin_provider'] = \
             utils.get_plugin_from_config(self.configuration_file)
     LOG.debug("Plugin location:%s", options['plugin_provider'])
     plugin_klass = utils.import_class(options['plugin_provider'])
     if not issubclass(plugin_klass, QuantumPluginBase):
         raise Exception("Configured Quantum plug-in " \
                         "didn't pass compatibility test")
     else:
         LOG.debug("Successfully imported Quantum plug-in." \
                   "All compatibility tests passed")
     self.plugin = plugin_klass()
Пример #4
0
def get_plugin_provider(options, config_file=None):
    if config_file:
        config_file = [config_file]

    if not 'plugin_provider' in options:
        cf = find_config_file(options, config_file, CONFIG_FILE)
        options['plugin_provider'] = utils.get_plugin_from_config(cf)
    return options['plugin_provider']