From 466bce576a69d170f1ef08264da7e72ac4a150fb Mon Sep 17 00:00:00 2001 From: Hieu LE Date: Thu, 12 May 2016 12:29:20 +0700 Subject: [PATCH] Config options: centralize cache options The config options of the "nova.conf" section "cache" got moved to the new central location "nova/conf/cache.py". Change-Id: I1b7aebb9f7d44ff8312b98c88093bf01f44dfa58 Implements: blueprint centralize-config-options-newton --- etc/nova/nova-config-generator.conf | 1 - nova/cache_utils.py | 4 ++-- nova/conf/__init__.py | 2 ++ nova/conf/cache.py | 26 ++++++++++++++++++++++++++ nova/config.py | 2 -- 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 nova/conf/cache.py diff --git a/etc/nova/nova-config-generator.conf b/etc/nova/nova-config-generator.conf index 931d8b456d..090caedabb 100644 --- a/etc/nova/nova-config-generator.conf +++ b/etc/nova/nova-config-generator.conf @@ -7,7 +7,6 @@ namespace = nova.api namespace = nova.cells namespace = nova.compute namespace = nova.network -namespace = oslo.cache namespace = oslo.log namespace = oslo.messaging namespace = oslo.policy diff --git a/nova/cache_utils.py b/nova/cache_utils.py index a4eb02f41d..bc0851c4cb 100644 --- a/nova/cache_utils.py +++ b/nova/cache_utils.py @@ -17,12 +17,12 @@ """Super simple fake memcache client.""" from oslo_cache import core as cache -from oslo_config import cfg +import nova.conf from nova.i18n import _ -CONF = cfg.CONF +CONF = nova.conf.CONF WEEK = 604800 diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 416d647790..cc47da8a70 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -25,6 +25,7 @@ from nova.conf import availability_zone # from nova.conf import aws from nova.conf import barbican from nova.conf import base +from nova.conf import cache from nova.conf import cells from nova.conf import cert from nova.conf import cinder @@ -97,6 +98,7 @@ availability_zone.register_opts(CONF) # aws.register_opts(CONF) barbican.register_opts(CONF) base.register_opts(CONF) +cache.register_opts(CONF) cells.register_opts(CONF) cert.register_opts(CONF) cinder.register_opts(CONF) diff --git a/nova/conf/cache.py b/nova/conf/cache.py new file mode 100644 index 0000000000..cccabf7d7d --- /dev/null +++ b/nova/conf/cache.py @@ -0,0 +1,26 @@ +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# Copyright 2016 OpenStack Foundation +# All Rights Reserved. +# +# 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 oslo_cache import core + + +def register_opts(conf): + core.configure(conf) + + +def list_opts(): + return core._opts.list_opts() diff --git a/nova/config.py b/nova/config.py index ff25628c6e..ed637a453e 100644 --- a/nova/config.py +++ b/nova/config.py @@ -15,7 +15,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_cache import core as cache from oslo_db import options from oslo_log import log @@ -44,7 +43,6 @@ def parse_args(argv, default_config_files=None, configure_db=True, options.set_defaults(CONF, connection=_DEFAULT_SQL_CONNECTION, sqlite_db='nova.sqlite') rpc.set_defaults(control_exchange='nova') - cache.configure(CONF) config.set_middleware_defaults() CONF(argv[1:],