From 180df199fe33137a403763e0c1a904e3804ceb27 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 30 Nov 2012 10:44:46 +0100 Subject: [PATCH] Automatically register engine options Register the engine options as soon as we import something from the engine package. This means we do not need to explicitly do it in all of the unit tests. Change-Id: I8fb0c8665d0e0255521e21a6aac223ad1e3b1b25 Signed-off-by: Zane Bitter --- bin/heat-engine | 3 +-- heat/engine/__init__.py | 16 ++++++++++++++++ heat/tests/test_api_cfn_v1.py | 2 -- heat/tests/test_api_cloudwatch.py | 2 -- heat/tests/test_api_openstack_v1.py | 2 -- heat/tests/test_engine_service.py | 2 -- heat/tests/test_loadbalancer.py | 2 -- heat/tests/test_rpc_client.py | 2 -- heat/tests/test_user.py | 2 -- heat/tests/test_waitcondition.py | 3 --- 10 files changed, 17 insertions(+), 19 deletions(-) diff --git a/bin/heat-engine b/bin/heat-engine index d0cf9561..b083b4a4 100755 --- a/bin/heat-engine +++ b/bin/heat-engine @@ -53,11 +53,10 @@ if __name__ == '__main__': cfg.CONF(project='heat', prog='heat-engine') config.setup_logging() - config.register_engine_opts() - db_api.configure() from heat.engine import service as engine + db_api.configure() srv = engine.EngineService(cfg.CONF.host, 'engine') launcher = service.launch(srv) diff --git a/heat/engine/__init__.py b/heat/engine/__init__.py index 1f19be57..024c1d74 100644 --- a/heat/engine/__init__.py +++ b/heat/engine/__init__.py @@ -1 +1,17 @@ # 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() diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py index 7564808a..d7b3279e 100644 --- a/heat/tests/test_api_cfn_v1.py +++ b/heat/tests/test_api_cfn_v1.py @@ -25,7 +25,6 @@ import httplib import json import urlparse -from heat.common import config from heat.common import context from heat.common import identifier from heat.openstack.common import cfg @@ -1104,7 +1103,6 @@ class StackControllerTest(unittest.TestCase): self.maxDiff = None self.m = mox.Mox() - config.register_engine_opts() cfg.CONF.set_default('engine_topic', 'engine') cfg.CONF.set_default('host', 'host') self.topic = '%s.%s' % (cfg.CONF.engine_topic, cfg.CONF.host) diff --git a/heat/tests/test_api_cloudwatch.py b/heat/tests/test_api_cloudwatch.py index 3f5398e6..c4d9750a 100644 --- a/heat/tests/test_api_cloudwatch.py +++ b/heat/tests/test_api_cloudwatch.py @@ -25,7 +25,6 @@ import httplib import json import urlparse -from heat.common import config from heat.common import context from heat.openstack.common import cfg from heat.openstack.common import rpc @@ -463,7 +462,6 @@ class WatchControllerTest(unittest.TestCase): self.maxDiff = None self.m = mox.Mox() - config.register_engine_opts() cfg.CONF.set_default('engine_topic', 'engine') cfg.CONF.set_default('host', 'host') self.topic = '%s.%s' % (cfg.CONF.engine_topic, cfg.CONF.host) diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py index 23d11f91..03d2832a 100644 --- a/heat/tests/test_api_openstack_v1.py +++ b/heat/tests/test_api_openstack_v1.py @@ -26,7 +26,6 @@ import httplib import urlparse import webob.exc -from heat.common import config from heat.common import context from heat.common import identifier from heat.openstack.common import cfg @@ -164,7 +163,6 @@ class ControllerTest(object): self.maxDiff = None self.m = mox.Mox() - config.register_engine_opts() cfg.CONF.set_default('engine_topic', 'engine') cfg.CONF.set_default('host', 'host') self.topic = '%s.%s' % (cfg.CONF.engine_topic, cfg.CONF.host) diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index d4dbbcfa..e2a79a8f 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -22,7 +22,6 @@ import mox import json from nose.plugins.attrib import attr -from heat.common import config from heat.common import context from heat.tests.v1_1 import fakes import heat.engine.api as engine_api @@ -100,7 +99,6 @@ class DummyThreadGroup(object): class stackCreateTest(unittest.TestCase): def setUp(self): self.m = mox.Mox() - config.register_engine_opts() def tearDown(self): self.m.UnsetStubs() diff --git a/heat/tests/test_loadbalancer.py b/heat/tests/test_loadbalancer.py index 89deb9f1..467fc791 100644 --- a/heat/tests/test_loadbalancer.py +++ b/heat/tests/test_loadbalancer.py @@ -26,7 +26,6 @@ from nose.plugins.attrib import attr from heat.common import exception from heat.common import context -from heat.common import config from heat.common import template_format from heat.engine import parser from heat.engine.resources import instance @@ -56,7 +55,6 @@ class LoadBalancerTest(unittest.TestCase): self.m.StubOutWithMock(instance.Instance, 'nova') self.m.StubOutWithMock(self.fc.servers, 'create') self.m.StubOutWithMock(Metadata, '__set__') - config.register_engine_opts() def tearDown(self): self.m.UnsetStubs() diff --git a/heat/tests/test_rpc_client.py b/heat/tests/test_rpc_client.py index 11c0ae2d..9fa29ff5 100644 --- a/heat/tests/test_rpc_client.py +++ b/heat/tests/test_rpc_client.py @@ -23,7 +23,6 @@ import stubout from nose.plugins.attrib import attr import unittest -from heat.common import config from heat.common import context from heat.rpc import client as rpc_client from heat.openstack.common import cfg @@ -35,7 +34,6 @@ class EngineRpcAPITestCase(unittest.TestCase): def setUp(self): self.context = context.get_admin_context() - config.register_engine_opts() cfg.CONF.set_default('rpc_backend', 'heat.openstack.common.rpc.impl_fake') cfg.CONF.set_default('verbose', True) diff --git a/heat/tests/test_user.py b/heat/tests/test_user.py index 69ca793b..35f63784 100644 --- a/heat/tests/test_user.py +++ b/heat/tests/test_user.py @@ -26,7 +26,6 @@ from nose.plugins.attrib import attr from heat.common import context from heat.common import exception -from heat.common import config from heat.common import template_format from heat.engine import parser from heat.engine.resources import user @@ -40,7 +39,6 @@ class UserTest(unittest.TestCase): def setUp(self): self.m = mox.Mox() self.fc = fakes.FakeKeystoneClient(username='test_stack.CfnUser') - config.register_engine_opts() cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role') def tearDown(self): diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py index df651211..4f5bf5b9 100644 --- a/heat/tests/test_waitcondition.py +++ b/heat/tests/test_waitcondition.py @@ -31,7 +31,6 @@ from heat.common import template_format from heat.engine import parser from heat.engine.resources import wait_condition as wc from heat.common import context -from heat.common import config from heat.openstack.common import cfg logger = logging.getLogger('test_waitcondition') @@ -68,7 +67,6 @@ class WaitConditionTest(unittest.TestCase): '_create_timeout') self.m.StubOutWithMock(eventlet, 'sleep') - config.register_engine_opts() cfg.CONF.set_default('heat_waitcondition_server_url', 'http://127.0.0.1:8000/v1/waitcondition') @@ -156,7 +154,6 @@ class WaitConditionTest(unittest.TestCase): class WaitConditionHandleTest(unittest.TestCase): def setUp(self): self.m = mox.Mox() - config.register_engine_opts() cfg.CONF.set_default('heat_waitcondition_server_url', 'http://127.0.0.1:8000/v1/waitcondition') -- 2.45.2