Merge "config options: move image_file_url download options"

This commit is contained in:
Jenkins
2016-05-17 06:31:13 +00:00
committed by Gerrit Code Review
3 changed files with 32 additions and 20 deletions

View File

@ -29,13 +29,36 @@ filesystems = cfg.ListOpt(
'image_file_url:<list entry name> '
'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]
def register_opts(conf):
conf.register_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():
# 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}

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
import nova.conf
@ -63,19 +62,6 @@ class FileTransfer(xfer_base.TransferBase):
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):
fs_dict = {}
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]
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):
for fs_key in self.filesystems:
for r in self.desc_required_keys:

View File

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