Example #1
0
    def test_create_asup(self):
        self.library._client = mock.Mock()
        self.library._client.features.AUTOSUPPORT = na_utils.FeatureState()
        self.library._client.api_operating_mode = (
            eseries_fake.FAKE_ASUP_DATA['operating-mode'])
        self.library._app_version = eseries_fake.FAKE_APP_VERSION
        self.mock_object(
            self.library._client, 'get_firmware_version',
            mock.Mock(
                return_value=(eseries_fake.FAKE_ASUP_DATA['system-version'])))
        self.mock_object(
            self.library._client, 'get_serial_numbers',
            mock.Mock(return_value=eseries_fake.FAKE_SERIAL_NUMBERS))
        self.mock_object(
            self.library._client, 'get_model_name',
            mock.Mock(
                return_value=eseries_fake.FAKE_CONTROLLERS[0]['modelName']))
        self.mock_object(self.library._client, 'set_counter',
                         mock.Mock(return_value={'value': 1}))
        mock_invoke = self.mock_object(self.library._client,
                                       'add_autosupport_data')

        self.library._create_asup(eseries_fake.FAKE_CINDER_HOST)

        mock_invoke.assert_called_with(eseries_fake.FAKE_KEY,
                                       eseries_fake.FAKE_ASUP_DATA)
Example #2
0
    def test_get_volume_api_path_invalid(self, ssc_available):
        key = 'invalidKey'
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=ssc_available)

        self.assertRaises(KeyError, self.my_client._get_volume_api_path, key)
Example #3
0
    def test_update_ssc_info_no_ssc(self):
        drives = [{
            'currentVolumeGroupRef': 'test_vg1',
            'driveMediaType': 'ssd'
        }]
        pools = [{
            'volumeGroupRef': 'test_vg1',
            'label': 'test_vg1',
            'raidLevel': 'raid6',
            'securityType': 'enabled'
        }]
        self.library._client = mock.Mock()
        self.library._client.features.SSC_API_V2 = na_utils.FeatureState(
            False, minimum_version="1.53.9000.1")
        self.library._client.SSC_VALID_VERSIONS = [(1, 53, 9000, 1),
                                                   (1, 53, 9010, 15)]
        self.library.configuration.netapp_storage_pools = "test_vg1"
        self.library._client.list_storage_pools = mock.Mock(return_value=pools)
        self.library._client.list_drives = mock.Mock(return_value=drives)

        self.library._update_ssc_info()

        self.assertEqual(
            {
                'test_vg1': {
                    'netapp_disk_encryption': 'true',
                    'netapp_disk_type': 'SSD',
                    'netapp_raid_type': 'raid6'
                }
            }, self.library._ssc_stats)
Example #4
0
    def test_create_volume_unsupported_specs(self):
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=False)
        self.my_client.api_version = '01.52.9000.1'

        self.assertRaises(exception.NetAppDriverException,
                          client.RestClient.create_volume, self.my_client,
                          '1', 'label', 1, read_cache=True)
Example #5
0
    def test_create_asup_not_supported(self):
        self.library._client = mock.Mock()
        self.library._client.features.AUTOSUPPORT = na_utils.FeatureState(
            supported=False)
        mock_invoke = self.mock_object(self.library._client,
                                       'add_autosupport_data')

        self.library._create_asup(eseries_fake.FAKE_CINDER_HOST)

        mock_invoke.assert_not_called()
Example #6
0
    def test_get_volume_api_path(self, path_key, ssc_available):
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=ssc_available)
        expected_key = 'ssc_' + path_key if ssc_available else path_key
        expected = self.my_client.RESOURCE_PATHS.get(expected_key)

        actual = self.my_client._get_volume_api_path(path_key)

        self.assertEqual(expected, actual)
Example #7
0
    def test_list_volumes(self):
        url = client.RestClient.RESOURCE_PATHS['ssc_volumes']
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=True)
        self.my_client._invoke = mock.Mock(return_value=eseries_fake.VOLUMES)

        volumes = client.RestClient.list_volumes(self.my_client)

        self.assertEqual(eseries_fake.VOLUMES, volumes)
        self.my_client._invoke.assert_called_once_with('GET', url)
Example #8
0
    def test_list_volume_v1_not_found(self):
        url = client.RestClient.RESOURCE_PATHS['volumes']
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=False)
        self.my_client._invoke = mock.Mock(return_value=eseries_fake.VOLUMES)

        self.assertRaises(exception.VolumeNotFound,
                          client.RestClient.list_volume, self.my_client,
                          'fakeId')
        self.my_client._invoke.assert_called_once_with('GET', url)
Example #9
0
    def test_extend_volume_unsupported(self):
        new_capacity = 10
        min_version = 1
        fake_volume = copy.deepcopy(eseries_fake.VOLUME)
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=False, minimum_version=min_version)
        self.my_client._invoke = mock.Mock(return_value=fake_volume)

        self.assertRaises(exception.NetAppDriverException,
                          self.my_client.expand_volume, fake_volume['id'],
                          new_capacity)
Example #10
0
    def test_list_volume_v1(self, uid_field_name):
        url = client.RestClient.RESOURCE_PATHS['volumes']
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=False)
        fake_volume = copy.deepcopy(eseries_fake.VOLUME)
        self.my_client._invoke = mock.Mock(return_value=eseries_fake.VOLUMES)

        volume = client.RestClient.list_volume(self.my_client,
                                               fake_volume[uid_field_name])

        self.my_client._invoke.assert_called_once_with('GET', url)
        self.assertEqual(fake_volume, volume)
