Add upgrade check for Windows iSCSI driver.
The WindowsDriver was renamed in the Queens release to WindowsISCSIDriver to avoid confusion with the SMB driver. The backwards compatibility for this has now been removed, so any cinder.conf settings still using cinder.volume.drivers.windows.windows.WindowsDriver must now be updated to use cinder.volume.drivers.windows.iscsi.WindowsISCSIDriver. The change includes the addtion of a function to get the enabled_drivers for a system as it is likely that the functionality will be useful for multiple update checks in the future. Change-Id: I34038c847b75f9f9bd1c4dd4d9a5803cd66ffc8d
This commit is contained in:
parent
ce4ff68c8d
commit
bc18906f01
@ -18,12 +18,20 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from cinder import objects
|
||||
from cinder import service # noqa
|
||||
from oslo_config import cfg
|
||||
from oslo_upgradecheck import upgradecheck as uc
|
||||
|
||||
from cinder.policy import DEFAULT_POLICY_FILENAME
|
||||
import cinder.service # noqa
|
||||
|
||||
# We must first register Cinder's objects. Otherwise
|
||||
# we cannot import the volume manager.
|
||||
objects.register_all()
|
||||
|
||||
import cinder.volume.manager as volume_manager
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
SUCCESS = uc.Code.SUCCESS
|
||||
@ -31,6 +39,20 @@ FAILURE = uc.Code.FAILURE
|
||||
WARNING = uc.Code.WARNING
|
||||
|
||||
|
||||
def _get_enabled_drivers():
|
||||
"""Returns a list of volume_driver entries"""
|
||||
volume_drivers = []
|
||||
if CONF.enabled_backends:
|
||||
for backend in filter(None, CONF.enabled_backends):
|
||||
# Each backend group needs to be registered first
|
||||
CONF.register_opts(volume_manager.volume_backend_opts,
|
||||
group=backend)
|
||||
volume_driver = CONF[backend]['volume_driver']
|
||||
volume_drivers.append(volume_driver)
|
||||
|
||||
return volume_drivers
|
||||
|
||||
|
||||
class Checks(uc.UpgradeCommands):
|
||||
"""Upgrade checks to run."""
|
||||
|
||||
@ -151,10 +173,35 @@ class Checks(uc.UpgradeCommands):
|
||||
|
||||
return uc.Result(SUCCESS)
|
||||
|
||||
def _check_legacy_windows_config(self):
|
||||
"""Checks to ensure that the Windows driver path is properly updated.
|
||||
|
||||
The WindowsDriver was renamed in the Queens release to
|
||||
WindowsISCSIDriver to avoid confusion with the SMB driver.
|
||||
The backwards compatibility for this has now been removed, so
|
||||
any cinder.conf settings still using
|
||||
cinder.volume.drivers.windows.windows.WindowsDriver
|
||||
must now be updated to use
|
||||
cinder.volume.drivers.windows.iscsi.WindowsISCSIDriver.
|
||||
"""
|
||||
for volume_driver in _get_enabled_drivers():
|
||||
if (volume_driver ==
|
||||
"cinder.volume.drivers.windows.windows.WindowsDriver"):
|
||||
return uc.Result(
|
||||
FAILURE,
|
||||
'Setting volume_driver to '
|
||||
'cinder.volume.drivers.windows.windows.WindowsDriver '
|
||||
'is no longer supported. Please update to use '
|
||||
'cinder.volume.drivers.windows.iscsi.WindowsISCSIDriver '
|
||||
'in cinder.conf.')
|
||||
|
||||
return uc.Result(SUCCESS)
|
||||
|
||||
_upgrade_checks = (
|
||||
# added in Stein
|
||||
('Backup Driver Path', _check_backup_module),
|
||||
('Use of Policy File', _check_policy_file),
|
||||
('Windows Driver Path', _check_legacy_windows_config),
|
||||
# added in Train
|
||||
('Periodic Interval Use', _check_periodic_interval),
|
||||
('Use of Nest Quota Driver', _check_nested_quota),
|
||||
|
@ -20,6 +20,8 @@ import testtools
|
||||
|
||||
from cinder.cmd import status
|
||||
|
||||
import cinder.volume.manager as volume_manager
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@ -48,6 +50,16 @@ class TestCinderStatus(testtools.TestCase):
|
||||
CONF.set_override(key, value, group=group)
|
||||
self.addCleanup(CONF.clear_override, key, group=group)
|
||||
|
||||
def _set_volume_driver(self, volume_driver, enabled_backend):
|
||||
CONF.register_opts(volume_manager.volume_backend_opts,
|
||||
group=enabled_backend)
|
||||
CONF.set_override('enabled_backends', enabled_backend)
|
||||
CONF.set_override('volume_driver', volume_driver,
|
||||
group=enabled_backend)
|
||||
self.addCleanup(CONF.clear_override, 'volume_driver',
|
||||
group=enabled_backend)
|
||||
self.addCleanup(CONF.clear_override, 'enabled_backends')
|
||||
|
||||
def test_check_backup_module(self):
|
||||
self._set_config(
|
||||
'backup_driver',
|
||||
@ -123,3 +135,23 @@ class TestCinderStatus(testtools.TestCase):
|
||||
else:
|
||||
expected = uc.Code.WARNING
|
||||
self.assertEqual(expected, result.code)
|
||||
|
||||
def test_check_legacy_win_conf(self):
|
||||
self._set_volume_driver(
|
||||
'cinder.volume.drivers.windows.iscsi.WindowsISCSIDriver',
|
||||
'winiscsi')
|
||||
result = self.checks._check_legacy_windows_config()
|
||||
self.assertEqual(uc.Code.SUCCESS, result.code)
|
||||
|
||||
def test_check_legacy_win_conf_fail(self):
|
||||
self._set_volume_driver(
|
||||
'cinder.volume.drivers.windows.windows.WindowsDriver',
|
||||
'winiscsi')
|
||||
result = self.checks._check_legacy_windows_config()
|
||||
self.assertEqual(uc.Code.FAILURE, result.code)
|
||||
self.assertIn('Please update to use', result.details)
|
||||
|
||||
def test_check_legacy_win_conf_no_drivers(self):
|
||||
self._set_config('enabled_backends', None)
|
||||
result = self.checks._check_legacy_windows_config()
|
||||
self.assertEqual(uc.Code.SUCCESS, result.code)
|
||||
|
@ -89,6 +89,7 @@ Upgrade
|
||||
class path and not just the module path.
|
||||
* Checks for the presence of a **policy.json** file have been added to warn
|
||||
if policy changes should be present in a **policy.yaml** file.
|
||||
* Ensure that correct volume_driver path is used for Windows iSCSI driver.
|
||||
|
||||
**15.0.0 (Train)**
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
A new check is added to the ``cinder-status upgrade check`` CLI to check
|
||||
for the use of ``cinder.volume.drivers.windows.windows.WindowsDriver``
|
||||
and a message is reported that the user needs to update the setting
|
||||
to ``cinder.volume.drivers.windows.iscsi.WindowsISCSIDriver`` if
|
||||
it is encountered.
|
Loading…
Reference in New Issue
Block a user