Browse Source

Split connector list by platform

We'll keep separate lists of connectors for each of the supported
operating systems so that we don't end up trying to use unsupported
connectors.

Since Cinder is explicitly trying to use the iSCSI/FC connectors,
we'll have to include those as well, for now.

Change-Id: Ibec2b798e8c5c3457cebea12cfd2f5813e62fb9e
Closes-Bug: #1850109
(cherry picked from commit 9e8657dd6e)
changes/90/706190/1
Lucian Petrut 2 years ago
parent
commit
0927b72f68
  1. 44
      os_brick/initiator/connector.py
  2. 2
      os_brick/tests/initiator/test_connector.py
  3. 2
      tools/generate_connector_list.py

44
os_brick/initiator/connector.py

@ -39,7 +39,14 @@ synchronized = lockutils.synchronized_with_prefix('os-brick-')
# List of connectors to call when getting
# the connector properties for a host
connector_list = [
windows_connector_list = [
'os_brick.initiator.windows.base.BaseWindowsConnector',
'os_brick.initiator.windows.iscsi.WindowsISCSIConnector',
'os_brick.initiator.windows.fibre_channel.WindowsFCConnector',
'os_brick.initiator.windows.smbfs.WindowsSMBFSConnector'
]
unix_connector_list = [
'os_brick.initiator.connectors.base.BaseLinuxConnector',
'os_brick.initiator.connectors.iscsi.ISCSIConnector',
'os_brick.initiator.connectors.fibre_channel.FibreChannelConnector',
@ -58,15 +65,19 @@ connector_list = [
'os_brick.initiator.connectors.scaleio.ScaleIOConnector',
'os_brick.initiator.connectors.disco.DISCOConnector',
'os_brick.initiator.connectors.vmware.VmdkConnector',
'os_brick.initiator.windows.base.BaseWindowsConnector',
'os_brick.initiator.windows.iscsi.WindowsISCSIConnector',
'os_brick.initiator.windows.fibre_channel.WindowsFCConnector',
'os_brick.initiator.windows.smbfs.WindowsSMBFSConnector',
'os_brick.initiator.connectors.vrtshyperscale.HyperScaleConnector',
'os_brick.initiator.connectors.storpool.StorPoolConnector',
'os_brick.initiator.connectors.nvmeof.NVMeOFConnector',
]
def _get_connector_list():
if sys.platform != 'win32':
return unix_connector_list
else:
return windows_connector_list
# Mappings used to determine who to construct in the factory
_connector_mapping_linux = {
initiator.AOE:
@ -182,9 +193,24 @@ _connector_mapping_windows = {
# Create aliases to the old names until 2.0.0
# TODO(smcginnis) Remove this lookup once unit test code is updated to
# point to the correct location
for item in connector_list:
_name = item.split('.')[-1]
globals()[_name] = importutils.import_class(item)
def _set_aliases():
conn_list = _get_connector_list()
# TODO(lpetrut): Cinder is explicitly trying to use those two
# connectors. We should drop this once we fix Cinder and
# get passed the backwards compatibility period.
if sys.platform == 'win32':
conn_list += [
'os_brick.initiator.connectors.iscsi.ISCSIConnector',
('os_brick.initiator.connectors.fibre_channel.'
'FibreChannelConnector'),
]
for item in conn_list:
_name = item.split('.')[-1]
globals()[_name] = importutils.import_class(item)
_set_aliases()
@utils.trace
@ -220,7 +246,7 @@ def get_connector_properties(root_helper, my_ip, multipath, enforce_multipath,
props['ip'] = my_ip
props['host'] = host if host else socket.gethostname()
for item in connector_list:
for item in _get_connector_list():
connector = importutils.import_class(item)
if (utils.platform_matches(props['platform'], connector.platform) and

2
os_brick/tests/initiator/test_connector.py

@ -79,7 +79,7 @@ class ConnectorUtilsTestCase(test_base.TestCase):
mock_list = []
# Make sure every connector is called
for item in connector.connector_list:
for item in connector._get_connector_list():
patched = mock.MagicMock()
patched.platform = platform.machine()
patched.os_type = sys.platform

2
tools/generate_connector_list.py

@ -55,7 +55,7 @@ def _ensure_loaded(connector_list):
def get_connectors():
"""Get a list of all connectors."""
classes = _ensure_loaded(connector.connector_list)
classes = _ensure_loaded(connector._get_connector_list())
return [DriverInfo(x) for x in classes]

Loading…
Cancel
Save