Fix driver mode opt definition

Share driver mode opt should be StrOpt, but now it is ListOpt. We get driver
mode validation error when option is redefined within external config file.
It can not be caught by update of config opt within code.

Change-Id: I77cab322beba7ec2258e106eebf631c081cfebe5
Closes-Bug: #1403952
This commit is contained in:
Valeriy Ponomaryov 2014-12-18 19:58:57 +02:00
parent 28f311c9ad
commit 397950e1e9
2 changed files with 17 additions and 1 deletions

View File

@ -53,7 +53,7 @@ share_opts = [
"If not set, the share backend's config group will be used."
"If an option is not found within provided group, then"
"'DEFAULT' group will be used for search of option."),
cfg.ListOpt(
cfg.StrOpt(
'share_driver_mode',
default=None,
help="One specific mode for driver to use. Available values: "

View File

@ -15,6 +15,7 @@
# under the License.
"""Unit tests for the Share driver module."""
import os
import time
import mock
@ -55,6 +56,21 @@ class ShareDriverTestCase(test.TestCase):
self.assertRaises(exception.ProcessExecutionError,
execute_mixin._try_execute)
def test_verify_share_driver_mode_option_type(self):
with utils.tempdir() as tmpdir:
tmpfilename = os.path.join(tmpdir, 'share_driver_mode.conf')
with open(tmpfilename, "w") as configfile:
configfile.write("""[DEFAULT]\nshare_driver_mode = fake""")
# Add config file with updated opt
driver.CONF.default_config_files = [configfile.name]
# Reload config instance to use redefined opt
driver.CONF.reload_config_files()
share_driver = driver.ShareDriver()
self.assertEqual('fake', share_driver.mode)
def _instantiate_share_driver(self, network_config_group):
self.stubs.Set(network, 'API', mock.Mock())
config = mock.Mock()