|
| 1 | +From ea83d169368539f5482f350e4e24203ee386ab4c 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 | 19 ++++++++++++++----- |
| 20 | + 2 files changed, 29 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 ba1d2a22b..9b7e185ee 100644 |
| 24 | +--- a/cinder/volume/drivers/netapp/dataontap/block_base.py |
| 25 | ++++ b/cinder/volume/drivers/netapp/dataontap/block_base.py |
| 26 | +@@ -442,13 +442,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 | +@@ -927,6 +932,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 a4335bff7..ba9f75553 100644 |
| 64 | +--- a/cinder/volume/drivers/netapp/dataontap/nvme_library.py |
| 65 | ++++ b/cinder/volume/drivers/netapp/dataontap/nvme_library.py |
| 66 | +@@ -653,7 +653,10 @@ class NetAppNVMeStorageLibrary( |
| 67 | + |
| 68 | + return subsystem_uuid, 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 | + metadata = self._get_namespace_attr(name, 'metadata') |
| 77 | + path = metadata['Path'] |
| 78 | +@@ -667,9 +670,8 @@ class NetAppNVMeStorageLibrary( |
| 79 | + self.client.map_host_with_subsystem(host_nqn, subsystem_uuid) |
| 80 | + else: |
| 81 | + subsystem_name = na_utils.OPENSTACK_PREFIX + str(uuid.uuid4()) |
| 82 | +- self.client.create_subsystem(subsystem_name, self.host_type, |
| 83 | +- host_nqn) |
| 84 | +- ns_uuid = self.client.map_namespace(path, subsystem_name, ) |
| 85 | ++ self.client.create_subsystem(subsystem_name, os_type, host_nqn) |
| 86 | ++ ns_uuid = self.client.map_namespace(path, subsystem_name) |
| 87 | + return subsystem_name, ns_uuid |
| 88 | + except netapp_api.NaApiError as e: |
| 89 | + (_, subsystem_name, ns_uuid) =\ |
| 90 | +@@ -706,8 +708,15 @@ class NetAppNVMeStorageLibrary( |
| 91 | + raise exception.VolumeBackendAPIException( |
| 92 | + data=_("Initialize connection error: no host nqn available!")) |
| 93 | + |
| 94 | ++ os_type = connector.get("os_type") or self.host_type |
| 95 | ++ if os_type not in self.ALLOWED_SUBSYSTEM_HOST_TYPES: |
| 96 | ++ raise exception.VolumeBackendAPIException( |
| 97 | ++ data=_("Initialize connection error: invalid os_type supplied") |
| 98 | ++ ) |
| 99 | ++ |
| 100 | + name = volume['name'] |
| 101 | +- subsystem, namespace_uuid = self._map_namespace(name, host_nqn) |
| 102 | ++ subsystem, namespace_uuid = self._map_namespace(name, host_nqn, |
| 103 | ++ os_type) |
| 104 | + |
| 105 | + LOG.debug("Mapped namespace %(name)s to the host NQN %(host_nqn)s", |
| 106 | + {'name': name, 'host_nqn': host_nqn}) |
| 107 | +-- |
| 108 | +2.50.1 (Apple Git-155) |
0 commit comments