def packages(): for package_name in extra_packages: yield sys.modules[package_name] cfg.CONF.import_opt('plugin_dirs', 'heat.common.config') yield plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine')
def test_create_subpackage_single_path(self): pkg_name = "heat.engine.test_single_path" self.assertNotIn(pkg_name, sys.modules) pkg = plugin_loader.create_subpackage("/tmp", "heat.engine", "test_single_path") self.assertIn(pkg_name, sys.modules) self.assertEqual(sys.modules[pkg_name], pkg) self.assertEqual(["/tmp"], pkg.__path__) self.assertEqual(pkg_name, pkg.__name__)
def test_create_subpackage_single_path(self): pkg_name = 'heat.engine.test_single_path' self.assertNotIn(pkg_name, sys.modules) pkg = plugin_loader.create_subpackage('/tmp', 'heat.engine', 'test_single_path') self.assertIn(pkg_name, sys.modules) self.assertEqual(sys.modules[pkg_name], pkg) self.assertEqual(['/tmp'], pkg.__path__) self.assertEqual(pkg_name, pkg.__name__)
def test_create_subpackage_single_path(self): pkg_name = 'heat.engine.test_single_path' self.assertFalse(pkg_name in sys.modules) pkg = plugin_loader.create_subpackage('/tmp', 'heat.engine', 'test_single_path') self.assertTrue(pkg_name in sys.modules) self.assertEqual(sys.modules[pkg_name], pkg) self.assertEqual(pkg.__path__, ['/tmp']) self.assertEqual(pkg.__name__, pkg_name)
def test_create_subpackage_path_list(self): path_list = ["/tmp"] pkg_name = "heat.engine.test_path_list" self.assertNotIn(pkg_name, sys.modules) pkg = plugin_loader.create_subpackage("/tmp", "heat.engine", "test_path_list") self.assertIn(pkg_name, sys.modules) self.assertEqual(sys.modules[pkg_name], pkg) self.assertEqual(path_list, pkg.__path__) self.assertNotIn(pkg.__path__, path_list) self.assertEqual(pkg_name, pkg.__name__)
def _initialise(): import sys from heat.common import plugin_loader _register_modules(plugin_loader.load_modules(sys.modules[__name__])) from heat.openstack.common import cfg plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') _register_modules(plugin_loader.load_modules(plugin_pkg, True))
def _load_global_resources(env): import sys from heat.common import plugin_loader # load plugin modules _register_modules(env, plugin_loader.load_modules(sys.modules[__name__])) cfg.CONF.import_opt('plugin_dirs', 'heat.common.config') plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') _register_modules(env, plugin_loader.load_modules(plugin_pkg, True))
def test_create_subpackage_path_list(self): path_list = ['/tmp'] pkg_name = 'heat.engine.test_path_list' self.assertNotIn(pkg_name, sys.modules) pkg = plugin_loader.create_subpackage('/tmp', 'heat.engine', 'test_path_list') self.assertIn(pkg_name, sys.modules) self.assertEqual(sys.modules[pkg_name], pkg) self.assertEqual(path_list, pkg.__path__) self.assertNotIn(pkg.__path__, path_list) self.assertEqual(pkg_name, pkg.__name__)
def _initialise(): import sys from heat.common import plugin_loader _register_modules(plugin_loader.load_modules(sys.modules[__name__])) from oslo.config import cfg plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') _register_modules(plugin_loader.load_modules(plugin_pkg, True))
def test_create_subpackage_path_list(self): path_list = ['/tmp'] pkg_name = 'heat.engine.test_path_list' self.assertFalse(pkg_name in sys.modules) pkg = plugin_loader.create_subpackage('/tmp', 'heat.engine', 'test_path_list') self.assertTrue(pkg_name in sys.modules) self.assertEqual(sys.modules[pkg_name], pkg) self.assertEqual(pkg.__path__, path_list) self.assertFalse(pkg.__path__ is path_list) self.assertEqual(pkg.__name__, pkg_name)
def _global_modules(): ''' Returns all core and plugin resource modules in Heat. Core resource modules are yielded first to allow plugin modules to override them if desired. ''' import sys from heat.common import plugin_loader cfg.CONF.import_opt('plugin_dirs', 'heat.common.config') plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') yield __name__, plugin_loader.load_modules(sys.modules[__name__]) yield plugin_pkg.__name__, plugin_loader.load_modules(plugin_pkg, True)
def initialise(): global _initialized if _initialized: return import sys from heat.common import plugin_loader _register_modules(plugin_loader.load_modules(sys.modules[__name__])) from oslo.config import cfg cfg.CONF.import_opt('plugin_dirs', 'heat.common.config') plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') _register_modules(plugin_loader.load_modules(plugin_pkg, True)) _initialized = True
def initialise(): global _environment if _environment is not None: return import sys from oslo.config import cfg from heat.common import plugin_loader _environment = environment.Environment({}, user_env=False) cfg.CONF.import_opt('environment_dir', 'heat.common.config') _load_global_environment(cfg.CONF.environment_dir) _register_modules(plugin_loader.load_modules(sys.modules[__name__])) cfg.CONF.import_opt('plugin_dirs', 'heat.common.config') plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') _register_modules(plugin_loader.load_modules(plugin_pkg, True)) _initialized = True