Merge "Fix get_driver_options"

This commit is contained in:
Zuul 2019-08-05 17:32:10 +00:00 committed by Gerrit Code Review
commit 9f7ef27b2a
7 changed files with 93 additions and 1 deletions

View 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)

View File

@ -562,6 +562,7 @@ class BaseVD(object):
def check_for_setup_error(self):
return
@staticmethod
def get_driver_options():
"""Return the oslo_config options specific to the driver."""
return volume_opts

View File

@ -39,6 +39,11 @@ class InfortrendCLIFCDriver(driver.FibreChannelDriver):
'FC', configuration=self.configuration)
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):
"""Any initialization the volume driver does while starting.

View File

@ -38,6 +38,11 @@ class InfortrendCLIISCSIDriver(driver.ISCSIDriver):
'iSCSI', configuration=self.configuration)
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):
"""Any initialization the volume driver does while starting.

View File

@ -87,7 +87,7 @@ macrosan_opts = [
(host; client_name; sp1_iscsi_port; sp2_iscsi_port),
(host; client_name; sp1_iscsi_port; sp2_iscsi_port)
Important warning, Client_name has the following requirements:
[a-zA-Z0-9.-_:], the maximum number of characters is 31
[a-zA-Z0-9.-_:], the maximum number of characters is 31
E.g:
(controller1; decive1; eth-1:0; eth-2:0),
(controller2; decive2; eth-1:0/eth-1:1; eth-2:0/eth-2:1),

View File

@ -182,6 +182,11 @@ class MacroSANBaseDriver(driver.VolumeDriver):
self.initialize_iscsi_info()
@staticmethod
def get_driver_options():
"""Return the oslo_config options specific to the driver."""
return config.macrosan_opts
@property
def _self_node_wwns(self):
return []

View File

@ -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.
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
----------------