config options: Centralise 'utils' options

Add options from 'utils'. These options affect the entire system so
they have been included in the "nova.conf.base" file.

Change-Id: I8f454ead0f4a88aeebe3883591cef80c567170c2
Implements: bp centralize-config-options-newton
This commit is contained in:
Stephen Finucane 2016-03-29 14:56:36 +01:00
parent 386d45eec7
commit f3a90a97b2
12 changed files with 80 additions and 47 deletions

View File

@ -24,7 +24,7 @@ from oslo_config import cfg
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 base
from nova.conf import cells
from nova.conf import cert
# from nova.conf import cinder
@ -87,7 +87,7 @@ CONF = cfg.CONF
availability_zone.register_opts(CONF)
# aws.register_opts(CONF)
barbican.register_opts(CONF)
# base.register_opts(CONF)
base.register_opts(CONF)
cells.register_opts(CONF)
cert.register_opts(CONF)
# cinder.register_opts(CONF)

62
nova/conf/base.py Normal file
View File

@ -0,0 +1,62 @@
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 Justin Santa Barbara
# 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
password_length = cfg.IntOpt(
'password_length',
default=12,
help='Length of generated instance admin passwords')
instance_usage_audit_period = cfg.StrOpt(
'instance_usage_audit_period',
default='month',
help='Time period to generate instance usages for. '
'Time period must be hour, day, month or year')
use_rootwrap_daemon = cfg.BoolOpt(
'use_rootwrap_daemon',
default=False,
help="Start and use a daemon that can run the commands that "
"need to be run with root privileges. This option is "
"usually enabled on nodes that run nova compute "
"processes")
rootwrap_config = cfg.StrOpt('rootwrap_config',
default="/etc/nova/rootwrap.conf",
help='Path to the rootwrap configuration file to use for '
'running commands as root')
tempdir = cfg.StrOpt(
'tempdir',
help='Explicitly specify the temporary working directory')
ALL_OPTS = [
password_length,
instance_usage_audit_period,
use_rootwrap_daemon,
rootwrap_config,
tempdir]
def register_opts(conf):
conf.register_opts(ALL_OPTS)
def list_opts():
return {'DEFAULT': ALL_OPTS}

View File

@ -64,7 +64,6 @@ def list_opts():
nova.paths.path_opts,
nova.quota.quota_opts,
nova.utils.monkey_patch_opts,
nova.utils.utils_opts,
nova.volume._volume_opts,
)),
('cinder', nova.volume.cinder.cinder_opts),

View File

@ -23,7 +23,6 @@ import uuid
import iso8601
import mock
from oslo_config import cfg
from oslo_policy import policy as oslo_policy
from oslo_serialization import jsonutils
from oslo_utils import timeutils
@ -41,6 +40,7 @@ from nova.compute import api as compute_api
from nova.compute import flavors
from nova.compute import task_states
from nova.compute import vm_states
import nova.conf
from nova import context
from nova import db
from nova.db.sqlalchemy import models
@ -59,8 +59,7 @@ from nova.tests.unit import matchers
from nova.tests.unit.objects import test_keypair
from nova import utils as nova_utils
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
FAKE_UUID = fakes.FAKE_UUID
NS = "{http://docs.openstack.org/compute/api/v1.1}"

View File

@ -15,7 +15,6 @@
import uuid
import mock
from oslo_config import cfg
import testtools
import webob
@ -25,14 +24,14 @@ from nova.api.openstack.compute.legacy_v2.contrib import evacuate \
from nova.api.openstack import extensions
from nova.compute import api as compute_api
from nova.compute import vm_states
import nova.conf
from nova import exception
from nova import test
from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import fake_instance
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
def fake_compute_api(*args, **kwargs):

View File

@ -13,17 +13,16 @@
# under the License.
import mock
from oslo_config import cfg
from nova.api.openstack import common
from nova.api.openstack.compute.legacy_v2.contrib import rescue
from nova.api.openstack import extensions
from nova import compute
import nova.conf
import nova.context as context
from nova import test
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
class FakeRequest(object):

View File

@ -15,7 +15,6 @@
import datetime
from oslo_config import cfg
import webob
from nova.api.openstack.compute import block_device_mapping \
@ -27,6 +26,7 @@ from nova.api.openstack.compute import servers as servers_v21
from nova.api.openstack import extensions as extensions_v20
from nova.compute import api as compute_api
from nova.compute import flavors
import nova.conf
from nova import exception
from nova.network import manager
from nova import test
@ -34,7 +34,7 @@ from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import fake_instance
from nova.tests.unit.image import fake
CONF = cfg.CONF
CONF = nova.conf.CONF
def return_security_group(context, instance_id, security_group_id):

View File

@ -13,19 +13,18 @@
# under the License.
import mock
from oslo_config import cfg
import webob
from nova.api.openstack.compute.legacy_v2.contrib import rescue as rescue_v2
from nova.api.openstack.compute import rescue as rescue_v21
from nova.api.openstack import extensions
from nova import compute
import nova.conf
from nova import exception
from nova import test
from nova.tests.unit.api.openstack import fakes
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
UUID = '70f6db34-de8d-4fbd-aafb-4065bdfa6114'

View File

@ -18,7 +18,6 @@ import uuid
import mock
from mox3 import mox
from oslo_config import cfg
from oslo_policy import policy as oslo_policy
from oslo_utils import uuidutils
import webob
@ -29,6 +28,7 @@ from nova.api.openstack.compute import servers as servers_v21
from nova.compute import api as compute_api
from nova.compute import task_states
from nova.compute import vm_states
import nova.conf
from nova import exception
from nova.image import glance
from nova import objects
@ -39,8 +39,7 @@ from nova.tests.unit import fake_block_device
from nova.tests.unit import fake_instance
from nova.tests.unit.image import fake
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
FAKE_UUID = fakes.FAKE_UUID
INSTANCE_IDS = {FAKE_UUID: 1}

View File

@ -24,7 +24,6 @@ import fixtures
import iso8601
import mock
from mox3 import mox
from oslo_config import cfg
from oslo_policy import policy as oslo_policy
from oslo_serialization import jsonutils
from oslo_utils import timeutils
@ -50,6 +49,7 @@ from nova.compute import api as compute_api
from nova.compute import flavors
from nova.compute import task_states
from nova.compute import vm_states
import nova.conf
from nova import context
from nova import db
from nova.db.sqlalchemy import models
@ -67,8 +67,7 @@ from nova.tests.unit.image import fake
from nova.tests.unit import matchers
from nova import utils as nova_utils
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
FAKE_UUID = fakes.FAKE_UUID

View File

@ -17,7 +17,6 @@
import datetime
import mock
from oslo_config import cfg
from oslo_serialization import jsonutils
from six.moves import urllib
import webob
@ -34,6 +33,7 @@ from nova.api.openstack import extensions
from nova.compute import api as compute_api
from nova.compute import flavors
from nova.compute import vm_states
import nova.conf
from nova import context
from nova import exception
from nova import objects
@ -43,8 +43,7 @@ from nova.tests.unit import fake_block_device
from nova.tests.unit import fake_instance
from nova.volume import cinder
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF = nova.conf.CONF
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
FAKE_UUID_A = '00000000-aaaa-aaaa-aaaa-000000000000'

View File

@ -74,31 +74,10 @@ monkey_patch_opts = [
],
help='List of modules/decorators to monkey patch'),
]
utils_opts = [
cfg.IntOpt('password_length',
default=12,
help='Length of generated instance admin passwords'),
cfg.StrOpt('instance_usage_audit_period',
default='month',
help='Time period to generate instance usages for. '
'Time period must be hour, day, month or year'),
cfg.BoolOpt('use_rootwrap_daemon', default=False,
help="Start and use a daemon that can run the commands that "
"need to be run with root privileges. This option is "
"usually enabled on nodes that run nova compute "
"processes"),
cfg.StrOpt('rootwrap_config',
default="/etc/nova/rootwrap.conf",
help='Path to the rootwrap configuration file to use for '
'running commands as root'),
cfg.StrOpt('tempdir',
help='Explicitly specify the temporary working directory'),
]
CONF = nova.conf.CONF
CONF.register_opts(monkey_patch_opts)
CONF.register_opts(utils_opts)
LOG = logging.getLogger(__name__)