Example #1
0
    def _load_plugins(self):
        for plugin_name, plugin_config in get_enabled_plugins():
            try:
                plugin_class = ('plugins.%s.%s' %
                                (plugin_name,
                                 plugin_config['kimchi']['plugin_class']))
                script_name = plugin_config['kimchi']['uri']
                del plugin_config['kimchi']

                plugin_config['/ui/config/tab-ext.xml'] = {
                    'tools.staticfile.on': True,
                    'tools.staticfile.filename':
                    os.path.join(PluginPaths(plugin_name).ui_dir,
                                 'config/tab-ext.xml'),
                    'tools.nocache.on': True}
            except KeyError:
                continue

            try:
                plugin_app = import_class(plugin_class)()
            except ImportError:
                cherrypy.log.error_log.error("Failed to import plugin %s" %
                                             plugin_class)
                continue
            cherrypy.tree.mount(plugin_app, script_name, plugin_config)
Example #2
0
    def _load_plugins(self):
        for plugin_name, plugin_config in get_enabled_plugins():
            try:
                plugin_class = (
                    'plugins.%s.%s' %
                    (plugin_name, plugin_config['kimchi']['plugin_class']))
                script_name = plugin_config['kimchi']['uri']
                del plugin_config['kimchi']

                plugin_config.update(PluginConfig(plugin_name))
            except KeyError:
                continue

            try:
                plugin_app = import_class(plugin_class)()
            except ImportError:
                cherrypy.log.error_log.error("Failed to import plugin %s" %
                                             plugin_class)
                continue
            cherrypy.tree.mount(plugin_app, script_name, plugin_config)
Example #3
0
    def _load_plugins(self):
        for plugin_name, plugin_config in get_enabled_plugins():
            try:
                plugin_class = ('plugins.%s.%s' %
                                (plugin_name,
                                 plugin_config['kimchi']['plugin_class']))
                script_name = plugin_config['kimchi']['uri']
                del plugin_config['kimchi']

                plugin_config.update(PluginConfig(plugin_name))
            except KeyError:
                continue

            try:
                plugin_app = import_class(plugin_class)()
            except ImportError:
                cherrypy.log.error_log.error("Failed to import plugin %s" %
                                             plugin_class)
                continue
            cherrypy.tree.mount(plugin_app, script_name, plugin_config)
Example #4
0
 def get_list(self):
     return [plugin for (plugin, config) in get_enabled_plugins()]
Example #5
0
    objstore_loc = config.get_object_store()
    model = kimchi.mockmodel.MockModel(objstore_loc)
    host = '127.0.0.1'
    port = get_free_port('http')
    ssl_port = get_free_port('https')
    test_server = run_server(host, port, ssl_port, test_mode=True,
                             model=model)


def tearDownModule():
    test_server.stop()
    os.unlink(objstore_loc)


@unittest.skipUnless(
    'dummy' in [plugin for plugin, _config in get_enabled_plugins()],
    'dummy plugin is not enabled, skip this test!')
class PluginTests(unittest.TestCase):

    def setUp(self):
        self.request = partial(request, host, ssl_port)

    # Colletcion/Resource Sample
    def _create_resource(self, nic, onboot, bootproto):
        req = json.dumps({'nic': nic, 'onboot': onboot, 'bootproto': bootproto})
        resp = self.request('/plugins/dummy/collectionsample', req, 'POST')
        return resp

    def _get_resource(self, nic):
        resp = self.request('/plugins/dummy/collectionsample/%s' % nic)
        return json.loads(resp.read())
Example #6
0
 def get_list(self):
     return [plugin for (plugin, config) in get_enabled_plugins()]
Example #7
0
    utils.patch_auth()
    model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
    host = '127.0.0.1'
    port = utils.get_free_port('http')
    ssl_port = utils.get_free_port('https')
    test_server = utils.run_server(host, port, ssl_port, test_mode=True,
                                   model=model)


def tearDownModule():
    test_server.stop()
    os.unlink('/tmp/obj-store-test')


@unittest.skipUnless(
    'sample' in [plugin for plugin, _config in get_enabled_plugins()],
    'sample plugin is not enabled, skip this test!')
class PluginTests(unittest.TestCase):

    def setUp(self):
        self.request = partial(utils.request, host, ssl_port)

    def _create_rectangle(self, name, length, width):
        req = json.dumps({'name': name, 'length': length, 'width': width})
        resp = self.request('/plugins/sample/rectangles', req, 'POST')
        return resp

    def _get_rectangle(self, name):
        resp = self.request('/plugins/sample/rectangles/%s' % name)
        return json.loads(resp.read())