diff --git a/heat/db/__init__.py b/heat/db/__init__.py index c43bd22c83..e69de29bb2 100644 --- a/heat/db/__init__.py +++ b/heat/db/__init__.py @@ -1,22 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -'''Database abstraction for Heat.''' - -from heat.common import config - -config.register_db_opts() - -from heat.db.api import * diff --git a/heat/db/api.py b/heat/db/api.py index be9713b1f1..3835c14631 100644 --- a/heat/db/api.py +++ b/heat/db/api.py @@ -28,6 +28,7 @@ supported backend. from oslo.config import cfg +from heat.common import config from heat.db import utils SQL_CONNECTION = 'sqlite://' @@ -44,6 +45,7 @@ IMPL = utils.LazyPluggable('db_backend', def configure(): global SQL_CONNECTION global SQL_IDLE_TIMEOUT + config.register_db_opts() SQL_CONNECTION = cfg.CONF.sql_connection SQL_IDLE_TIMEOUT = cfg.CONF.sql_idle_timeout diff --git a/heat/engine/__init__.py b/heat/engine/__init__.py index 7675cc57c1..e69de29bb2 100644 --- a/heat/engine/__init__.py +++ b/heat/engine/__init__.py @@ -1,19 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from heat.common import config - -config.register_engine_opts() - -from heat import db # pyflakes_bypass register DB options diff --git a/heat/engine/parser.py b/heat/engine/parser.py index 203c5bc864..c925f02727 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -21,6 +21,7 @@ from heat.common import exception from heat.engine import dependencies from heat.common import identifier from heat.engine import resource +from heat.engine import resources from heat.engine import template from heat.engine import timestamp from heat.engine.parameters import Parameters @@ -84,6 +85,8 @@ class Stack(object): self.timeout_mins = timeout_mins self.disable_rollback = disable_rollback + resources.initialise() + if parameters is None: parameters = Parameters(self.name, self.t) self.parameters = parameters diff --git a/heat/engine/resources/__init__.py b/heat/engine/resources/__init__.py index 356c2f0527..1e11745596 100644 --- a/heat/engine/resources/__init__.py +++ b/heat/engine/resources/__init__.py @@ -42,10 +42,19 @@ def _register_modules(modules): _register_resources(itertools.chain.from_iterable(resource_lists)) -def _initialise(): +_initialized = False + + +def initialise(): + global _initialized + if _initialized: + return import sys + from heat.common import config from heat.common import plugin_loader + config.register_engine_opts() + _register_modules(plugin_loader.load_modules(sys.modules[__name__])) from oslo.config import cfg @@ -53,6 +62,4 @@ def _initialise(): plugin_pkg = plugin_loader.create_subpackage(cfg.CONF.plugin_dirs, 'heat.engine') _register_modules(plugin_loader.load_modules(plugin_pkg, True)) - - -_initialise() + _initialized = True diff --git a/heat/engine/service.py b/heat/engine/service.py index efd962c1ac..df34da6160 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -19,6 +19,7 @@ import json from oslo.config import cfg import webob +from heat.common import config from heat.common import context from heat.db import api as db_api from heat.engine import api @@ -65,6 +66,7 @@ class EngineService(service.Service): super(EngineService, self).__init__(host, topic) # stg == "Stack Thread Groups" self.stg = {} + config.register_engine_opts() def _start_in_thread(self, stack_id, func, *args, **kwargs): if stack_id not in self.stg: diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index e5ed9679e4..b61942729c 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -25,7 +25,7 @@ from heat.common import context from heat.common import exception from heat.tests.v1_1 import fakes import heat.engine.api as engine_api -import heat.db as db_api +import heat.db.api as db_api from heat.common import identifier from heat.common import template_format from heat.engine import parser diff --git a/heat/tests/test_event.py b/heat/tests/test_event.py index cd50cdfabe..580af8339a 100644 --- a/heat/tests/test_event.py +++ b/heat/tests/test_event.py @@ -18,7 +18,7 @@ import mox import unittest from heat.common import context -import heat.db as db_api +import heat.db.api as db_api from heat.engine import parser from heat.engine import resource from heat.engine import template diff --git a/heat/tests/test_loadbalancer.py b/heat/tests/test_loadbalancer.py index 1cc916acd0..170210156e 100644 --- a/heat/tests/test_loadbalancer.py +++ b/heat/tests/test_loadbalancer.py @@ -23,6 +23,7 @@ from nose.plugins.attrib import attr from oslo.config import cfg from heat.common import exception +from heat.common import config from heat.common import context from heat.common import template_format from heat.engine import parser @@ -49,6 +50,7 @@ def create_context(mocks, user='lb_test_user', @attr(speed='fast') class LoadBalancerTest(unittest.TestCase): def setUp(self): + config.register_engine_opts() self.m = mox.Mox() self.fc = fakes.FakeClient() self.m.StubOutWithMock(lb.LoadBalancer, 'nova') diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index 8a349edd1b..968aaf5089 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -29,7 +29,7 @@ from heat.engine import template from heat.tests.utils import stack_delete_after from heat.tests import generic_resource as generic_rsrc -import heat.db as db_api +import heat.db.api as db_api def join(raw): diff --git a/heat/tests/test_rpc_client.py b/heat/tests/test_rpc_client.py index 11c5627f34..d250c2f7d3 100644 --- a/heat/tests/test_rpc_client.py +++ b/heat/tests/test_rpc_client.py @@ -24,6 +24,7 @@ from oslo.config import cfg import stubout import unittest +from heat.common import config from heat.common import context from heat.common import identifier from heat.rpc import client as rpc_client @@ -34,6 +35,7 @@ from heat.openstack.common import rpc class EngineRpcAPITestCase(unittest.TestCase): def setUp(self): + config.register_engine_opts() self.context = context.get_admin_context() cfg.CONF.set_default('rpc_backend', 'heat.openstack.common.rpc.impl_fake') diff --git a/heat/tests/test_security_group.py b/heat/tests/test_security_group.py index bfa30dd4ac..ab8051bd44 100644 --- a/heat/tests/test_security_group.py +++ b/heat/tests/test_security_group.py @@ -28,7 +28,6 @@ from heat.tests.v1_1 import fakes from novaclient.v1_1 import security_groups as nova_sg from novaclient.v1_1 import security_group_rules as nova_sgr - NovaSG = collections.namedtuple('NovaSG', ' '.join([ 'name', diff --git a/heat/tests/test_user.py b/heat/tests/test_user.py index 52fc616364..6c2495c026 100644 --- a/heat/tests/test_user.py +++ b/heat/tests/test_user.py @@ -20,6 +20,7 @@ import mox from nose.plugins.attrib import attr from oslo.config import cfg +from heat.common import config from heat.common import context from heat.common import exception from heat.common import template_format @@ -34,6 +35,7 @@ import keystoneclient.exceptions @attr(speed='fast') class UserTest(unittest.TestCase): def setUp(self): + config.register_engine_opts() self.m = mox.Mox() self.fc = fakes.FakeKeystoneClient(username='test_stack.CfnUser') cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role') @@ -225,6 +227,7 @@ class UserTest(unittest.TestCase): @attr(speed='fast') class AccessKeyTest(unittest.TestCase): def setUp(self): + config.register_engine_opts() self.m = mox.Mox() self.fc = fakes.FakeKeystoneClient(username='test_stack.CfnUser') cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role') diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 689b828aa9..8c9a51b632 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -23,7 +23,7 @@ from heat.common import exception from heat.common import template_format from heat.engine.resources import instance as instances from heat.engine import service -import heat.db as db_api +import heat.db.api as db_api from heat.engine import parser test_template_volumeattach = ''' diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py index 2977d2179d..c211df0736 100644 --- a/heat/tests/test_waitcondition.py +++ b/heat/tests/test_waitcondition.py @@ -26,11 +26,12 @@ import unittest from heat.tests import fakes from heat.tests.utils import stack_delete_after -import heat.db as db_api +import heat.db.api as db_api from heat.common import template_format from heat.common import identifier from heat.engine import parser from heat.engine.resources import wait_condition as wc +from heat.common import config from heat.common import context test_template_waitcondition = ''' @@ -79,6 +80,7 @@ test_template_wc_count = ''' @attr(speed='slow') class WaitConditionTest(unittest.TestCase): def setUp(self): + config.register_engine_opts() self.m = mox.Mox() self.m.StubOutWithMock(wc.WaitConditionHandle, 'get_status') @@ -381,6 +383,7 @@ class WaitConditionTest(unittest.TestCase): @attr(speed='fast') class WaitConditionHandleTest(unittest.TestCase): def setUp(self): + config.register_engine_opts() self.m = mox.Mox() cfg.CONF.set_default('heat_waitcondition_server_url', 'http://127.0.0.1:8000/v1/waitcondition') diff --git a/heat/tests/test_watch.py b/heat/tests/test_watch.py index b2d0b4c9ee..7a0162d4a4 100644 --- a/heat/tests/test_watch.py +++ b/heat/tests/test_watch.py @@ -18,7 +18,7 @@ import mox from nose.plugins.attrib import attr import unittest from heat.common import context -import heat.db as db_api +import heat.db.api as db_api from heat.openstack.common import timeutils from heat.engine import watchrule