Merge "Declare the CONF variable"

This commit is contained in:
Jenkins 2015-07-15 00:39:08 +00:00 committed by Gerrit Code Review
commit 6ac473fabb
25 changed files with 101 additions and 78 deletions

View File

@ -23,6 +23,7 @@ import murano.dsl.helpers as helpers
from murano.openstack.common import log as logging
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -64,7 +65,7 @@ class GlanceClient(object):
@classmethod
def init_plugin(cls):
cls.CONF = cfg.init_config(config.CONF)
cls.CONF = cfg.init_config(CONF)
def create_glance_client(self, keystone_client, auth_token):
LOG.debug("Creating a glance client")

View File

@ -39,13 +39,15 @@ from murano.common import config
from murano.common import engine
from murano.openstack.common import log
CONF = config.CONF
def main():
try:
config.parse_args()
log.setup('murano')
launcher = service.ServiceLauncher(config.CONF)
launcher = service.ServiceLauncher(CONF)
launcher.launch_service(engine.get_rpc_service())
launcher.wait()

View File

@ -17,12 +17,12 @@ import traceback
import uuid
import eventlet.debug
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging import target
from oslo_serialization import jsonutils
from murano.common import auth_utils
from murano.common import config
from murano.common.helpers import token_sanitizer
from murano.common import plugin_loader
from murano.common import rpc
@ -39,6 +39,7 @@ from murano.common.i18n import _LI, _LE
from murano.openstack.common import log as logging
from murano.policy import model_policy_enforcer as enforcer
CONF = cfg.CONF
RPC_SERVICE = None
PLUGIN_LOADER = None
@ -75,7 +76,7 @@ class TaskProcessingEndpoint(object):
def _prepare_rpc_service(server_id):
endpoints = [TaskProcessingEndpoint()]
transport = messaging.get_transport(config.CONF)
transport = messaging.get_transport(CONF)
s_target = target.Target('murano', 'tasks', server=server_id)
return messaging.get_rpc_server(transport, s_target, endpoints, 'eventlet')
@ -230,7 +231,7 @@ class TaskExecutor(object):
}
def _validate_model(self, obj, action, class_loader):
if config.CONF.engine.enable_model_policy_enforcer:
if CONF.engine.enable_model_policy_enforcer:
if obj is not None:
if action is not None and action['method'] == 'deploy':
self._model_policy_enforcer.validate(obj.to_dictionary(),
@ -244,7 +245,7 @@ class TaskExecutor(object):
return obj.type.invoke(method_name, mpl_executor, obj, args)
def _create_trust(self):
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
return
trust_id = self._environment.system_attributes.get('TrustId')
if not trust_id:

View File

@ -15,15 +15,15 @@
import inspect
import re
from oslo_config import cfg
import six
from stevedore import dispatch
from murano.common import config
from murano.common.i18n import _LE, _LI, _LW
from murano.openstack.common import log as logging
CONF = config.CONF
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
# regexp validator to ensure that the entry-point name is a valid MuranoPL

View File

@ -12,11 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging import rpc
from oslo_messaging import target
from murano.common import config
CONF = cfg.CONF
TRANSPORT = None
@ -43,7 +44,7 @@ class EngineClient(object):
def api():
global TRANSPORT
if TRANSPORT is None:
TRANSPORT = messaging.get_transport(config.CONF)
TRANSPORT = messaging.get_transport(CONF)
return ApiClient(TRANSPORT)
@ -51,6 +52,6 @@ def api():
def engine():
global TRANSPORT
if TRANSPORT is None:
TRANSPORT = messaging.get_transport(config.CONF)
TRANSPORT = messaging.get_transport(CONF)
return EngineClient(TRANSPORT)

View File

@ -14,13 +14,13 @@
import uuid
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging.notify import dispatcher as oslo_dispatcher
from oslo_messaging import target
from oslo_utils import timeutils
from sqlalchemy import desc
from murano.common import config
from murano.common.helpers import token_sanitizer
from murano.db import models
from murano.db.services import environments
@ -30,6 +30,7 @@ from murano.common.i18n import _, _LI, _LW
from murano.openstack.common import log as logging
from murano.services import states
CONF = cfg.CONF
RPC_SERVICE = None
NOTIFICATION_SERVICE = None
@ -195,7 +196,7 @@ def get_last_deployment(unit, env_id):
def _prepare_rpc_service(server_id):
endpoints = [ResultEndpoint()]
transport = messaging.get_transport(config.CONF)
transport = messaging.get_transport(CONF)
s_target = target.Target('murano', 'results', server=server_id)
return messaging.get_rpc_server(transport, s_target, endpoints, 'eventlet')
@ -203,7 +204,7 @@ def _prepare_rpc_service(server_id):
def _prepare_notification_service(server_id):
endpoints = [report_notification, track_instance, untrack_instance]
transport = messaging.get_transport(config.CONF)
transport = messaging.get_transport(CONF)
s_target = target.Target(topic='murano', server=server_id)
dispatcher = oslo_dispatcher.NotificationDispatcher(
[s_target], endpoints, None, True)

View File

@ -18,18 +18,19 @@ import socket
import time
import eventlet
from oslo_config import cfg
from oslo_service import service
import psutil
from murano.api import v1
from murano.api.v1 import request_statistics
from murano.common import config
from murano.common.i18n import _LE
from murano.db.services import stats as db_stats
from murano.openstack.common import log as logging
CONF = cfg.CONF
CONF_STATS = config.CONF.stats
CONF_STATS = CONF.stats
LOG = logging.getLogger(__name__)

View File

@ -13,10 +13,10 @@
# under the License.
from keystoneclient import exceptions as ks_exceptions
from oslo_config import cfg
import yaml
from murano.common import auth_utils
from murano.common import config
from murano.common import uuidutils
from murano.db import models
from murano.db.services import sessions
@ -24,6 +24,7 @@ from murano.db import session as db_session
from murano.openstack.common import log as logging
from murano.services import states
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
DEFAULT_NETWORK_TYPES = {
@ -205,8 +206,8 @@ class EnvironmentServices(object):
@staticmethod
def generate_default_networks(env_name, network_driver):
net_config = config.CONF.find_file(
config.CONF.networking.network_config_file)
net_config = CONF.find_file(
CONF.networking.network_config_file)
if net_config:
LOG.debug("Loading network configuration from file")
with open(net_config) as f:

View File

@ -15,17 +15,17 @@
"""Session management functions."""
import threading
from oslo_config import cfg
from oslo_db import exception
from oslo_db import options
from oslo_db.sqlalchemy import session as db_session
from oslo_utils import timeutils
from murano.common import config
from murano.db.models import Lock
from murano.openstack.common import log as logging
LOG = logging.getLogger(__name__)
CONF = config.CONF
CONF = cfg.CONF
options.set_defaults(CONF)

View File

@ -20,7 +20,6 @@ import neutronclient.v2_0.client as nclient
from oslo_config import cfg
from murano.common import auth_utils
from murano.common import config
from murano.dsl import helpers
from murano.engine import environment
@ -35,6 +34,8 @@ try:
except ImportError as mistral_import_error:
mistralclient = None
CONF = cfg.CONF
class ClientManager(object):
def __init__(self):
@ -49,7 +50,7 @@ class ClientManager(object):
return helpers.get_environment(context)
def get_client(self, context, name, use_trusts, client_factory):
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
keystone_client = None if name == 'keystone' else \
@ -75,7 +76,7 @@ class ClientManager(object):
self._semaphore.release()
def get_keystone_client(self, context, use_trusts=True):
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
env = self._get_environment(context)
factory = lambda _1, _2: \
@ -95,7 +96,7 @@ class ClientManager(object):
if not congress_client:
# congress client was not imported
raise congress_client_import_error
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
def factory(keystone_client, auth_token):
@ -110,11 +111,11 @@ class ClientManager(object):
return self.get_client(context, 'congress', use_trusts, factory)
def get_heat_client(self, context, use_trusts=True):
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
def factory(keystone_client, auth_token):
heat_settings = config.CONF.heat
heat_settings = CONF.heat
heat_url = keystone_client.service_catalog.url_for(
service_type='orchestration',
@ -128,7 +129,7 @@ class ClientManager(object):
'insecure': heat_settings.insecure
}
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
kwargs.update({
'username': 'badusername',
'password': 'badpassword'
@ -138,11 +139,11 @@ class ClientManager(object):
return self.get_client(context, 'heat', use_trusts, factory)
def get_neutron_client(self, context, use_trusts=True):
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
def factory(keystone_client, auth_token):
neutron_settings = config.CONF.neutron
neutron_settings = CONF.neutron
neutron_url = keystone_client.service_catalog.url_for(
service_type='network',
@ -157,11 +158,11 @@ class ClientManager(object):
return self.get_client(context, 'neutron', use_trusts, factory)
def get_murano_client(self, context, use_trusts=True):
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
def factory(keystone_client, auth_token):
murano_settings = config.CONF.murano
murano_settings = CONF.murano
murano_url = \
murano_settings.url or keystone_client.service_catalog.url_for(
@ -183,11 +184,11 @@ class ClientManager(object):
if not mistralclient:
raise mistral_import_error
if not config.CONF.engine.use_trusts:
if not CONF.engine.use_trusts:
use_trusts = False
def factory(keystone_client, auth_token):
mistral_settings = config.CONF.mistral
mistral_settings = CONF.mistral
endpoint_type = mistral_settings.endpoint_type
service_type = mistral_settings.service_type

View File

@ -21,9 +21,9 @@ import tempfile
import uuid
from muranoclient.common import exceptions as muranoclient_exc
from oslo_config import cfg
import six
from murano.common import config
from murano.common.i18n import _LE
from murano.dsl import exceptions
from murano.engine import yaql_yaml_loader
@ -31,6 +31,7 @@ from murano.openstack.common import log as logging
from murano.packages import exceptions as pkg_exc
from murano.packages import load_utils
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -71,7 +72,7 @@ class ApiPackageLoader(PackageLoader):
@staticmethod
def _get_cache_directory():
base_directory = (
config.CONF.packages_opts.packages_cache or
CONF.packages_opts.packages_cache or
os.path.join(tempfile.gettempdir(), 'murano-packages-cache')
)
directory = os.path.abspath(os.path.join(base_directory,

View File

@ -24,7 +24,6 @@ import uuid
import eventlet.event
from oslo_config import cfg
import murano.common.config as config
import murano.common.exceptions as exceptions
import murano.common.messaging as messaging
import murano.dsl.murano_class as murano_class
@ -44,7 +43,7 @@ class AgentException(Exception):
class Agent(murano_object.MuranoObject):
def initialize(self, _context, host):
self._enabled = False
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
LOG.debug('Use of murano-agent is disallowed '
'by the server configuration')
return
@ -65,7 +64,7 @@ class Agent(murano_object.MuranoObject):
def prepare(self):
# (sjmc7) - turn this into a no-op if agents are disabled
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
LOG.debug('Use of murano-agent is disallowed '
'by the server configuration')
return
@ -77,7 +76,7 @@ class Agent(murano_object.MuranoObject):
return self._queue
def _check_enabled(self):
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
raise exceptions.PolicyViolationException(
'Use of murano-agent is disallowed '
'by the server configuration')

View File

@ -15,8 +15,9 @@
import eventlet
import greenlet
from oslo_config import cfg
import murano.common.config as config
import murano.common.exceptions as exceptions
from murano.dsl import helpers
import murano.dsl.murano_class as murano_class
@ -25,6 +26,7 @@ import murano.engine.system.common as common
from murano.openstack.common import log as logging
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
class AgentListenerException(Exception):
@ -35,7 +37,7 @@ class AgentListenerException(Exception):
class AgentListener(murano_object.MuranoObject):
def initialize(self, _context, name):
self._enabled = False
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
return
self._enabled = True
self._results_queue = str('-execution-results-%s' % name.lower())
@ -43,7 +45,7 @@ class AgentListener(murano_object.MuranoObject):
self._receive_thread = None
def _check_enabled(self):
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
LOG.debug(
'Use of murano-agent is disallowed '
'by the server configuration')
@ -60,7 +62,7 @@ class AgentListener(murano_object.MuranoObject):
return self._results_queue
def start(self, _context):
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
# Noop
LOG.debug("murano-agent is disabled by the server")
return
@ -71,7 +73,7 @@ class AgentListener(murano_object.MuranoObject):
self._receive_thread = eventlet.spawn(self._receive)
def stop(self):
if config.CONF.engine.disable_murano_agent:
if CONF.engine.disable_murano_agent:
# Noop
LOG.debug("murano-agent is disabled by the server")
return

View File

@ -13,12 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import murano.common.config as config
from oslo_config import cfg
import murano.common.messaging as messaging
CONF = cfg.CONF
def create_rmq_client():
rabbitmq = config.CONF.rabbitmq
rabbitmq = CONF.rabbitmq
connection_params = {
'login': rabbitmq.login,
'password': rabbitmq.password,

View File

@ -13,14 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_config import cfg
import oslo_messaging as messaging
from murano.common import config
from murano.common import uuidutils
from murano.dsl import murano_class
from murano.openstack.common import log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
UNCLASSIFIED = 0
@ -34,8 +34,7 @@ class InstanceReportNotifier(object):
def initialize(self, environment):
if InstanceReportNotifier.transport is None:
InstanceReportNotifier.transport = \
messaging.get_transport(config.CONF)
InstanceReportNotifier.transport = messaging.get_transport(CONF)
self._notifier = messaging.Notifier(
InstanceReportNotifier.transport,
publisher_id=uuidutils.generate_uuid(),

View File

@ -16,15 +16,15 @@ import math
import netaddr
from netaddr.strategy import ipv4
from oslo_config import cfg
from oslo_utils import uuidutils
import murano.common.config as config
import murano.dsl.helpers as helpers
import murano.dsl.murano_class as murano_class
import murano.dsl.murano_object as murano_object
from murano.openstack.common import log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -35,7 +35,7 @@ class NetworkExplorer(murano_object.MuranoObject):
environment = helpers.get_environment(_context)
self._clients = environment.clients
self._tenant_id = environment.tenant_id
self._settings = config.CONF.networking
self._settings = CONF.networking
self._available_cidrs = self._generate_possible_cidrs()
# noinspection PyPep8Naming

View File

@ -13,14 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_config import cfg
import oslo_messaging as messaging
from murano.common import config
from murano.common import uuidutils
from murano.dsl import murano_class
from murano.openstack.common import log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -30,8 +30,7 @@ class StatusReporter(object):
def initialize(self, environment):
if StatusReporter.transport is None:
StatusReporter.transport = \
messaging.get_transport(config.CONF)
StatusReporter.transport = messaging.get_transport(CONF)
self._notifier = messaging.Notifier(
StatusReporter.transport,
publisher_id=uuidutils.generate_uuid(),

View File

@ -24,11 +24,12 @@ import types
import jsonpatch
import jsonpointer
from oslo_config import cfg
import yaql.context
import murano.common.config as cfg
import murano.dsl.helpers as helpers
CONF = cfg.CONF
_random_string_counter = None
@ -120,12 +121,12 @@ def _base64decode(value):
@yaql.context.EvalArg('group', types.StringTypes)
@yaql.context.EvalArg('setting', types.StringTypes)
def _config(group, setting):
return cfg.CONF[group][setting]
return CONF[group][setting]
@yaql.context.EvalArg('setting', types.StringTypes)
def _config_default(setting):
return cfg.CONF[setting]
return CONF[setting]
@yaql.context.EvalArg('value', types.StringTypes)

View File

@ -18,6 +18,8 @@ import uuid
import murano.tests.functional.engine.muranomanager as core
CONF = core.CONF
class MuranoBase(core.MuranoTestsCore):
@ -25,8 +27,8 @@ class MuranoBase(core.MuranoTestsCore):
def setUpClass(cls):
super(MuranoBase, cls).setUpClass()
cls.linux = core.CONF.murano.linux_image
cls.flavor = core.CONF.murano.standard_flavor
cls.linux = CONF.murano.linux_image
cls.flavor = CONF.murano.standard_flavor
cls.pkgs_path = os.path.abspath(os.path.join(
os.path.dirname(__file__),

View File

@ -49,6 +49,8 @@ MuranoGroup = [
help="image for windows services")
]
CONF = cfg.CONF
def register_config(config, config_group, config_opts):
@ -62,6 +64,6 @@ def load_config():
path = os.path.join(__location, "config.conf")
if os.path.exists(path):
cfg.CONF([], project='muranointegration', default_config_files=[path])
CONF([], project='muranointegration', default_config_files=[path])
register_config(cfg.CONF, murano_group, MuranoGroup)
register_config(CONF, murano_group, MuranoGroup)

View File

@ -19,11 +19,12 @@ from oslo_config import cfg
from oslo_utils import timeutils
from murano.api.v1 import templates
from murano.common import config
from murano.db import models
import murano.tests.unit.api.base as tb
import murano.tests.unit.utils as test_utils
CONF = cfg.CONF
class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
def setUp(self):
@ -430,7 +431,7 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
cfg.StrOpt('config_file', default='murano.conf'),
cfg.StrOpt('project', default='murano'),
]
config.CONF.register_opts(opts)
CONF.register_opts(opts)
self._set_policy_rules(
{'create_env_template': '@',
'create_environment': '@'}
@ -459,7 +460,7 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
cfg.StrOpt('config_file', default='murano.conf'),
cfg.StrOpt('project', default='murano'),
]
config.CONF.register_opts(opts)
CONF.register_opts(opts)
self._set_policy_rules(
{'create_env_template': '@',
'create_environment': '@'}

View File

@ -20,11 +20,12 @@ from oslo_config import cfg
from oslo_utils import timeutils
from murano.api.v1 import environments
from murano.common import config
from murano.db import models
import murano.tests.unit.api.base as tb
import murano.tests.unit.utils as test_utils
CONF = cfg.CONF
class TestEnvironmentApi(tb.ControllerTest, tb.MuranoApiTestCase):
def setUp(self):
@ -38,7 +39,7 @@ class TestEnvironmentApi(tb.ControllerTest, tb.MuranoApiTestCase):
cfg.StrOpt('config_file', default='murano.conf'),
cfg.StrOpt('project', default='murano'),
]
config.CONF.register_opts(opts)
CONF.register_opts(opts)
def test_list_empty_environments(self):
"""Check that with no environments an empty list is returned."""

View File

@ -19,9 +19,10 @@ from oslo_config import cfg
from murano.api.v1 import environments
from murano.api.v1 import sessions
from murano.common import config
import murano.tests.unit.api.base as tb
CONF = cfg.CONF
class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
def setUp(self):
@ -43,7 +44,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
cfg.StrOpt('config_file', default='murano.conf'),
cfg.StrOpt('project', default='murano'),
]
config.CONF.register_opts(opts)
CONF.register_opts(opts)
self._set_policy_rules(
{'create_environment': '@'}

View File

@ -12,13 +12,13 @@
# limitations under the License.
import fixtures
from oslo_config import cfg
import testtools
from murano.common import config
from murano.db import api as db_api
from murano.openstack.common import log
CONF = cfg.CONF
CONF = config.CONF
log.setup('murano')

View File

@ -12,15 +12,18 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import congressclient
import mock
from oslo_config import cfg
from murano.common import config
from murano.common import engine
from murano.engine import client_manager
from murano.policy import model_policy_enforcer
from murano.tests.unit import base
CONF = cfg.CONF
class TestModelPolicyEnforcer(base.MuranoTestCase):
obj = mock.Mock()
@ -54,7 +57,7 @@ class TestModelPolicyEnforcer(base.MuranoTestCase):
executor = engine.TaskExecutor(self.task)
executor._model_policy_enforcer = mock.Mock()
config.CONF.engine.enable_model_policy_enforcer = False
CONF.engine.enable_model_policy_enforcer = False
executor._validate_model(self.obj, self.task['action'],
self.class_loader)
@ -64,7 +67,7 @@ class TestModelPolicyEnforcer(base.MuranoTestCase):
executor = engine.TaskExecutor(self.task)
executor._model_policy_enforcer = mock.Mock()
config.CONF.engine.enable_model_policy_enforcer = True
CONF.engine.enable_model_policy_enforcer = True
executor._validate_model(self.obj, self.task['action'],
self.class_loader)
@ -109,7 +112,7 @@ class TestModelPolicyEnforcer(base.MuranoTestCase):
executor = engine.TaskExecutor(self.task)
executor._model_policy_enforcer = mock.Mock()
config.CONF.engine.enable_model_policy_enforcer = True
CONF.engine.enable_model_policy_enforcer = True
executor._validate_model(self.obj, {'method': 'not_deploy'},
self.class_loader)