|
| 1 | +From 12bd279bddfe2459e33ad925ecb7fd7daf874ec6 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Doug Goldstein < [email protected]> |
| 3 | +Date: Tue, 11 Nov 2025 20:11:03 -0600 |
| 4 | +Subject: [PATCH] fix(netapp): respect the iniitalize_connection supplied |
| 5 | + os_type |
| 6 | + |
| 7 | +The user or os-brick can supply the os_type which should be used but |
| 8 | +this was never used. Switch to respecting the value supplied and if no |
| 9 | +value was supplied utilize the existing behavior which uses the config |
| 10 | +file and then a driver coded default. Added some types to the existing |
| 11 | +method and fixed a call to map_namespace() which had an unnecessary |
| 12 | +comma. |
| 13 | + |
| 14 | +Closes-Bug: #2131104 |
| 15 | +Change-Id: I4c87d1bdd8a757c7c43ef0b23a4a52c10bda8635 |
| 16 | +Signed-off-by: Doug Goldstein < [email protected]> |
| 17 | +--- |
| 18 | + .../drivers/netapp/dataontap/block_base.py | 18 ++++++++++++++--- |
| 19 | + .../drivers/netapp/dataontap/nvme_library.py | 20 ++++++++++++++----- |
| 20 | + 2 files changed, 30 insertions(+), 8 deletions(-) |
| 21 | + |
| 22 | +diff --git a/cinder/volume/drivers/netapp/dataontap/block_base.py b/cinder/volume/drivers/netapp/dataontap/block_base.py |
| 23 | +index fa5cf367e..7912930e7 100644 |
| 24 | +--- a/cinder/volume/drivers/netapp/dataontap/block_base.py |
| 25 | ++++ b/cinder/volume/drivers/netapp/dataontap/block_base.py |
| 26 | +@@ -438,13 +438,18 @@ class NetAppBlockStorageLibrary( |
| 27 | + discovered_lun = self._extract_lun_info(lun) |
| 28 | + self._add_lun_to_table(discovered_lun) |
| 29 | + |
| 30 | +- def _map_lun(self, name, initiator_list, initiator_type, lun_id=None): |
| 31 | ++ def _map_lun(self, |
| 32 | ++ name: str, |
| 33 | ++ initiator_list: list, |
| 34 | ++ initiator_type, |
| 35 | ++ os_type: str, |
| 36 | ++ lun_id: str | None = None) -> str: |
| 37 | + """Maps LUN to the initiator(s) and returns LUN ID assigned.""" |
| 38 | + metadata = self._get_lun_attr(name, 'metadata') |
| 39 | + path = metadata['Path'] |
| 40 | + igroup_name, ig_host_os, ig_type = self._get_or_create_igroup( |
| 41 | +- initiator_list, initiator_type, self.host_type) |
| 42 | +- if ig_host_os != self.host_type: |
| 43 | ++ initiator_list, initiator_type, os_type) |
| 44 | ++ if ig_host_os != os_type: |
| 45 | + LOG.warning("LUN misalignment may occur for current" |
| 46 | + " initiator group %(ig_nm)s) with host OS type" |
| 47 | + " %(ig_os)s. Please configure initiator group" |
| 48 | +@@ -910,6 +915,13 @@ class NetAppBlockStorageLibrary( |
| 49 | + initiator_name = connector['initiator'] |
| 50 | + lun_path = volume['provider_location'].split(':')[1] |
| 51 | + name = volume['name'] |
| 52 | ++ |
| 53 | ++ os_type = connector.get("os_type") or self.host_type |
| 54 | ++ if os_type not in self.ALLOWED_IGROUP_HOST_TYPES: |
| 55 | ++ raise exception.VolumeBackendAPIException( |
| 56 | ++ data=_("Initialize connection error: invalid os_type supplied") |
| 57 | ++ ) |
| 58 | ++ |
| 59 | + lun_id = self._map_lun(name, [initiator_name], 'iscsi', None) |
| 60 | + |
| 61 | + LOG.debug("Mapped LUN %(name)s to the initiator %(initiator_name)s", |
| 62 | +diff --git a/cinder/volume/drivers/netapp/dataontap/nvme_library.py b/cinder/volume/drivers/netapp/dataontap/nvme_library.py |
| 63 | +index fa969b058..30b74825d 100644 |
| 64 | +--- a/cinder/volume/drivers/netapp/dataontap/nvme_library.py |
| 65 | ++++ b/cinder/volume/drivers/netapp/dataontap/nvme_library.py |
| 66 | +@@ -653,12 +653,15 @@ class NetAppNVMeStorageLibrary( |
| 67 | + |
| 68 | + return subsystem_name, n_uuid |
| 69 | + |
| 70 | +- def _map_namespace(self, name, host_nqn): |
| 71 | ++ def _map_namespace(self, |
| 72 | ++ name: str, |
| 73 | ++ host_nqn: str, |
| 74 | ++ os_type: str) -> tuple[str, str]: |
| 75 | + """Maps namespace to the host nqn and returns its ID assigned.""" |
| 76 | + |
| 77 | + subsystem_name, subsystem_host_os = self._get_or_create_subsystem( |
| 78 | +- host_nqn, self.host_type) |
| 79 | +- if subsystem_host_os != self.host_type: |
| 80 | ++ host_nqn, os_type) |
| 81 | ++ if subsystem_host_os != os_type: |
| 82 | + LOG.warning("Namespace misalignment may occur for current" |
| 83 | + " subsystem %(sub_name)s with host OS type" |
| 84 | + " %(sub_os)s. Please configure subsystem manually" |
| 85 | +@@ -670,7 +673,7 @@ class NetAppNVMeStorageLibrary( |
| 86 | + path = metadata['Path'] |
| 87 | + try: |
| 88 | + ns_uuid = self.client.map_namespace( |
| 89 | +- path, subsystem_name,) |
| 90 | ++ path, subsystem_name) |
| 91 | + return subsystem_name, ns_uuid |
| 92 | + except netapp_api.NaApiError as e: |
| 93 | + (subsystem_name, ns_uuid) = self._find_mapped_namespace_subsystem( |
| 94 | +@@ -706,8 +709,15 @@ class NetAppNVMeStorageLibrary( |
| 95 | + raise exception.VolumeBackendAPIException( |
| 96 | + data=_("Initialize connection error: no host nqn available!")) |
| 97 | + |
| 98 | ++ os_type = connector.get("os_type") or self.host_type |
| 99 | ++ if os_type not in self.ALLOWED_SUBSYSTEM_HOST_TYPES: |
| 100 | ++ raise exception.VolumeBackendAPIException( |
| 101 | ++ data=_("Initialize connection error: invalid os_type supplied") |
| 102 | ++ ) |
| 103 | ++ |
| 104 | + name = volume['name'] |
| 105 | +- subsystem, namespace_uuid = self._map_namespace(name, host_nqn) |
| 106 | ++ subsystem, namespace_uuid = self._map_namespace(name, host_nqn, |
| 107 | ++ os_type) |
| 108 | + |
| 109 | + LOG.debug("Mapped namespace %(name)s to the host NQN %(host_nqn)s", |
| 110 | + {'name': name, 'host_nqn': host_nqn}) |
| 111 | +-- |
| 112 | +2.50.1 (Apple Git-155) |
0 commit comments