config options: move image_file_url download options

In August 2013 the blueprint "image-multiple-location" got merged
with commit 6f9ed56. This commit introduced another way of
downloading images from glance, despite the normal way via HTTP.
This feature introduced new config options which dynamically generate
new "nova.conf" groups and therefore got never listed in the sample
"nova.conf" file nor in the configuration reference manual.

This change moves these options to "nova/conf/". A follow up change
will deprecate those options as we believe that this feature is never
used in any production environment.

bp centralize-config-options-newton

Change-Id: I140ce486d70e59eaca127d4bc8274c205a2355ee
This commit is contained in:
Markus Zoeller 2016-05-10 15:47:06 +02:00
parent afce1f2c1c
commit 9f6bb41fb4
3 changed files with 32 additions and 20 deletions

View File

@ -29,13 +29,36 @@ filesystems = cfg.ListOpt(
'image_file_url:<list entry name> ' 'image_file_url:<list entry name> '
'sections')) 'sections'))
# NOTE(jbresnah) because the group under which these options are added is
# dyncamically determined these options need to stay out of global space
# or they will confuse generate_sample.sh
filesystem_opts = [
cfg.StrOpt('id',
help=_('A unique ID given to each file system. This is '
'value is set in Glance and agreed upon here so '
'that the operator knowns they are dealing with '
'the same file system.')),
cfg.StrOpt('mountpoint',
help=_('The path at which the file system is mounted.')),
]
ALL_OPTS = [filesystems] ALL_OPTS = [filesystems]
def register_opts(conf): def register_opts(conf):
conf.register_group(image_file_url_group) conf.register_group(image_file_url_group)
conf.register_opts(ALL_OPTS, group=image_file_url_group) conf.register_opts(ALL_OPTS, group=image_file_url_group)
for fs in conf.image_file_url.filesystems:
group_name = 'image_file_url:' + fs
conf.register_opts(filesystem_opts, group=group_name)
def list_opts(): def list_opts():
# NOTE(markus_z): As the "filesystem" opt has an empty list as a default
# value and this value is necessary for a correct group name, we cannot
# list the "filesystem_opts" for the "nova.conf.sample" file here. A
# follow up patch will deprecate those. Due to their dynamic creation
# they never got shown in "nova.conf.sample" nor the config reference
# manual. I see no need to change this here with a dummy group or somehing
# like that.
return {image_file_url_group: ALL_OPTS} return {image_file_url_group: ALL_OPTS}

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import nova.conf import nova.conf
@ -63,19 +62,6 @@ class FileTransfer(xfer_base.TransferBase):
desc_required_keys = ['id', 'mountpoint'] desc_required_keys = ['id', 'mountpoint']
# NOTE(jbresnah) because the group under which these options are added is
# dyncamically determined these options need to stay out of global space
# or they will confuse generate_sample.sh
filesystem_opts = [
cfg.StrOpt('id',
help=_('A unique ID given to each file system. This is '
'value is set in Glance and agreed upon here so '
'that the operator knowns they are dealing with '
'the same file system.')),
cfg.StrOpt('mountpoint',
help=_('The path at which the file system is mounted.')),
]
def _get_options(self): def _get_options(self):
fs_dict = {} fs_dict = {}
for fs in CONF.image_file_url.filesystems: for fs in CONF.image_file_url.filesystems:
@ -89,12 +75,6 @@ class FileTransfer(xfer_base.TransferBase):
fs_dict[CONF[group_name].id] = CONF[group_name] fs_dict[CONF[group_name].id] = CONF[group_name]
return fs_dict return fs_dict
def __init__(self):
# create the needed options
for fs in CONF.image_file_url.filesystems:
group_name = 'image_file_url:' + fs
CONF.register_opts(self.filesystem_opts, group=group_name)
def _verify_config(self): def _verify_config(self):
for fs_key in self.filesystems: for fs_key in self.filesystems:
for r in self.desc_required_keys: for r in self.desc_required_keys:

View File

@ -16,10 +16,13 @@
import mock import mock
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
import nova.conf
from nova import exception from nova import exception
from nova.image.download import file as tm_file from nova.image.download import file as tm_file
from nova import test from nova import test
CONF = nova.conf.CONF
class TestFileTransferModule(test.NoDBTestCase): class TestFileTransferModule(test.NoDBTestCase):
@ -27,6 +30,8 @@ class TestFileTransferModule(test.NoDBTestCase):
def test_filesystem_success(self, copy_mock): def test_filesystem_success(self, copy_mock):
self.flags(allowed_direct_url_schemes=['file'], group='glance') self.flags(allowed_direct_url_schemes=['file'], group='glance')
self.flags(group='image_file_url', filesystems=['gluster']) self.flags(group='image_file_url', filesystems=['gluster'])
# register opts for dynamically created group 'image_file_url:gluster'
nova.conf.image_file_url.register_opts(CONF)
mountpoint = '/gluster' mountpoint = '/gluster'
url = 'file:///gluster/my/image/path' url = 'file:///gluster/my/image/path'
@ -52,6 +57,8 @@ class TestFileTransferModule(test.NoDBTestCase):
def test_filesystem_mismatched_mountpoint(self, copy_mock): def test_filesystem_mismatched_mountpoint(self, copy_mock):
self.flags(allowed_direct_url_schemes=['file'], group='glance') self.flags(allowed_direct_url_schemes=['file'], group='glance')
self.flags(group='image_file_url', filesystems=['gluster']) self.flags(group='image_file_url', filesystems=['gluster'])
# register opts for dynamically created group 'image_file_url:gluster'
nova.conf.image_file_url.register_opts(CONF)
mountpoint = '/gluster' mountpoint = '/gluster'
# Should include the mountpoint before my/image/path # Should include the mountpoint before my/image/path
@ -78,6 +85,8 @@ class TestFileTransferModule(test.NoDBTestCase):
def test_filesystem_mismatched_filesystem(self, copy_mock): def test_filesystem_mismatched_filesystem(self, copy_mock):
self.flags(allowed_direct_url_schemes=['file'], group='glance') self.flags(allowed_direct_url_schemes=['file'], group='glance')
self.flags(group='image_file_url', filesystems=['gluster']) self.flags(group='image_file_url', filesystems=['gluster'])
# register opts for dynamically created group 'image_file_url:gluster'
nova.conf.image_file_url.register_opts(CONF)
mountpoint = '/gluster' mountpoint = '/gluster'
# Should include the mountpoint before my/image/path # Should include the mountpoint before my/image/path