Example #1
0
    def test_list_volumes(self, mock_unisphere_version, mock_version,
                          mock_array, mock_vols, mock_vol, mock_sg,
                          mock_capacity):
        expected = \
            [
                {
                    'name': 'volume_1',
                    'storage_id': '12345',
                    'description': "Dell EMC VMAX 'thin device' volume",
                    'type': 'thin',
                    'status': 'available',
                    'native_volume_id': '00001',
                    'wwn': 'wwn123',
                    'total_capacity': 104857600,
                    'used_capacity': 10485760,
                    'free_capacity': 94371840,
                    'native_storage_pool_id': 'SRP_1',
                    'compressed': True
                },
                {
                    'name': 'volume_2:id',
                    'storage_id': '12345',
                    'description': "Dell EMC VMAX 'thin device' volume",
                    'type': 'thin',
                    'status': 'available',
                    'native_volume_id': '00002',
                    'wwn': 'wwn1234',
                    'total_capacity': 104857600,
                    'used_capacity': 10485760,
                    'free_capacity': 94371840,
                    'native_storage_pool_id': 'SRP_1'
                }
            ]
        volumes = {
            'volumeId': '00001',
            'cap_mb': 100,
            'allocated_percent': 10,
            'status': 'Ready',
            'type': 'TDEV',
            'wwn': 'wwn123',
            'num_of_storage_groups': 1,
            'storageGroupId': ['SG_001'],
            'emulation': 'FBA'
        }
        volumes1 = {
            'volumeId': '00002',
            'volume_identifier': 'id',
            'cap_mb': 100,
            'allocated_percent': 10,
            'status': 'Ready',
            'type': 'TDEV',
            'wwn': 'wwn1234',
            'num_of_storage_groups': 0,
            'storageGroupId': [],
            'emulation': 'FBA'
        }
        volumes2 = {
            'volumeId': '00003',
            'cap_mb': 100,
            'allocated_percent': 10,
            'status': 'Ready',
            'type': 'TDEV',
            'wwn': 'wwn1234',
            'num_of_storage_groups': 0,
            'storageGroupId': [],
            'emulation': 'CKD'
        }
        storage_group_info = {'srp': 'SRP_1', 'compression': True}
        default_srps = {'default_fba_srp': 'SRP_1', 'default_ckd_srp': 'SRP_2'}
        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_vols.side_effect = [['volume_1', 'volume_2', 'volume_3']]
        mock_vol.side_effect = [volumes, volumes1, volumes2]
        mock_sg.side_effect = [storage_group_info]
        mock_capacity.return_value = default_srps

        driver = VMAXStorageDriver(**kwargs)
        self.assertEqual(driver.storage_id, "12345")
        self.assertEqual(driver.client.array_id, "00112233")
        ret = driver.list_volumes(context)
        self.assertDictEqual(ret[0], expected[0])
        self.assertDictEqual(ret[1], expected[1])

        mock_vols.side_effect = [['volume_1']]
        mock_vol.side_effect = [volumes]
        mock_sg.side_effect = [exception.StorageBackendException]
        with self.assertRaises(Exception) as exc:
            driver.list_volumes(context)

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

        mock_vols.side_effect = [['volume_1']]
        mock_vol.side_effect = [exception.StorageBackendException]
        mock_sg.side_effect = [storage_group_info]
        with self.assertRaises(Exception) as exc:
            driver.list_volumes(context)

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

        mock_vols.side_effect = [exception.StorageBackendException]
        mock_vol.side_effect = [volumes]
        mock_sg.side_effect = [storage_group_info]
        with self.assertRaises(Exception) as exc:
            driver.list_volumes(context)

        self.assertIn('Failed to get list volumes from VMAX',
                      str(exc.exception))
Example #2
0
    def test_list_volumes(self):
        expected = [{
            'name': 'volume_1',
            'storage_id': '12345',
            'description': "Dell EMC VMAX 'thin device' volume",
            'type': 'thin',
            'status': 'available',
            'native_volume_id': '00001',
            'wwn': 'wwn123',
            'total_capacity': 104857600,
            'used_capacity': 10485760,
            'free_capacity': 94371840,
            'native_storage_pool_id': 'SRP_1',
            'compressed': True
        }]
        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")
            volumes = {
                'volumeId': '00001',
                'cap_mb': 100,
                'allocated_percent': 10,
                'status': 'Ready',
                'type': 'TDEV',
                'wwn': 'wwn123',
                'num_of_storage_groups': 1,
                'storageGroupId': ['SG_001']
            }
            storage_group_info = {
                'srp': 'SRP_1',
                'compression': True
            }
            m.provisioning.get_volume_list.side_effect = \
                [['volume_1'], ['volume_1'],
                 exception.StorageBackendException, ['volume_1']]
            m.provisioning.get_volume.side_effect = \
                [volumes, exception.StorageBackendException,
                 volumes, volumes]
            m.provisioning.get_storage_group.side_effect = \
                [exception.StorageBackendException, storage_group_info,
                 storage_group_info, storage_group_info]

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

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

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

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

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

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

            ret = driver.list_volumes(context)
            self.assertDictEqual(ret[0], expected[0])