Example #11
0
    def test_list_volume_v2(self):
        url = client.RestClient.RESOURCE_PATHS['ssc_volume']
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=True)
        fake_volume = copy.deepcopy(eseries_fake.VOLUME)
        self.my_client._invoke = mock.Mock(return_value=fake_volume)

        volume = client.RestClient.list_volume(self.my_client,
                                               fake_volume['id'])

        self.my_client._invoke.assert_called_once_with(
            'GET', url, **{'object-id': mock.ANY})
        self.assertEqual(fake_volume, volume)
Example #12
0
    def test_update_ssc_info(self, data_assurance_supported):
        self.library._client = mock.Mock()
        self.library._client.features.SSC_API_V2 = na_utils.FeatureState(
            True, minimum_version="1.53.9000.1")
        self.library._client.list_ssc_storage_pools = mock.Mock(
            return_value=eseries_fake.SSC_POOLS)
        self.library._get_storage_pools = mock.Mock(
            return_value=eseries_fake.STORAGE_POOLS)
        # Data Assurance is not supported on some storage backends
        self.library._is_data_assurance_supported = mock.Mock(
            return_value=data_assurance_supported)

        self.library._update_ssc_info()

        for pool in eseries_fake.SSC_POOLS:
            poolId = pool['poolId']

            raid_lvl = self.library.SSC_RAID_TYPE_MAPPING.get(
                pool['raidLevel'], 'unknown')

            if pool['pool']["driveMediaType"] == 'ssd':
                disk_type = 'SSD'
            else:
                disk_type = pool['pool']['drivePhysicalType']
                disk_type = (self.library.SSC_DISK_TYPE_MAPPING.get(
                    disk_type, 'unknown'))

            da_enabled = pool['dataAssuranceCapable'] and (
                data_assurance_supported)

            thin_provisioned = pool['thinProvisioningCapable']

            expected = {
                'netapp_disk_encryption':
                six.text_type(pool['encrypted']).lower(),
                'netapp_eseries_flash_read_cache':
                six.text_type(pool['flashCacheCapable']).lower(),
                'netapp_thin_provisioned':
                six.text_type(thin_provisioned).lower(),
                'netapp_eseries_data_assurance':
                six.text_type(da_enabled).lower(),
                'netapp_eseries_disk_spindle_speed':
                pool['spindleSpeed'],
                'netapp_raid_type':
                raid_lvl,
                'netapp_disk_type':
                disk_type
            }
            actual = self.library._ssc_stats[poolId]
            self.assertDictMatch(expected, actual)
Example #13
0
    def test_create_volume_V1(self):
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=False)
        create_volume = self.my_client._invoke = mock.Mock(
            return_value=eseries_fake.VOLUME)

        volume = client.RestClient.create_volume(self.my_client, 'fakePool',
                                                 '1', 1)

        args, kwargs = create_volume.call_args
        verb, url, body = args
        # Ensure the correct API was used
        self.assertEqual('/storage-systems/{system-id}/volumes', url)
        self.assertEqual(eseries_fake.VOLUME, volume)
Example #14
0
    def test_delete_volume(self, ssc_api_enabled):
        fake_volume = copy.deepcopy(eseries_fake.VOLUME)
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=ssc_api_enabled)
        self.my_client._invoke = mock.Mock()

        self.my_client.delete_volume(fake_volume['id'])

        if ssc_api_enabled:
            url = self.my_client.RESOURCE_PATHS.get('ssc_volume')
        else:
            url = self.my_client.RESOURCE_PATHS.get('volume')

        self.my_client._invoke.assert_called_once_with(
            'DELETE', url, **{'object-id': fake_volume['id']})
Example #15
0
    def test_extend_volume(self):
        new_capacity = 10
        fake_volume = copy.deepcopy(eseries_fake.VOLUME)
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=True)
        self.my_client._invoke = mock.Mock(return_value=fake_volume)

        expanded_volume = self.my_client.expand_volume(fake_volume['id'],
                                                       new_capacity, False)

        url = self.my_client.RESOURCE_PATHS.get('volume_expand')
        body = {'expansionSize': new_capacity, 'sizeUnit': 'gb'}
        self.my_client._invoke.assert_called_once_with(
            'POST', url, body, **{'object-id': fake_volume['id']})
        self.assertEqual(fake_volume, expanded_volume)
Example #16
0
    def test_list_volume_v2_failure(self):
        status_code = http_client.UNPROCESSABLE_ENTITY
        url = client.RestClient.RESOURCE_PATHS['ssc_volume']
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=True)
        msg = "Response error code - %s." % status_code
        self.my_client._invoke = mock.Mock(
            side_effect=es_exception.WebServiceException(
                message=msg, status_code=status_code))

        self.assertRaises(es_exception.WebServiceException,
                          client.RestClient.list_volume, self.my_client,
                          'fakeId')
        self.my_client._invoke.assert_called_once_with(
            'GET', url, **{'object-id': mock.ANY})
Example #17
0
    def test_update_volume(self, ssc_api_enabled):
        label = 'updatedName'
        fake_volume = copy.deepcopy(eseries_fake.VOLUME)
        expected_volume = copy.deepcopy(fake_volume)
        expected_volume['name'] = label
        self.my_client.features = mock.Mock()
        self.my_client.features.SSC_API_V2 = na_utils.FeatureState(
            supported=ssc_api_enabled)
        self.my_client._invoke = mock.Mock(return_value=expected_volume)

        updated_volume = self.my_client.update_volume(fake_volume['id'], label)

        if ssc_api_enabled:
            url = self.my_client.RESOURCE_PATHS.get('ssc_volume')
        else:
            url = self.my_client.RESOURCE_PATHS.get('volume')

        self.my_client._invoke.assert_called_once_with(
            'POST', url, {'name': label}, **{'object-id': fake_volume['id']})
        self.assertDictEqual(expected_volume, updated_volume)