Esempio n. 1
0
    def test_get_storage(self):
        expected = {
            'name': '',
            'vendor': 'Dell EMC',
            'description': '',
            'model': 'VMAX250F',
            'status': 'normal',
            'serial_number': '00112233',
            'location': '',
            '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")
            model = {
                'symmetrix': [
                    {'model': 'VMAX250F'}
                ],
                'system_capacity': {
                    'usable_total_tb': 100,
                    'usable_used_tb': 75
                }
            }
            m.common.get_request.side_effect = \
                [
                    model, model,
                    model, exception.StorageBackendException,
                    exception.StorageBackendException, model]
            ret = driver.get_storage(context)
            self.assertDictEqual(ret, expected)

            with self.assertRaises(Exception) as exc:
                driver.get_storage(context)

            self.assertIn('Failed to get capacity from VMAX',
                          str(exc.exception))

            with self.assertRaises(Exception) as exc:
                driver.get_storage(context)

            self.assertIn('Failed to get model from VMAX',
                          str(exc.exception))
Esempio n. 2
0
    def test_get_storage(self, mock_unisphere_version, mock_version,
                         mock_array, mock_array_details, mock_capacity):
        expected = {
            'name': 'VMAX250F-00112233',
            'vendor': 'Dell EMC',
            'description': '',
            'model': 'VMAX250F',
            'firmware_version': '5978.221.221',
            'status': 'normal',
            'serial_number': '00112233',
            'location': '',
            'total_capacity': 109951162777600,
            'used_capacity': 82463372083200,
            'free_capacity': 27487790694400,
            'raw_capacity': 1610612736000,
            'subscribed_capacity': 219902325555200
        }
        system_capacity = {
            'system_capacity': {
                'usable_total_tb': 100,
                'usable_used_tb': 75,
                'subscribed_total_tb': 200
            },
            'physicalCapacity': {
                'total_capacity_gb': 1500
            }
        }
        system_capacity_84 = {
            'total_usable_cap_gb': 100 * 1024,
            'total_allocated_cap_gb': 75 * 1024,
            'total_subscribed_cap_gb': 200 * 1024,
            'physicalCapacity': {
                'total_capacity_gb': 1500
            }
        }
        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_array_details.return_value = {
            'model': 'VMAX250F',
            'ucode': '5978.221.221',
            'display_name': 'VMAX250F-00112233'
        }
        mock_capacity.return_value = system_capacity

        driver = VMAXStorageDriver(**kwargs)

        self.assertEqual(driver.storage_id, "12345")
        self.assertEqual(driver.client.array_id, "00112233")

        ret = driver.get_storage(context)
        self.assertDictEqual(ret, expected)

        driver.client.uni_version = '84'
        mock_capacity.return_value = system_capacity_84
        ret = driver.get_storage(context)
        self.assertDictEqual(ret, expected)

        mock_array_details.side_effect = exception.StorageBackendException
        with self.assertRaises(Exception) as exc:
            driver.get_storage(context)

        self.assertIn('Failed to get array details from VMAX',
                      str(exc.exception))

        mock_array_details.side_effect = [{
            'model': 'VMAX250F',
            'ucode': '5978.221.221',
            'display_name': 'VMAX250F-00112233'
        }]

        mock_capacity.side_effect = exception.StorageBackendException
        with self.assertRaises(Exception) as exc:
            driver.get_storage(context)

        self.assertIn('Failed to get capacity from VMAX', str(exc.exception))