Fix get_driver_options
Any new Cinder driver we add that doesn't have the "get_driver_options" method defined will break the driver list generation tools. The reason why it breaks them is because this method must be static, yet our base driver class doesn't define it as static. This patch: - Sets the base method as static to prevent new drivers from breaking the tools. - Documents the existence of this method for driver developers. - Adds get_driver_options method for drivers that are missing it. - Fix macrosan_client help message that breaks the doc building process. Closes-Bug: #1838225 Change-Id: I4797724d7b55709f0903d522b0233242b867146d
This commit is contained in:
parent
fa08588969
commit
2f0bd74604
59
cinder/tests/unit/test_interface.py
Normal file
59
cinder/tests/unit/test_interface.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# Copyright (c) 2019, Red Hat, Inc.
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from cinder.interface import util
|
||||||
|
from cinder import test
|
||||||
|
|
||||||
|
|
||||||
|
class GetDriversTestCase(test.TestCase):
|
||||||
|
def test_get_volume_drivers(self):
|
||||||
|
# Just ensure that it doesn't raise an exception
|
||||||
|
drivers = util.get_volume_drivers()
|
||||||
|
self.assertNotEqual(0, len(drivers))
|
||||||
|
for driver in drivers:
|
||||||
|
self.assertIsInstance(driver, util.DriverInfo)
|
||||||
|
|
||||||
|
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.get_driver_options')
|
||||||
|
def test_get_volume_drivers_fail(self, driver_opt):
|
||||||
|
driver_opt.side_effect = ValueError
|
||||||
|
self.assertRaises(ValueError, util.get_volume_drivers)
|
||||||
|
|
||||||
|
def test_get_backup_drivers(self):
|
||||||
|
# Just ensure that it doesn't raise an exception
|
||||||
|
drivers = util.get_backup_drivers()
|
||||||
|
self.assertNotEqual(0, len(drivers))
|
||||||
|
for driver in drivers:
|
||||||
|
self.assertIsInstance(driver, util.DriverInfo)
|
||||||
|
|
||||||
|
@mock.patch('cinder.backup.drivers.ceph.CephBackupDriver.'
|
||||||
|
'get_driver_options')
|
||||||
|
def test_get_backup_drivers_fail(self, driver_opt):
|
||||||
|
driver_opt.side_effect = ValueError
|
||||||
|
self.assertRaises(ValueError, util.get_backup_drivers)
|
||||||
|
|
||||||
|
def test_get_fczm_drivers(self):
|
||||||
|
# Just ensure that it doesn't raise an exception
|
||||||
|
drivers = util.get_fczm_drivers()
|
||||||
|
self.assertNotEqual(0, len(drivers))
|
||||||
|
for driver in drivers:
|
||||||
|
self.assertIsInstance(driver, util.DriverInfo)
|
||||||
|
|
||||||
|
@mock.patch('cinder.zonemanager.drivers.cisco.cisco_fc_zone_driver.'
|
||||||
|
'CiscoFCZoneDriver.get_driver_options')
|
||||||
|
def test_get_fczm_drivers_fail(self, driver_opt):
|
||||||
|
driver_opt.side_effect = ValueError
|
||||||
|
self.assertRaises(ValueError, util.get_fczm_drivers)
|
@ -562,6 +562,7 @@ class BaseVD(object):
|
|||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def get_driver_options():
|
def get_driver_options():
|
||||||
"""Return the oslo_config options specific to the driver."""
|
"""Return the oslo_config options specific to the driver."""
|
||||||
return volume_opts
|
return volume_opts
|
||||||
|
@ -39,6 +39,11 @@ class InfortrendCLIFCDriver(driver.FibreChannelDriver):
|
|||||||
'FC', configuration=self.configuration)
|
'FC', configuration=self.configuration)
|
||||||
self.VERSION = self.common.VERSION
|
self.VERSION = self.common.VERSION
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_driver_options():
|
||||||
|
"""Return the oslo_config options specific to the driver."""
|
||||||
|
return common_cli.infortrend_opts
|
||||||
|
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
"""Any initialization the volume driver does while starting.
|
"""Any initialization the volume driver does while starting.
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ class InfortrendCLIISCSIDriver(driver.ISCSIDriver):
|
|||||||
'iSCSI', configuration=self.configuration)
|
'iSCSI', configuration=self.configuration)
|
||||||
self.VERSION = self.common.VERSION
|
self.VERSION = self.common.VERSION
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_driver_options():
|
||||||
|
"""Return the oslo_config options specific to the driver."""
|
||||||
|
return common_cli.infortrend_opts
|
||||||
|
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
"""Any initialization the volume driver does while starting.
|
"""Any initialization the volume driver does while starting.
|
||||||
|
|
||||||
|
@ -182,6 +182,11 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
|||||||
|
|
||||||
self.initialize_iscsi_info()
|
self.initialize_iscsi_info()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_driver_options():
|
||||||
|
"""Return the oslo_config options specific to the driver."""
|
||||||
|
return config.macrosan_opts
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _self_node_wwns(self):
|
def _self_node_wwns(self):
|
||||||
return []
|
return []
|
||||||
|
@ -35,6 +35,23 @@ There are some basic attributes that all drivers classes should have:
|
|||||||
|
|
||||||
The tooling system will also use the name and docstring of the driver class.
|
The tooling system will also use the name and docstring of the driver class.
|
||||||
|
|
||||||
|
Configuration options
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Each driver requires different configuration options set in the cinder.conf
|
||||||
|
file to operate, and due to the complexities of the Object Oriented programming
|
||||||
|
mechanisms (inheritance, composition, overwriting, etc.) once your driver
|
||||||
|
defines its parameters in the code Cinder has no automated way of telling which
|
||||||
|
configuration options are relevant to your driver.
|
||||||
|
|
||||||
|
In order to assist operators and installation tools we recommend reporting the
|
||||||
|
relevant options:
|
||||||
|
|
||||||
|
* For operators: In the documentation under
|
||||||
|
``doc/source/configuration/block-storage``.
|
||||||
|
* For operators and installers: Through the ``get_driver_options`` static
|
||||||
|
method returning that returns a list of all the Oslo Config parameters.
|
||||||
|
|
||||||
Minimum Features
|
Minimum Features
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user