Regerate the iSCSI patch
Change-Id: Idfaec26ca2013ba2dc151177356310b8e198f486
diff --git a/patches/openstack/cinder/sep-sp-iscsi.patch b/patches/openstack/cinder/sep-sp-iscsi.patch
index a7dbea7..90af1b2 100644
--- a/patches/openstack/cinder/sep-sp-iscsi.patch
+++ b/patches/openstack/cinder/sep-sp-iscsi.patch
@@ -1,4 +1,4 @@
-From f15732ac9c326996b418aaaf40aece68912f038b Mon Sep 17 00:00:00 2001
+From 98e9487ad99ac6969e5ae58601ab5550b947202b Mon Sep 17 00:00:00 2001
From: Peter Penchev <openstack-dev@storpool.com>
Date: Mon, 12 Mar 2018 12:00:10 +0200
Subject: [PATCH] Add iSCSI export support to the StorPool driver
@@ -26,29 +26,30 @@
Change-Id: I9de64306e0e6976268df782053b0651dd1cca96f
---
.../unit/volume/drivers/test_storpool.py | 441 +++++++++++++++++-
- cinder/volume/drivers/storpool.py | 381 ++++++++++++++-
+ cinder/volume/drivers/storpool.py | 386 ++++++++++++++-
.../drivers/storpool-volume-driver.rst | 68 ++-
.../storpool-iscsi-cefcfe590a07c5c7.yaml | 15 +
- 4 files changed, 889 insertions(+), 16 deletions(-)
+ 4 files changed, 895 insertions(+), 15 deletions(-)
create mode 100644 releasenotes/notes/storpool-iscsi-cefcfe590a07c5c7.yaml
diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py
-index 2015c734d..440740a56 100644
+index 2015c734d..b21f1582d 100644
--- a/cinder/tests/unit/volume/drivers/test_storpool.py
+++ b/cinder/tests/unit/volume/drivers/test_storpool.py
-@@ -13,9 +13,10 @@
+@@ -13,9 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
--
++from __future__ import annotations
+
+import dataclasses
import itertools
import re
-+from typing import Any, NamedTuple, TYPE_CHECKING # noqa: H301
++from typing import Any, NamedTuple # noqa: H301
from unittest import mock
import ddt
-@@ -23,6 +24,7 @@ from os_brick.initiator import storpool_utils
+@@ -23,6 +26,7 @@ from os_brick.initiator import storpool_utils
from os_brick.tests.initiator import test_storpool_utils
from oslo_utils import units
@@ -56,7 +57,7 @@
from cinder import exception
from cinder.tests.unit import fake_constants
from cinder.tests.unit import test
-@@ -30,6 +32,13 @@ from cinder.volume import configuration as conf
+@@ -30,6 +34,13 @@ from cinder.volume import configuration as conf
from cinder.volume.drivers import storpool as driver
@@ -70,7 +71,7 @@
volume_types = {
fake_constants.VOLUME_TYPE_ID: {},
fake_constants.VOLUME_TYPE2_ID: {'storpool_template': 'ssd'},
-@@ -67,6 +76,10 @@ def snapshotName(vtype, vid, more=None):
+@@ -67,6 +78,10 @@ def snapshotName(vtype, vid, more=None):
)
@@ -81,7 +82,7 @@
class MockAPI(object):
def __init__(self, *args):
self._disks = {}
-@@ -162,6 +175,242 @@ class MockAPI(object):
+@@ -162,6 +177,242 @@ class MockAPI(object):
volumes[name] = dict(snapshots[snapname])
@@ -152,7 +153,6 @@
+ }
+
+
-+
+class MockIscsiAPI:
+ """Mock only the iSCSI-related calls of the StorPool API bindings."""
+
@@ -182,7 +182,8 @@
+ 'volumeName': volumeName(fake_constants.VOLUME_ID),
+ },
+ )
-+ self._asrt.assertEqual(cfg['initiators']['1']['name'], cmd['initiator'])
++ self._asrt.assertEqual(cfg['initiators']['1']['name'],
++ cmd['initiator'])
+ self._asrt.assertListEqual(cfg['initiators']['1']['exports'], [])
+
+ cfg['initiators'] = {
@@ -209,11 +210,12 @@
+ 'volumeName': volumeName(fake_constants.VOLUME_ID),
+ },
+ )
-+ self._asrt.assertEqual(cfg['initiators']['1']['name'], cmd['initiator'])
++ self._asrt.assertEqual(cfg['initiators']['1']['name'],
++ cmd['initiator'])
+ self._asrt.assertListEqual(
+ cfg['initiators']['1']['exports'],
+ [{'portalGroup': ISCSI_PORTAL_GROUP,
-+ 'target': cfg['targets']['1']['name']}])
++ 'target': cfg['targets']['1']['name']}])
+
+ del cfg['initiators']['1']
+ return cfg
@@ -240,7 +242,6 @@
+ }
+ return cfg
+
-+
+ def _handle_create_target(self, cfg: dict, cmd: dict[str, Any]) -> dict:
+ """Add a target for a volume so that it may be exported."""
+ self._asrt.assertDictEqual(
@@ -324,7 +325,7 @@
class MockVolumeDB(object):
"""Simulate a Cinder database with a volume_get() method."""
-@@ -198,7 +447,15 @@ class StorPoolTestCase(test.TestCase):
+@@ -198,7 +449,15 @@ class StorPoolTestCase(test.TestCase):
self.cfg.volume_backend_name = 'storpool_test'
self.cfg.storpool_template = None
self.cfg.storpool_replication = 3
@@ -332,15 +333,15 @@
+ self.cfg.storpool_iscsi_export_to = ''
+ self.cfg.storpool_iscsi_learn_initiator_iqns = True
+ self.cfg.storpool_iscsi_portal_group = ISCSI_PORTAL_GROUP
-+
-+ self._setup_test_driver()
++ self._setup_test_driver()
++
+ def _setup_test_driver(self):
+ """Initialize a StorPool driver as per the current configuration."""
mock_exec = mock.Mock()
mock_exec.return_value = ('', '')
-@@ -216,7 +473,7 @@ class StorPoolTestCase(test.TestCase):
+@@ -216,7 +475,7 @@ class StorPoolTestCase(test.TestCase):
self.driver.check_for_setup_error()
@ddt.data(
@@ -349,7 +350,7 @@
({'no-host': None}, KeyError),
({'host': 'sbad'}, driver.StorPoolConfigurationInvalid),
({'host': 's01'}, None),
-@@ -232,7 +489,7 @@ class StorPoolTestCase(test.TestCase):
+@@ -232,7 +491,7 @@ class StorPoolTestCase(test.TestCase):
conn)
@ddt.data(
@@ -358,7 +359,7 @@
({'no-host': None}, KeyError),
({'host': 'sbad'}, driver.StorPoolConfigurationInvalid),
)
-@@ -271,7 +528,7 @@ class StorPoolTestCase(test.TestCase):
+@@ -271,7 +530,7 @@ class StorPoolTestCase(test.TestCase):
self.assertEqual(21, pool['total_capacity_gb'])
self.assertEqual(5, int(pool['free_capacity_gb']))
@@ -367,7 +368,7 @@
self.assertFalse(pool['QoS_support'])
self.assertFalse(pool['thick_provisioning_support'])
self.assertTrue(pool['thin_provisioning_support'])
-@@ -690,3 +947,179 @@ class StorPoolTestCase(test.TestCase):
+@@ -690,3 +949,179 @@ class StorPoolTestCase(test.TestCase):
'No such volume',
self.driver.revert_to_snapshot, None,
{'id': vol_id}, {'id': snap_id})
@@ -548,7 +549,7 @@
+ self.assertFalse(
+ _export_exists(iapi.get_iscsi_config()['iscsi'], tcase.volume))
diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
-index 2dc7bb6be..d9e607552 100644
+index 2dc7bb6be..acfabccd6 100644
--- a/cinder/volume/drivers/storpool.py
+++ b/cinder/volume/drivers/storpool.py
@@ -15,6 +15,7 @@
@@ -613,7 +614,7 @@
@staticmethod
def get_driver_options():
-@@ -158,10 +186,322 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -158,10 +186,327 @@ class StorPoolDriver(driver.VolumeDriver):
raise StorPoolConfigurationInvalid(
section=hostname, param='SP_OURID', error=e)
@@ -676,7 +677,8 @@
+
+ pg_name = self.configuration.storpool_iscsi_portal_group
+ pg_found = [
-+ pg for pg in cfg['iscsi']['portalGroups'].values() if pg['name'] == pg_name
++ pg for pg in
++ cfg['iscsi']['portalGroups'].values() if pg['name'] == pg_name
+ ]
+ if not pg_found:
+ raise Exception('StorPool Cinder iSCSI configuration error: '
@@ -685,7 +687,8 @@
+
+ # Do we know about this initiator?
+ i_found = [
-+ init for init in cfg['iscsi']['initiators'].values() if init['name'] == iqn
++ init for init in
++ cfg['iscsi']['initiators'].values() if init['name'] == iqn
+ ]
+ if i_found:
+ initiator = i_found[0]
@@ -693,9 +696,11 @@
+ initiator = None
+
+ # Is this volume already being exported?
-+ volname = storpool_utils.os_to_sp_volume_name(volume_id)
++ volname = storpool_utils.os_to_sp_volume_name(
++ self._volume_prefix, volume_id)
+ t_found = [
-+ tgt for tgt in cfg['iscsi']['targets'].values() if tgt['volume'] == volname
++ tgt for tgt in
++ cfg['iscsi']['targets'].values() if tgt['volume'] == volname
+ ]
+ if t_found:
+ target = t_found[0]
@@ -707,7 +712,8 @@
+ if initiator is not None and target is not None:
+ e_found = [
+ exp for exp in initiator['exports']
-+ if exp['portalGroup'] == pg['name'] and exp['target'] == target['name']
++ if (exp['portalGroup'] == pg['name'] and
++ exp['target'] == target['name'])
+ ]
+ if e_found:
+ export = e_found[0]
@@ -936,7 +942,7 @@
return {'driver_volume_type': 'storpool',
'data': {
'client_id': self._storpool_client_id(connector),
-@@ -170,6 +510,9 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -170,6 +515,9 @@ class StorPoolDriver(driver.VolumeDriver):
}}
def terminate_connection(self, volume, connector, **kwargs):
@@ -946,7 +952,7 @@
pass
def create_snapshot(self, snapshot):
-@@ -278,11 +621,20 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -278,11 +626,20 @@ class StorPoolDriver(driver.VolumeDriver):
)
def create_export(self, context, volume, connector):
@@ -968,7 +974,7 @@
def delete_volume(self, volume):
name = storpool_utils.os_to_sp_volume_name(
self._volume_prefix, volume['id'])
-@@ -321,6 +673,17 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -321,6 +678,17 @@ class StorPoolDriver(driver.VolumeDriver):
LOG.error("StorPoolDriver API initialization failed: %s", e)
raise
@@ -986,7 +992,7 @@
def _update_volume_stats(self):
try:
dl = self._sp_api.disks_list()
-@@ -346,7 +709,7 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -346,7 +714,7 @@ class StorPoolDriver(driver.VolumeDriver):
'total_capacity_gb': total / units.Gi,
'free_capacity_gb': free / units.Gi,
'reserved_percentage': 0,
@@ -995,7 +1001,7 @@
'QoS_support': False,
'thick_provisioning_support': False,
'thin_provisioning_support': True,
-@@ -365,7 +728,9 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -365,7 +733,9 @@ class StorPoolDriver(driver.VolumeDriver):
'volume_backend_name') or 'storpool',
'vendor_name': 'StorPool',
'driver_version': self.VERSION,
@@ -1006,7 +1012,7 @@
# Driver capabilities
'clone_across_pools': True,
'sparse_copy_volume': True,
-@@ -452,15 +817,15 @@ class StorPoolDriver(driver.VolumeDriver):
+@@ -452,15 +822,15 @@ class StorPoolDriver(driver.VolumeDriver):
LOG.debug('Trying to swap volume names, intermediate "%(int)s"',
{'int': int_name})
try: