From 88703e1c87b8eb8b29ab3d39bcc9d7c822e26706 Mon Sep 17 00:00:00 2001 From: Markus Zoeller Date: Mon, 9 May 2016 15:38:28 +0200 Subject: [PATCH] config options: centralize default flavor option The default flavor was introduced for the ec2 API. That API is deprecated and this option is not used in functional code anymore but in unit tests. A follow up patch will deprecate this option. In the next cycle we can then remove it. I've put the option to its own module to avoid merge conflicts with the nova.conf.compute module. As this option was the last one for the "oslo.config" generator namespace "nova.compute", the generator file was changed too and the nova.compute.ops module was deleted. blueprint centralize-config-options-newton Change-Id: Ie2be972673498ef984dfd3b5164512d77ef85ace --- etc/nova/nova-config-generator.conf | 1 - nova/compute/flavors.py | 12 ++--------- nova/compute/opts.py | 23 --------------------- nova/conf/__init__.py | 2 ++ nova/conf/flavors.py | 32 +++++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 34 deletions(-) delete mode 100644 nova/compute/opts.py create mode 100644 nova/conf/flavors.py diff --git a/etc/nova/nova-config-generator.conf b/etc/nova/nova-config-generator.conf index e51e18ba6d34..045f93065ef5 100644 --- a/etc/nova/nova-config-generator.conf +++ b/etc/nova/nova-config-generator.conf @@ -6,7 +6,6 @@ namespace = nova.conf namespace = nova.api namespace = nova.cache_utils namespace = nova.cells -namespace = nova.compute namespace = nova.network namespace = oslo.cache namespace = oslo.log diff --git a/nova/compute/flavors.py b/nova/compute/flavors.py index b443d73f7122..ded0e3505507 100644 --- a/nova/compute/flavors.py +++ b/nova/compute/flavors.py @@ -21,12 +21,12 @@ import re import uuid -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import strutils import six from nova.api.validation import parameter_types +import nova.conf from nova import context from nova import db from nova import exception @@ -35,15 +35,7 @@ from nova.i18n import _LE from nova import objects from nova import utils -flavor_opts = [ - cfg.StrOpt('default_flavor', - default='m1.small', - help='Default flavor to use for the EC2 API only. The Nova API ' - 'does not support a default flavor.'), -] - -CONF = cfg.CONF -CONF.register_opts(flavor_opts) +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) diff --git a/nova/compute/opts.py b/nova/compute/opts.py deleted file mode 100644 index cfc3e76e1a6f..000000000000 --- a/nova/compute/opts.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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. - -import nova.compute.flavors -import nova.compute.monitors -import nova.conf - - -def list_opts(): - return [ - ('DEFAULT', - nova.compute.flavors.flavor_opts, - ), - ] diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 416d64779087..2dd72163b52c 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -40,6 +40,7 @@ from nova.conf import crypto # from nova.conf import database # from nova.conf import disk from nova.conf import ephemeral_storage +from nova.conf import flavors from nova.conf import floating_ips from nova.conf import glance from nova.conf import guestfs @@ -113,6 +114,7 @@ crypto.register_opts(CONF) # disk.register_opts(CONF) ephemeral_storage.register_opts(CONF) floating_ips.register_opts(CONF) +flavors.register_opts(CONF) glance.register_opts(CONF) guestfs.register_opts(CONF) # host.register_opts(CONF) diff --git a/nova/conf/flavors.py b/nova/conf/flavors.py new file mode 100644 index 000000000000..d79f09e44944 --- /dev/null +++ b/nova/conf/flavors.py @@ -0,0 +1,32 @@ +# 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_config import cfg + + +flavor_opts = [ + cfg.StrOpt('default_flavor', + default='m1.small', + help='Default flavor to use for the EC2 API only. The Nova API ' + 'does not support a default flavor.'), +] + + +def register_opts(conf): + conf.register_opts(flavor_opts) + + +def list_opts(): + return {'DEFAULT': flavor_opts}