Rsdlib changed providing_pools interface

With the latest changes in the rsdlib in the RSD driver,
The _get_providing_pool(self, volume) method is returning
StoragePoolCollection instance, instead of StoragePool URL. Made
code changes and corresponding unit tests to address this changes

Change-Id: If7d24d2537deecd28400c120a23f3af172e92222
Closes-Bug: #1836121
This commit is contained in:
tkauthar 2019-07-12 09:35:23 -07:00
parent 4c9ae85ac8
commit cf0f5daad8
5 changed files with 41 additions and 13 deletions

View File

@ -79,6 +79,7 @@ class RSDClientTestCase(test.TestCase):
super(RSDClientTestCase, self).setUp()
self.mock_rsd_lib = mock.Mock()
self.mock_rsd_lib._rsd_api_version = "2.4.0"
self.mock_rsd_lib._redfish_version = "1.1.0"
self.mock_rsd_lib_factory = mock.MagicMock(
return_value=self.mock_rsd_lib)
fake_RSDLib.factory = self.mock_rsd_lib_factory
@ -120,20 +121,34 @@ class RSDClientTestCase(test.TestCase):
verify=True)
self.assertTrue(isinstance(rsd_client, rsd_driver.RSDClient))
def test_initialize_incorrect_version(self):
def test_initialize_rsd_api_incorrect_version(self):
self.mock_rsd_lib._rsd_api_version = "2.3.0"
rsd_client_init = rsd_driver.RSDClient.initialize
self.assertRaises(exception.VolumeBackendAPIException,
rsd_client_init, MOCK_URL, MOCK_USER,
MOCK_PASSWORD, False)
def test_initialize_higher_version(self):
def test_initialize_rsd_api_higher_version(self):
self.mock_rsd_lib._rsd_api_version = "2.5.0"
rsd_client = rsd_driver.RSDClient.initialize(MOCK_URL, MOCK_USER,
MOCK_PASSWORD,
verify=True)
self.assertTrue(isinstance(rsd_client, rsd_driver.RSDClient))
def test_initialize_rsd_lib_incorrect_version(self):
self.mock_rsd_lib._redfish_version = "1.0.0"
rsd_client_init = rsd_driver.RSDClient.initialize
self.assertRaises(exception.VolumeBackendAPIException,
rsd_client_init, MOCK_URL, MOCK_USER,
MOCK_PASSWORD, False)
def test_initialize_rsd_lib_higher_version(self):
self.mock_rsd_lib._redfish_version = "1.5.0"
rsd_client = rsd_driver.RSDClient.initialize(MOCK_URL, MOCK_USER,
MOCK_PASSWORD,
verify=True)
self.assertTrue(isinstance(rsd_client, rsd_driver.RSDClient))
def test_initialize_invalid_credentials(self):
self.mock_rsd_lib_factory.side_effect = (
fixtures._fixtures.timeout.TimeoutException)
@ -207,14 +222,18 @@ class RSDClientTestCase(test.TestCase):
mock_stor_serv.volumes.get_member.assert_called_with(self.resource_url)
def test_get_providing_pool(self):
mock_providing_pool_collection = mock.Mock()
mock_providing_pool_collection.path = mock.Mock()
mock_providing_pool = mock.Mock()
mock_providing_pool.get_members = mock.Mock(
return_value=[mock_providing_pool_collection])
mock_volume = mock.Mock()
mock_volume.capacity_sources = [mock.Mock()]
mock_volume.capacity_sources[0].providing_pools = [mock.Mock()]
mock_volume.capacity_sources[0].providing_pools = [mock_providing_pool]
provider_pool = self.rsd_client._get_providing_pool(mock_volume)
self.assertEqual(mock_volume.capacity_sources[0].providing_pools[0],
provider_pool)
self.assertEqual(mock_providing_pool_collection.path, provider_pool)
def test_get_providing_pool_no_capacity(self):
mock_volume = mock.Mock()

View File

@ -84,14 +84,21 @@ class RSDClient(object):
raise exception.VolumeBackendAPIException(
data=_("initialize: Cannot connect to RSD PODM."))
rsd_lib_version = version.LooseVersion(rsdlib._rsd_api_version)
if rsd_lib_version < version.LooseVersion("2.4.0"):
rsd_api_version = version.LooseVersion(rsdlib._rsd_api_version)
if rsd_api_version < version.LooseVersion("2.4.0"):
raise exception.VolumeBackendAPIException(
data=(_("initialize: Unsupported rsd_lib version: "
data=(_("initialize: Unsupported rsd_api version: "
"%(current)s < %(expected)s.")
% {'current': rsdlib._rsd_api_version,
'expected': "2.4.0"}))
if rsdlib._redfish_version < version.LooseVersion("1.1.0"):
raise exception.VolumeBackendAPIException(
data=(_("initialize: Unsupported rsd_lib version: "
"%(current)s < %(expected)s.")
% {'current': rsdlib._redfish_version,
'expected': "1.1.0"}))
LOG.info("initialize: Connected to %s at version %s.",
url, rsdlib._rsd_api_version)
return cls(rsdlib)
@ -137,7 +144,8 @@ class RSDClient(object):
detail=(_("Volume %(vol)s has %(len_pp)d providing_pools!")
% {'vol': volume.path,
'len_pp': len_pp}))
return volume.capacity_sources[0].providing_pools[0]
providing_pool = volume.capacity_sources[0].providing_pools[0]
return providing_pool.get_members()[0].path
def _create_vol_or_snap(self,
storage,

View File

@ -40,7 +40,4 @@ infi.dtypes.wwn # PSF
infi.dtypes.iqn # PSF
# Storpool
storpool # Apache-2.0
# RSD Driver
rsd-lib # Apache-2.0
storpool # Apache-2.0

View File

@ -173,3 +173,4 @@ capacity==1.3.10
info.dtypes.wwn==0.1.1
info.dtypes.iqn==0.4.0
purestorage==1.6.0
rsd-lib==1.1.0

View File

@ -127,3 +127,6 @@ infinidat =
infinisdk>=103.0.1 # BSD-3
pure =
purestorage>=1.6.0 # BSD
rsd =
rsd-lib>=1.1.0 # Apache-2.0