config options: centralize section: "glance"

The config options  of the "nova.conf" section "glance"
got moved to the new central location "nova/conf/glance.py".

Change-Id: I4e608a985d4d787e19ef21a7fc506c1df67a982e
Implements: blueprint centralize-config-options-newton
This commit is contained in:
Kevin_Zheng
2015-12-14 14:27:32 +08:00
parent 7b032f5339
commit 178a5cb755
6 changed files with 66 additions and 42 deletions

View File

@@ -40,7 +40,7 @@ from nova.conf import conductor
# from nova.conf import disk
from nova.conf import ephemeral_storage
from nova.conf import floating_ips
# from nova.conf import glance
from nova.conf import glance
# from nova.conf import guestfs
# from nova.conf import host
from nova.conf import hyperv
@@ -101,7 +101,7 @@ conductor.register_opts(CONF)
# disk.register_opts(CONF)
ephemeral_storage.register_opts(CONF)
floating_ips.register_opts(CONF)
# glance.register_opts(CONF)
glance.register_opts(CONF)
# guestfs.register_opts(CONF)
# host.register_opts(CONF)
hyperv.register_opts(CONF)

57
nova/conf/glance.py Normal file
View File

@@ -0,0 +1,57 @@
# 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
glance_group = cfg.OptGroup(
'glance',
title='Glance Options')
glance_opts = [
# NOTE(sdague): there is intentionally no default here. This
# requires configuration. Eventually this will come from the
# service catalog, however we don't have a good path there atm.
cfg.ListOpt('api_servers',
help='''
A list of the glance api servers endpoints available to nova. These
should be fully qualified urls of the form
"scheme://hostname:port[/path]" (i.e. "http://10.0.1.0:9292" or
"https://my.glance.server/image")'''),
cfg.BoolOpt('api_insecure',
default=False,
help='Allow to perform insecure SSL (https) requests to '
'glance'),
cfg.IntOpt('num_retries',
default=0,
help='Number of retries when uploading / downloading an image '
'to / from glance.'),
cfg.ListOpt('allowed_direct_url_schemes',
default=[],
help='A list of url scheme that can be downloaded directly '
'via the direct_url. Currently supported schemes: '
'[file].'),
cfg.BoolOpt('verify_glance_signatures',
default=False,
help='Require Nova to perform signature verification on '
'each image downloaded from Glance.'),
]
def register_opts(conf):
conf.register_group(glance_group)
conf.register_opts(glance_opts, group=glance_group)
def list_opts():
return {glance_group: glance_opts}

View File

@@ -28,7 +28,6 @@ import cryptography
import glanceclient
from glanceclient.common import http
import glanceclient.exc
from oslo_config import cfg
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_service import sslutils
@@ -38,45 +37,15 @@ import six
from six.moves import range
import six.moves.urllib.parse as urlparse
import nova.conf
from nova import exception
from nova.i18n import _LE, _LI, _LW
import nova.image.download as image_xfers
from nova import objects
from nova import signature_utils
glance_opts = [
# NOTE(sdague): there is intentionally no default here. This
# requires configuration. Eventually this will come from the
# service catalog, however we don't have a good path there atm.
cfg.ListOpt('api_servers',
help='''
A list of the glance api servers endpoints available to nova. These
should be fully qualified urls of the form
"scheme://hostname:port[/path]" (i.e. "http://10.0.1.0:9292" or
"https://my.glance.server/image")'''),
cfg.BoolOpt('api_insecure',
default=False,
help='Allow to perform insecure SSL (https) requests to '
'glance'),
cfg.IntOpt('num_retries',
default=0,
help='Number of retries when uploading / downloading an image '
'to / from glance.'),
cfg.ListOpt('allowed_direct_url_schemes',
default=[],
help='A list of url scheme that can be downloaded directly '
'via the direct_url. Currently supported schemes: '
'[file].'),
cfg.BoolOpt('verify_glance_signatures',
default=False,
help='Require Nova to perform signature verification on '
'each image downloaded from Glance.'),
]
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.register_opts(glance_opts, 'glance')
CONF = nova.conf.CONF
CONF.import_opt('auth_strategy', 'nova.api.auth')
supported_glance_versions = (1, 2)

View File

@@ -33,7 +33,6 @@ import nova.db.base
import nova.db.sqlalchemy.api
import nova.exception
import nova.image.download.file
import nova.image.glance
import nova.ipv6.api
import nova.netconf
import nova.notifications
@@ -80,7 +79,6 @@ def list_opts():
('cinder', nova.volume.cinder.cinder_opts),
('api_database', nova.db.sqlalchemy.api.api_db_opts),
('database', nova.db.sqlalchemy.api.oslo_db_options.database_opts),
('glance', nova.image.glance.glance_opts),
('image_file_url', [nova.image.download.file.opt_group]),
('spice',
itertools.chain(

View File

@@ -20,17 +20,18 @@ from six.moves import StringIO
import cryptography
import glanceclient.exc
import mock
from oslo_config import cfg
from oslo_service import sslutils
import six
import testtools
import nova.conf
from nova import context
from nova import exception
from nova.image import glance
from nova import test
CONF = cfg.CONF
CONF = nova.conf.CONF
NOW_GLANCE_FORMAT = "2010-10-11T10:30:22.000000"

View File

@@ -16,18 +16,17 @@
import functools
import sys
from oslo_config import cfg
from oslo_log import log as logging
import six
from nova.compute import utils as compute_utils
import nova.conf
from nova import exception
from nova.image import glance
from nova import utils
from nova.virt.xenapi import vm_utils
CONF = cfg.CONF
CONF.import_opt('num_retries', 'nova.image.glance', group='glance')
CONF = nova.conf.CONF
LOG = logging.getLogger(__name__)