diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 79a0b5166e34..b79eee92289c 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -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) diff --git a/nova/conf/glance.py b/nova/conf/glance.py new file mode 100644 index 000000000000..9d70be52d09b --- /dev/null +++ b/nova/conf/glance.py @@ -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} diff --git a/nova/image/glance.py b/nova/image/glance.py index c30fe6edc335..2ab46a947ec7 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -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) diff --git a/nova/opts.py b/nova/opts.py index 9cf184236b39..92aea0c5bb05 100644 --- a/nova/opts.py +++ b/nova/opts.py @@ -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( diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py index b0c339803047..b70bb1a34410 100644 --- a/nova/tests/unit/image/test_glance.py +++ b/nova/tests/unit/image/test_glance.py @@ -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" diff --git a/nova/virt/xenapi/image/glance.py b/nova/virt/xenapi/image/glance.py index 3a368acb9183..6e0454c3230b 100644 --- a/nova/virt/xenapi/image/glance.py +++ b/nova/virt/xenapi/image/glance.py @@ -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__)