def test_list_storage_pools(self, mock_unisphere_version, mock_version, mock_array, mock_srp): expected = [{ 'name': 'SRP_1', 'storage_id': '12345', 'native_storage_pool_id': 'SRP_ID', 'description': 'Dell EMC VMAX Pool', 'status': 'normal', 'storage_type': 'block', 'total_capacity': 109951162777600, 'used_capacity': 82463372083200, 'free_capacity': 27487790694400, 'subscribed_capacity': 219902325555200 }] pool_info = { 'srp_capacity': { 'usable_total_tb': 100, 'usable_used_tb': 75, 'subscribed_total_tb': 200 }, 'srpId': 'SRP_ID' } kwargs = VMAX_STORAGE_CONF mock_version.return_value = ['V9.0.2.7', '90'] mock_unisphere_version.return_value = ['V9.0.2.7', '90'] mock_array.return_value = {'symmetrixId': ['00112233']} mock_srp.side_effect = [{'srpId': ['SRP_1']}, pool_info] driver = VMAXStorageDriver(**kwargs) self.assertEqual(driver.storage_id, "12345") self.assertEqual(driver.client.array_id, "00112233") ret = driver.list_storage_pools(context) self.assertDictEqual(ret[0], expected[0]) mock_srp.side_effect = [{ 'srpId': ['SRP_1'] }, exception.StorageBackendException] with self.assertRaises(Exception) as exc: driver.list_storage_pools(context) self.assertIn('Failed to get pool metrics from VMAX', str(exc.exception)) mock_srp.side_effect = [exception.StorageBackendException, pool_info] with self.assertRaises(Exception) as exc: driver.list_storage_pools(context) self.assertIn('Failed to get pool metrics from VMAX', str(exc.exception))
def test_list_storage_pools(self): expected = [{ 'name': 'SRP_1', 'storage_id': '12345', 'native_storage_pool_id': 'SRP_ID', 'description': 'Dell EMC VMAX Pool', 'status': 'normal', 'storage_type': 'block', 'total_capacity': 109951162777600, 'used_capacity': 82463372083200, 'free_capacity': 27487790694400 }] kwargs = VMAX_STORAGE_CONF m = mock.MagicMock() with mock.patch('PyU4V.U4VConn', return_value=m): driver = VMAXStorageDriver(**kwargs) self.assertEqual(driver.storage_id, "12345") self.assertEqual(driver.client.array_id, "00112233") pool_info = { 'srp_capacity': { 'usable_total_tb': 100, 'usable_used_tb': 75 }, 'srpId': 'SRP_ID' } m.provisioning.get_srp_list.side_effect = \ [['SRP_1'], ['SRP_2'], exception.StorageBackendException] m.provisioning.get_srp.side_effect = \ [pool_info, exception.StorageBackendException, pool_info] ret = driver.list_storage_pools(context) self.assertDictEqual(ret[0], expected[0]) with self.assertRaises(Exception) as exc: driver.list_storage_pools(context) self.assertIn('Failed to get pool metrics from VMAX', str(exc.exception)) with self.assertRaises(Exception) as exc: driver.list_storage_pools(context) self.assertIn('Failed to get pool metrics from VMAX', str(exc.exception))