from cinder.volume import configuration as conf
from cinder.volume.drivers.netapp import common
from cinder.volume.drivers.netapp.eseries import client
-from cinder.volume.drivers.netapp.eseries import iscsi
+from cinder.volume.drivers.netapp.eseries import library
from cinder.volume.drivers.netapp.eseries import utils
from cinder.volume.drivers.netapp import options
import cinder.volume.drivers.netapp.utils as na_utils
self.mock_object(na_utils, 'OpenStackInfo')
configuration = self._set_config(create_configuration())
self.driver = common.NetAppDriver(configuration=configuration)
+ self.library = self.driver.library
self.mock_object(requests, 'Session', FakeEseriesHTTPSession)
self.driver.do_setup(context='context')
self.driver.check_for_setup_error()
configuration.netapp_controller_ips = '127.0.0.1,127.0.0.3'
driver = common.NetAppDriver(configuration=configuration)
driver.do_setup(context='context')
- self.assertEqual(driver._client.get_system_id(),
+ self.assertEqual(driver.library._client.get_system_id(),
'1fa6efb5-f07b-4de4-9f0e-52e5f7ff5d1b')
def test_check_system_pwd_not_sync(self):
return {'status': 'passwordoutofsync'}
return {'status': 'needsAttention'}
- self.driver._client.list_storage_system = mock.Mock(wraps=list_system)
- result = self.driver._check_storage_system()
+ self.library._client.list_storage_system = mock.Mock(wraps=list_system)
+ result = self.library._check_storage_system()
self.assertTrue(result)
def test_connect(self):
self.driver.get_volume_stats(refresh=False)
def test_get_pool(self):
- self.mock_object(self.driver, '_get_volume',
+ self.mock_object(self.library, '_get_volume',
mock.Mock(return_value={
'volumeGroupRef': 'fake_ref'}))
- self.mock_object(self.driver._client, "get_storage_pool",
+ self.mock_object(self.library._client, "get_storage_pool",
mock.Mock(return_value={'volumeGroupRef': 'fake_ref',
'label': 'ddp1'}))
self.assertEqual(pool, 'ddp1')
def test_get_pool_no_pools(self):
- self.mock_object(self.driver, '_get_volume',
+ self.mock_object(self.library, '_get_volume',
mock.Mock(return_value={
'volumeGroupRef': 'fake_ref'}))
- self.mock_object(self.driver._client, "get_storage_pool",
+ self.mock_object(self.library._client, "get_storage_pool",
mock.Mock(return_value=None))
pool = self.driver.get_pool({'name_id': 'fake-uuid'})
self.assertEqual(pool, None)
- @mock.patch.object(iscsi.NetAppEseriesISCSIDriver, '_create_volume',
+ @mock.patch.object(library.NetAppESeriesLibrary, '_create_volume',
mock.Mock())
def test_create_volume(self):
+
self.driver.create_volume(self.volume)
- self.driver._create_volume.assert_called_with(
+
+ self.library._create_volume.assert_called_with(
'DDP', self.fake_eseries_volume_label, self.volume['size'])
def test_create_volume_no_pool_provided_by_scheduler(self):
fake_list_pools.return_value = fake_pools
wrong_eseries_pool_label = 'hostname@backend'
self.assertRaises(exception.NetAppDriverException,
- self.driver._create_volume, wrong_eseries_pool_label,
- self.fake_eseries_volume_label, self.fake_size_gb)
+ self.library._create_volume,
+ wrong_eseries_pool_label,
+ self.fake_eseries_volume_label,
+ self.fake_size_gb)
- @mock.patch.object(iscsi.LOG, 'info')
+ @mock.patch.object(library.LOG, 'info')
@mock.patch.object(client.RestClient, 'list_storage_pools')
@mock.patch.object(client.RestClient, 'create_volume',
mock.MagicMock(return_value='CorrectVolume'))
fake_pool['raidLevel'] = 'raidDiskPool'
fake_pools = [fake_pool]
storage_pools.return_value = fake_pools
- storage_vol = self.driver._create_volume(
+ storage_vol = self.library._create_volume(
self.fake_eseries_pool_label,
self.fake_eseries_volume_label,
self.fake_size_gb)
@mock.patch.object(client.RestClient, 'create_volume',
mock.MagicMock(
side_effect=exception.NetAppDriverException))
- @mock.patch.object(iscsi.LOG, 'info', mock.Mock())
+ @mock.patch.object(library.LOG, 'info', mock.Mock())
def test_create_volume_check_exception(self, fake_list_pools):
fake_pool = {}
fake_pool['label'] = self.fake_eseries_pool_label
fake_pools = [fake_pool]
fake_list_pools.return_value = fake_pools
self.assertRaises(exception.NetAppDriverException,
- self.driver._create_volume,
+ self.library._create_volume,
self.fake_eseries_pool_label,
self.fake_eseries_volume_label, self.fake_size_gb)
vol_nomatch = {'id': 'vol_id', 'currentManager': 'ctrl3'}
portals = [{'controller': 'ctrl2', 'iqn': 'iqn2'},
{'controller': 'ctrl1', 'iqn': 'iqn1'}]
- portal = self.driver._get_iscsi_portal_for_vol(volume, portals)
+ portal = self.library._get_iscsi_portal_for_vol(volume, portals)
self.assertEqual(portal, {'controller': 'ctrl1', 'iqn': 'iqn1'})
- portal = self.driver._get_iscsi_portal_for_vol(vol_nomatch, portals)
+ portal = self.library._get_iscsi_portal_for_vol(vol_nomatch, portals)
self.assertEqual(portal, {'controller': 'ctrl2', 'iqn': 'iqn2'})
def test_portal_for_vol_any_false(self):
portals = [{'controller': 'ctrl2', 'iqn': 'iqn2'},
{'controller': 'ctrl1', 'iqn': 'iqn1'}]
self.assertRaises(exception.NetAppDriverException,
- self.driver._get_iscsi_portal_for_vol,
+ self.library._get_iscsi_portal_for_vol,
vol_nomatch, portals, False)
def test_setup_error_unsupported_host_type(self):
configuration.netapp_host_type = 'garbage'
driver = common.NetAppDriver(configuration=configuration)
self.assertRaises(exception.NetAppDriverException,
- driver.check_for_setup_error)
+ driver.library.check_for_setup_error)
def test_check_host_type_default(self):
configuration = self._set_config(create_configuration())
driver = common.NetAppDriver(configuration=configuration)
- driver._check_host_type()
- self.assertEqual('LnxALUA', driver.host_type)
+ driver.library._check_host_type()
+ self.assertEqual('LnxALUA', driver.library.host_type)
def test_do_setup_all_default(self):
configuration = self._set_config(create_configuration())
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system = mock.Mock()
+ driver.library._check_mode_get_or_register_storage_system = mock.Mock()
driver.do_setup(context='context')
- url = urllib.parse.urlparse(driver._client._endpoint)
+ url = urllib.parse.urlparse(driver.library._client._endpoint)
port = url.port
scheme = url.scheme
self.assertEqual(8080, port)
configuration = self._set_config(create_configuration())
configuration.netapp_transport_type = 'http'
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system = mock.Mock()
+ driver.library._check_mode_get_or_register_storage_system = mock.Mock()
driver.do_setup(context='context')
- url = urllib.parse.urlparse(driver._client._endpoint)
+ url = urllib.parse.urlparse(driver.library._client._endpoint)
port = url.port
scheme = url.scheme
self.assertEqual(8080, port)
configuration = self._set_config(create_configuration())
configuration.netapp_transport_type = 'https'
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system = mock.Mock()
+ driver.library._check_mode_get_or_register_storage_system = mock.Mock()
driver.do_setup(context='context')
- url = urllib.parse.urlparse(driver._client._endpoint)
+ url = urllib.parse.urlparse(driver.library._client._endpoint)
port = url.port
scheme = url.scheme
self.assertEqual(8443, port)
configuration = self._set_config(create_configuration())
configuration.netapp_server_port = 81
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system = mock.Mock()
+ driver.library._check_mode_get_or_register_storage_system = mock.Mock()
driver.do_setup(context='context')
- url = urllib.parse.urlparse(driver._client._endpoint)
+ url = urllib.parse.urlparse(driver.library._client._endpoint)
port = url.port
scheme = url.scheme
self.assertEqual(81, port)
configuration.netapp_transport_type = 'https'
configuration.netapp_server_port = 446
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system = mock.Mock()
+ driver.library._check_mode_get_or_register_storage_system = mock.Mock()
driver.do_setup(context='context')
- url = urllib.parse.urlparse(driver._client._endpoint)
+ url = urllib.parse.urlparse(driver.library._client._endpoint)
port = url.port
scheme = url.scheme
self.assertEqual(446, port)
configuration = self._set_config(create_configuration())
configuration.netapp_controller_ips = '127.0.0.1'
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system
+ driver.library._check_mode_get_or_register_storage_system
def test_setup_good_controller_ips(self):
configuration = self._set_config(create_configuration())
configuration.netapp_controller_ips = '127.0.0.2,127.0.0.1'
driver = common.NetAppDriver(configuration=configuration)
- driver._check_mode_get_or_register_storage_system
+ driver.library._check_mode_get_or_register_storage_system
def test_setup_missing_controller_ip(self):
configuration = self._set_config(create_configuration())
configuration = self._set_config(create_configuration())
configuration.netapp_controller_ips = '987.65.43.21'
driver = common.NetAppDriver(configuration=configuration)
- self.assertRaises(exception.NoValidHost,
- driver._check_mode_get_or_register_storage_system)
+ self.assertRaises(
+ exception.NoValidHost,
+ driver.library._check_mode_get_or_register_storage_system)
def test_setup_error_invalid_first_controller_ip(self):
configuration = self._set_config(create_configuration())
configuration.netapp_controller_ips = '987.65.43.21,127.0.0.1'
driver = common.NetAppDriver(configuration=configuration)
- self.assertRaises(exception.NoValidHost,
- driver._check_mode_get_or_register_storage_system)
+ self.assertRaises(
+ exception.NoValidHost,
+ driver.library._check_mode_get_or_register_storage_system)
def test_setup_error_invalid_second_controller_ip(self):
configuration = self._set_config(create_configuration())
configuration.netapp_controller_ips = '127.0.0.1,987.65.43.21'
driver = common.NetAppDriver(configuration=configuration)
- self.assertRaises(exception.NoValidHost,
- driver._check_mode_get_or_register_storage_system)
+ self.assertRaises(
+ exception.NoValidHost,
+ driver.library._check_mode_get_or_register_storage_system)
def test_setup_error_invalid_both_controller_ips(self):
configuration = self._set_config(create_configuration())
configuration.netapp_controller_ips = '564.124.1231.1,987.65.43.21'
driver = common.NetAppDriver(configuration=configuration)
- self.assertRaises(exception.NoValidHost,
- driver._check_mode_get_or_register_storage_system)
+ self.assertRaises(
+ exception.NoValidHost,
+ driver.library._check_mode_get_or_register_storage_system)
def test_get_vol_with_label_wwn_missing(self):
self.assertRaises(exception.InvalidInput,
- self.driver._get_volume_with_label_wwn,
+ self.library._get_volume_with_label_wwn,
None, None)
def test_get_vol_with_label_wwn_found(self):
{'volumeRef': '2', 'volumeUse': 'standardVolume',
'label': 'l2', 'volumeGroupRef': 'g2',
'worldWideName': 'w2ghyu'}]
- self.driver._get_storage_pools = mock.Mock(return_value=['g2', 'g3'])
- self.driver._client.list_volumes = mock.Mock(return_value=fake_vl_list)
- vol = self.driver._get_volume_with_label_wwn('l2', 'w2:gh:yu')
- self.assertEqual(1, self.driver._client.list_volumes.call_count)
+ self.library._get_storage_pools = mock.Mock(return_value=['g2', 'g3'])
+ self.library._client.list_volumes = mock.Mock(
+ return_value=fake_vl_list)
+ vol = self.library._get_volume_with_label_wwn('l2', 'w2:gh:yu')
+ self.assertEqual(1, self.library._client.list_volumes.call_count)
self.assertEqual('2', vol['volumeRef'])
def test_get_vol_with_label_wwn_unmatched(self):
{'volumeRef': '2', 'volumeUse': 'standardVolume',
'label': 'l2', 'volumeGroupRef': 'g2',
'worldWideName': 'w2ghyu'}]
- self.driver._get_storage_pools = mock.Mock(return_value=['g2', 'g3'])
- self.driver._client.list_volumes = mock.Mock(return_value=fake_vl_list)
- self.assertRaises(KeyError, self.driver._get_volume_with_label_wwn,
+ self.library._get_storage_pools = mock.Mock(return_value=['g2', 'g3'])
+ self.library._client.list_volumes = mock.Mock(
+ return_value=fake_vl_list)
+ self.assertRaises(KeyError, self.library._get_volume_with_label_wwn,
'l2', 'abcdef')
- self.assertEqual(1, self.driver._client.list_volumes.call_count)
+ self.assertEqual(1, self.library._client.list_volumes.call_count)
def test_manage_existing_get_size(self):
- self.driver._get_existing_vol_with_manage_ref = mock.Mock(
+ self.library._get_existing_vol_with_manage_ref = mock.Mock(
return_value=self.fake_ret_vol)
size = self.driver.manage_existing_get_size(self.volume, self.fake_ref)
self.assertEqual(3, size)
- self.driver._get_existing_vol_with_manage_ref.assert_called_once_with(
+ self.library._get_existing_vol_with_manage_ref.assert_called_once_with(
self.volume, self.fake_ref)
def test_get_exist_vol_source_name_missing(self):
self.assertRaises(exception.ManageExistingInvalidReference,
- self.driver._get_existing_vol_with_manage_ref,
+ self.library._get_existing_vol_with_manage_ref,
self.volume, {'id': '1234'})
def test_get_exist_vol_source_not_found(self):
d = {'id': '1'}
return d[v_id]
- self.driver._get_volume_with_label_wwn = mock.Mock(wraps=_get_volume)
+ self.library._get_volume_with_label_wwn = mock.Mock(wraps=_get_volume)
self.assertRaises(exception.ManageExistingInvalidReference,
- self.driver._get_existing_vol_with_manage_ref,
+ self.library._get_existing_vol_with_manage_ref,
{'id': 'id2'}, {'source-name': 'name2'})
- self.driver._get_volume_with_label_wwn.assert_called_once_with(
+ self.library._get_volume_with_label_wwn.assert_called_once_with(
'name2', None)
def test_get_exist_vol_with_manage_ref(self):
fake_ret_vol = {'id': 'right'}
- self.driver._get_volume_with_label_wwn = mock.Mock(
+ self.library._get_volume_with_label_wwn = mock.Mock(
return_value=fake_ret_vol)
- actual_vol = self.driver._get_existing_vol_with_manage_ref(
+ actual_vol = self.library._get_existing_vol_with_manage_ref(
{'id': 'id2'}, {'source-name': 'name2'})
- self.driver._get_volume_with_label_wwn.assert_called_once_with(
+ self.library._get_volume_with_label_wwn.assert_called_once_with(
'name2', None)
self.assertEqual(fake_ret_vol, actual_vol)
@mock.patch.object(utils, 'convert_uuid_to_es_fmt')
def test_manage_existing_same_label(self, mock_convert_es_fmt):
- self.driver._get_existing_vol_with_manage_ref = mock.Mock(
+ self.library._get_existing_vol_with_manage_ref = mock.Mock(
return_value=self.fake_ret_vol)
mock_convert_es_fmt.return_value = 'label'
self.driver.manage_existing(self.volume, self.fake_ref)
- self.driver._get_existing_vol_with_manage_ref.assert_called_once_with(
+ self.library._get_existing_vol_with_manage_ref.assert_called_once_with(
self.volume, self.fake_ref)
mock_convert_es_fmt.assert_called_once_with(
'114774fb-e15a-4fae-8ee2-c9723e3645ef')
@mock.patch.object(utils, 'convert_uuid_to_es_fmt')
def test_manage_existing_new(self, mock_convert_es_fmt):
- self.driver._get_existing_vol_with_manage_ref = mock.Mock(
+ self.library._get_existing_vol_with_manage_ref = mock.Mock(
return_value=self.fake_ret_vol)
mock_convert_es_fmt.return_value = 'vol_label'
- self.driver._client.update_volume = mock.Mock(
+ self.library._client.update_volume = mock.Mock(
return_value={'id': 'update', 'worldWideName': 'wwn'})
self.driver.manage_existing(self.volume, self.fake_ref)
- self.driver._get_existing_vol_with_manage_ref.assert_called_once_with(
+ self.library._get_existing_vol_with_manage_ref.assert_called_once_with(
self.volume, self.fake_ref)
mock_convert_es_fmt.assert_called_once_with(
'114774fb-e15a-4fae-8ee2-c9723e3645ef')
- self.driver._client.update_volume.assert_called_once_with(
+ self.library._client.update_volume.assert_called_once_with(
'vol_id', 'vol_label')
- @mock.patch.object(iscsi.LOG, 'info')
+ @mock.patch.object(library.LOG, 'info')
def test_unmanage(self, log_info):
- self.driver._get_volume = mock.Mock(return_value=self.fake_ret_vol)
+ self.library._get_volume = mock.Mock(return_value=self.fake_ret_vol)
self.driver.unmanage(self.volume)
- self.driver._get_volume.assert_called_once_with(
+ self.library._get_volume.assert_called_once_with(
'114774fb-e15a-4fae-8ee2-c9723e3645ef')
self.assertEqual(1, log_info.call_count)
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-"""
-Mock unit tests for the NetApp E-series iscsi driver
-"""
import copy
eseries_fakes
from cinder.volume.drivers.netapp.eseries import client as es_client
from cinder.volume.drivers.netapp.eseries import host_mapper
-from cinder.volume.drivers.netapp.eseries import iscsi as es_iscsi
+from cinder.volume.drivers.netapp.eseries import library
from cinder.volume.drivers.netapp.eseries import utils
from cinder.volume.drivers.netapp import utils as na_utils
}
-class NetAppEseriesISCSIDriverTestCase(test.TestCase):
+class NetAppEseriesLibraryTestCase(test.TestCase):
def setUp(self):
- super(NetAppEseriesISCSIDriverTestCase, self).setUp()
+ super(NetAppEseriesLibraryTestCase, self).setUp()
kwargs = {'configuration':
eseries_fakes.create_configuration_eseries()}
- self.driver = es_iscsi.NetAppEseriesISCSIDriver(**kwargs)
- self.driver._client = eseries_fakes.FakeEseriesClient()
- self.driver.check_for_setup_error()
+ self.library = library.NetAppESeriesLibrary('FAKE', **kwargs)
+ self.library._client = eseries_fakes.FakeEseriesClient()
+ self.library.check_for_setup_error()
def test_do_setup(self):
- self.mock_object(es_iscsi.NetAppEseriesISCSIDriver,
+ self.mock_object(self.library,
'_check_mode_get_or_register_storage_system')
self.mock_object(es_client, 'RestClient',
eseries_fakes.FakeEseriesClient)
mock_check_flags = self.mock_object(na_utils, 'check_flags')
- self.driver.do_setup(mock.Mock())
+ self.library.do_setup(mock.Mock())
self.assertTrue(mock_check_flags.called)
drives = [{'currentVolumeGroupRef': 'test_vg1',
'driveMediaType': 'ssd'}]
- self.driver._get_storage_pools = mock.Mock(return_value=['test_vg1'])
- self.driver._client.list_storage_pools = mock.Mock(return_value=[])
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._get_storage_pools = mock.Mock(return_value=['test_vg1'])
+ self.library._client.list_storage_pools = mock.Mock(return_value=[])
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- self.driver._update_ssc_info()
+ self.library._update_ssc_info()
self.assertEqual({'test_vg1': {'netapp_disk_type': 'SSD'}},
- self.driver._ssc_stats)
+ self.library._ssc_stats)
def test_update_ssc_disk_types_ssd(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'driveMediaType': 'ssd'}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'SSD'}},
ssc_stats)
def test_update_ssc_disk_types_scsi(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'interfaceType': {'driveType': 'scsi'}}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'SCSI'}},
ssc_stats)
def test_update_ssc_disk_types_fcal(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'interfaceType': {'driveType': 'fibre'}}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'FCAL'}},
ssc_stats)
def test_update_ssc_disk_types_sata(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'interfaceType': {'driveType': 'sata'}}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'SATA'}},
ssc_stats)
def test_update_ssc_disk_types_sas(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'interfaceType': {'driveType': 'sas'}}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'SAS'}},
ssc_stats)
def test_update_ssc_disk_types_unknown(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'interfaceType': {'driveType': 'unknown'}}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'unknown'}},
ssc_stats)
def test_update_ssc_disk_types_undefined(self):
drives = [{'currentVolumeGroupRef': 'test_vg1',
'interfaceType': {'driveType': '__UNDEFINED'}}]
- self.driver._client.list_drives = mock.Mock(return_value=drives)
+ self.library._client.list_drives = mock.Mock(return_value=drives)
- ssc_stats = self.driver._update_ssc_disk_types(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_types(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_type': 'unknown'}},
ssc_stats)
def test_update_ssc_disk_encryption_SecType_enabled(self):
pools = [{'volumeGroupRef': 'test_vg1', 'securityType': 'enabled'}]
- self.driver._client.list_storage_pools = mock.Mock(return_value=pools)
+ self.library._client.list_storage_pools = mock.Mock(return_value=pools)
- ssc_stats = self.driver._update_ssc_disk_encryption(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_encryption(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_encryption': 'true'}},
ssc_stats)
def test_update_ssc_disk_encryption_SecType_unknown(self):
pools = [{'volumeGroupRef': 'test_vg1', 'securityType': 'unknown'}]
- self.driver._client.list_storage_pools = mock.Mock(return_value=pools)
+ self.library._client.list_storage_pools = mock.Mock(return_value=pools)
- ssc_stats = self.driver._update_ssc_disk_encryption(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_encryption(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_encryption': 'false'}},
ssc_stats)
def test_update_ssc_disk_encryption_SecType_none(self):
pools = [{'volumeGroupRef': 'test_vg1', 'securityType': 'none'}]
- self.driver._client.list_storage_pools = mock.Mock(return_value=pools)
+ self.library._client.list_storage_pools = mock.Mock(return_value=pools)
- ssc_stats = self.driver._update_ssc_disk_encryption(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_encryption(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_encryption': 'false'}},
ssc_stats)
def test_update_ssc_disk_encryption_SecType_capable(self):
pools = [{'volumeGroupRef': 'test_vg1', 'securityType': 'capable'}]
- self.driver._client.list_storage_pools = mock.Mock(return_value=pools)
+ self.library._client.list_storage_pools = mock.Mock(return_value=pools)
- ssc_stats = self.driver._update_ssc_disk_encryption(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_encryption(['test_vg1'])
self.assertEqual({'test_vg1': {'netapp_disk_encryption': 'false'}},
ssc_stats)
def test_update_ssc_disk_encryption_SecType_garbage(self):
pools = [{'volumeGroupRef': 'test_vg1', 'securityType': 'garbage'}]
- self.driver._client.list_storage_pools = mock.Mock(return_value=pools)
+ self.library._client.list_storage_pools = mock.Mock(return_value=pools)
- ssc_stats = self.driver._update_ssc_disk_encryption(['test_vg1'])
+ ssc_stats = self.library._update_ssc_disk_encryption(['test_vg1'])
self.assertRaises(TypeError, 'test_vg1',
{'netapp_disk_encryption': 'false'}, ssc_stats)
def test_update_ssc_disk_encryption_multiple(self):
pools = [{'volumeGroupRef': 'test_vg1', 'securityType': 'none'},
{'volumeGroupRef': 'test_vg2', 'securityType': 'enabled'}]
- self.driver._client.list_storage_pools = mock.Mock(return_value=pools)
+ self.library._client.list_storage_pools = mock.Mock(return_value=pools)
- ssc_stats = self.driver._update_ssc_disk_encryption(['test_vg1',
- 'test_vg2'])
+ ssc_stats = self.library._update_ssc_disk_encryption(['test_vg1',
+ 'test_vg2'])
self.assertEqual({'test_vg1': {'netapp_disk_encryption': 'false'},
'test_vg2': {'netapp_disk_encryption': 'true'}},
ssc_stats)
- def test_terminate_connection_no_hosts(self):
+ def test_terminate_connection_iscsi_no_hosts(self):
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
- self.mock_object(self.driver._client, 'list_hosts',
+ self.mock_object(self.library._client, 'list_hosts',
mock.Mock(return_value=[]))
self.assertRaises(exception.NotFound,
- self.driver.terminate_connection,
+ self.library.terminate_connection_iscsi,
get_fake_volume(),
connector)
- def test_terminate_connection_volume_not_mapped(self):
+ def test_terminate_connection_iscsi_volume_not_mapped(self):
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
err = self.assertRaises(exception.NetAppDriverException,
- self.driver.terminate_connection,
+ self.library.terminate_connection_iscsi,
get_fake_volume(),
connector)
self.assertIn("not currently mapped to host", six.text_type(err))
- def test_terminate_connection_volume_mapped(self):
+ def test_terminate_connection_iscsi_volume_mapped(self):
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
fake_eseries_volume['listOfMappings'] = [
eseries_fakes.VOLUME_MAPPING
]
- self.mock_object(self.driver._client, 'list_volumes',
+ self.mock_object(self.library._client, 'list_volumes',
mock.Mock(return_value=[fake_eseries_volume]))
self.mock_object(host_mapper, 'unmap_volume_from_host')
- self.driver.terminate_connection(get_fake_volume(), connector)
+ self.library.terminate_connection_iscsi(get_fake_volume(), connector)
self.assertTrue(host_mapper.unmap_volume_from_host.called)
- def test_terminate_connection_volume_not_mapped_initiator_does_not_exist(
+ def test_terminate_connection_iscsi_not_mapped_initiator_does_not_exist(
self):
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
- self.mock_object(self.driver._client, 'list_hosts',
+ self.mock_object(self.library._client, 'list_hosts',
mock.Mock(return_value=[eseries_fakes.HOST_2]))
self.assertRaises(exception.NotFound,
- self.driver.terminate_connection,
+ self.library.terminate_connection_iscsi,
get_fake_volume(),
connector)
- def test_initialize_connection_volume_not_mapped(self):
+ def test_initialize_connection_iscsi_volume_not_mapped(self):
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
- self.mock_object(self.driver._client, 'get_volume_mappings',
+ self.mock_object(self.library._client, 'get_volume_mappings',
mock.Mock(return_value=[]))
self.mock_object(host_mapper, 'map_volume_to_single_host',
mock.Mock(
return_value=eseries_fakes.VOLUME_MAPPING))
- self.driver.initialize_connection(get_fake_volume(), connector)
+ self.library.initialize_connection_iscsi(get_fake_volume(), connector)
- self.assertTrue(self.driver._client.get_volume_mappings.called)
+ self.assertTrue(self.library._client.get_volume_mappings.called)
self.assertTrue(host_mapper.map_volume_to_single_host.called)
- def test_initialize_connection_volume_not_mapped_host_does_not_exist(self):
+ def test_initialize_connection_iscsi_volume_not_mapped_host_does_not_exist(
+ self):
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
- self.mock_object(self.driver._client, 'get_volume_mappings',
+ self.mock_object(self.library._client, 'get_volume_mappings',
mock.Mock(return_value=[]))
- self.mock_object(self.driver._client, 'list_hosts',
+ self.mock_object(self.library._client, 'list_hosts',
mock.Mock(return_value=[]))
- self.mock_object(self.driver._client, 'create_host_with_port',
+ self.mock_object(self.library._client, 'create_host_with_port',
mock.Mock(return_value=eseries_fakes.HOST))
self.mock_object(host_mapper, 'map_volume_to_single_host',
mock.Mock(
return_value=eseries_fakes.VOLUME_MAPPING))
- self.driver.initialize_connection(get_fake_volume(), connector)
+ self.library.initialize_connection_iscsi(get_fake_volume(), connector)
- self.assertTrue(self.driver._client.get_volume_mappings.called)
- self.assertTrue(self.driver._client.list_hosts.called)
- self.assertTrue(self.driver._client.create_host_with_port.called)
+ self.assertTrue(self.library._client.get_volume_mappings.called)
+ self.assertTrue(self.library._client.list_hosts.called)
+ self.assertTrue(self.library._client.create_host_with_port.called)
self.assertTrue(host_mapper.map_volume_to_single_host.called)
- def test_initialize_connection_volume_already_mapped_to_target_host(self):
+ def test_initialize_connection_iscsi_volume_already_mapped_to_target_host(
+ self):
"""Should be a no-op"""
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
self.mock_object(host_mapper, 'map_volume_to_single_host',
mock.Mock(
return_value=eseries_fakes.VOLUME_MAPPING))
- self.driver.initialize_connection(get_fake_volume(), connector)
+ self.library.initialize_connection_iscsi(get_fake_volume(), connector)
self.assertTrue(host_mapper.map_volume_to_single_host.called)
- def test_initialize_connection_volume_mapped_to_another_host(self):
+ def test_initialize_connection_iscsi_volume_mapped_to_another_host(self):
"""Should raise error saying multiattach not enabled"""
connector = {'initiator': eseries_fakes.INITIATOR_NAME}
fake_mapping_to_other_host = copy.deepcopy(
side_effect=exception.NetAppDriverException))
self.assertRaises(exception.NetAppDriverException,
- self.driver.initialize_connection,
+ self.library.initialize_connection_iscsi,
get_fake_volume(), connector)
self.assertTrue(host_mapper.map_volume_to_single_host.called)
-class NetAppEseriesISCSIDriverMultiAttachTestCase(test.TestCase):
+class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase):
"""Test driver behavior when the netapp_enable_multiattach
configuration option is True.
"""
def setUp(self):
- super(NetAppEseriesISCSIDriverMultiAttachTestCase, self).setUp()
+ super(NetAppEseriesLibraryMultiAttachTestCase, self).setUp()
config = eseries_fakes.create_configuration_eseries()
config.netapp_enable_multiattach = True
kwargs = {'configuration': config}
- self.driver = es_iscsi.NetAppEseriesISCSIDriver(**kwargs)
- self.driver._client = eseries_fakes.FakeEseriesClient()
- self.driver.check_for_setup_error()
+ self.library = library.NetAppESeriesLibrary("FAKE", **kwargs)
+ self.library._client = eseries_fakes.FakeEseriesClient()
+ self.library.check_for_setup_error()
def test_do_setup_host_group_already_exists(self):
mock_check_flags = self.mock_object(na_utils, 'check_flags')
- self.mock_object(es_iscsi.NetAppEseriesISCSIDriver,
+ self.mock_object(self.library,
'_check_mode_get_or_register_storage_system')
fake_rest_client = eseries_fakes.FakeEseriesClient()
- self.mock_object(self.driver, '_create_rest_client',
+ self.mock_object(self.library, '_create_rest_client',
mock.Mock(return_value=fake_rest_client))
mock_create = self.mock_object(fake_rest_client, 'create_host_group')
- self.driver.do_setup(mock.Mock())
+ self.library.do_setup(mock.Mock())
self.assertTrue(mock_check_flags.called)
self.assertFalse(mock_create.call_count)
def test_do_setup_host_group_does_not_exist(self):
mock_check_flags = self.mock_object(na_utils, 'check_flags')
fake_rest_client = eseries_fakes.FakeEseriesClient()
- self.mock_object(self.driver, '_create_rest_client',
+ self.mock_object(self.library, '_create_rest_client',
mock.Mock(return_value=fake_rest_client))
mock_get_host_group = self.mock_object(
fake_rest_client, "get_host_group_by_name",
mock.Mock(side_effect=exception.NotFound))
- self.mock_object(es_iscsi.NetAppEseriesISCSIDriver,
+ self.mock_object(self.library,
'_check_mode_get_or_register_storage_system')
- self.driver.do_setup(mock.Mock())
+ self.library.do_setup(mock.Mock())
self.assertTrue(mock_check_flags.called)
self.assertTrue(mock_get_host_group.call_count)
def test_create_volume(self):
- self.driver._client.create_volume = mock.Mock(
+ self.library._client.create_volume = mock.Mock(
return_value=eseries_fakes.VOLUME)
- self.driver.create_volume(get_fake_volume())
- self.assertTrue(self.driver._client.create_volume.call_count)
+ self.library.create_volume(get_fake_volume())
+ self.assertTrue(self.library._client.create_volume.call_count)
def test_create_volume_too_many_volumes(self):
- self.driver._client.list_volumes = mock.Mock(
+ self.library._client.list_volumes = mock.Mock(
return_value=[eseries_fakes.VOLUME for __ in
range(utils.MAX_LUNS_PER_HOST_GROUP + 1)])
- self.driver._client.create_volume = mock.Mock(
+ self.library._client.create_volume = mock.Mock(
return_value=eseries_fakes.VOLUME)
self.assertRaises(exception.NetAppDriverException,
- self.driver.create_volume,
+ self.library.create_volume,
get_fake_volume())
- self.assertFalse(self.driver._client.create_volume.call_count)
+ self.assertFalse(self.library._client.create_volume.call_count)
def test_create_volume_from_snapshot(self):
fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
- self.mock_object(self.driver, "_schedule_and_create_volume",
+ self.mock_object(self.library, "_schedule_and_create_volume",
mock.Mock(return_value=fake_eseries_volume))
- self.mock_object(self.driver, "_create_snapshot_volume",
+ self.mock_object(self.library, "_create_snapshot_volume",
mock.Mock(return_value=fake_eseries_volume))
- self.mock_object(self.driver._client, "delete_snapshot_volume")
+ self.mock_object(self.library._client, "delete_snapshot_volume")
- self.driver.create_volume_from_snapshot(
+ self.library.create_volume_from_snapshot(
get_fake_volume(), fake_snapshot.fake_snapshot_obj(None))
self.assertEqual(
- 1, self.driver._schedule_and_create_volume.call_count)
- self.assertEqual(1, self.driver._create_snapshot_volume.call_count)
+ 1, self.library._schedule_and_create_volume.call_count)
+ self.assertEqual(1, self.library._create_snapshot_volume.call_count)
self.assertEqual(
- 1, self.driver._client.delete_snapshot_volume.call_count)
+ 1, self.library._client.delete_snapshot_volume.call_count)
def test_create_volume_from_snapshot_create_fails(self):
fake_dest_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
- self.mock_object(self.driver, "_schedule_and_create_volume",
+ self.mock_object(self.library, "_schedule_and_create_volume",
mock.Mock(return_value=fake_dest_eseries_volume))
- self.mock_object(self.driver, "_create_snapshot_volume",
+ self.mock_object(self.library, "_create_snapshot_volume",
mock.Mock(side_effect=exception.NetAppDriverException)
)
- self.mock_object(self.driver._client, "delete_snapshot_volume")
- self.mock_object(self.driver._client, "delete_volume")
+ self.mock_object(self.library._client, "delete_snapshot_volume")
+ self.mock_object(self.library._client, "delete_volume")
self.assertRaises(exception.NetAppDriverException,
- self.driver.create_volume_from_snapshot,
+ self.library.create_volume_from_snapshot,
get_fake_volume(),
fake_snapshot.fake_snapshot_obj(None))
self.assertEqual(
- 1, self.driver._schedule_and_create_volume.call_count)
- self.assertEqual(1, self.driver._create_snapshot_volume.call_count)
+ 1, self.library._schedule_and_create_volume.call_count)
+ self.assertEqual(1, self.library._create_snapshot_volume.call_count)
self.assertEqual(
- 0, self.driver._client.delete_snapshot_volume.call_count)
+ 0, self.library._client.delete_snapshot_volume.call_count)
# Ensure the volume we were going to copy to is cleaned up
- self.driver._client.delete_volume.assert_called_once_with(
+ self.library._client.delete_volume.assert_called_once_with(
fake_dest_eseries_volume['volumeRef'])
def test_create_volume_from_snapshot_copy_job_fails(self):
fake_dest_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
- self.mock_object(self.driver, "_schedule_and_create_volume",
+ self.mock_object(self.library, "_schedule_and_create_volume",
mock.Mock(return_value=fake_dest_eseries_volume))
- self.mock_object(self.driver, "_create_snapshot_volume",
+ self.mock_object(self.library, "_create_snapshot_volume",
mock.Mock(return_value=fake_dest_eseries_volume))
- self.mock_object(self.driver._client, "delete_snapshot_volume")
- self.mock_object(self.driver._client, "delete_volume")
+ self.mock_object(self.library._client, "delete_snapshot_volume")
+ self.mock_object(self.library._client, "delete_volume")
fake_failed_volume_copy_job = copy.deepcopy(
eseries_fakes.VOLUME_COPY_JOB)
fake_failed_volume_copy_job['status'] = 'failed'
- self.mock_object(self.driver._client,
+ self.mock_object(self.library._client,
"create_volume_copy_job",
mock.Mock(return_value=fake_failed_volume_copy_job))
- self.mock_object(self.driver._client,
+ self.mock_object(self.library._client,
"list_vol_copy_job",
mock.Mock(return_value=fake_failed_volume_copy_job))
self.assertRaises(exception.NetAppDriverException,
- self.driver.create_volume_from_snapshot,
+ self.library.create_volume_from_snapshot,
get_fake_volume(),
fake_snapshot.fake_snapshot_obj(None))
self.assertEqual(
- 1, self.driver._schedule_and_create_volume.call_count)
- self.assertEqual(1, self.driver._create_snapshot_volume.call_count)
+ 1, self.library._schedule_and_create_volume.call_count)
+ self.assertEqual(1, self.library._create_snapshot_volume.call_count)
self.assertEqual(
- 1, self.driver._client.delete_snapshot_volume.call_count)
+ 1, self.library._client.delete_snapshot_volume.call_count)
# Ensure the volume we were going to copy to is cleaned up
- self.driver._client.delete_volume.assert_called_once_with(
+ self.library._client.delete_volume.assert_called_once_with(
fake_dest_eseries_volume['volumeRef'])
def test_create_volume_from_snapshot_fail_to_delete_snapshot_volume(self):
fake_dest_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
fake_dest_eseries_volume['volumeRef'] = 'fake_volume_ref'
- self.mock_object(self.driver, "_schedule_and_create_volume",
+ self.mock_object(self.library, "_schedule_and_create_volume",
mock.Mock(return_value=fake_dest_eseries_volume))
- self.mock_object(self.driver, "_create_snapshot_volume",
+ self.mock_object(self.library, "_create_snapshot_volume",
mock.Mock(return_value=copy.deepcopy(
eseries_fakes.VOLUME)))
- self.mock_object(self.driver._client, "delete_snapshot_volume",
+ self.mock_object(self.library._client, "delete_snapshot_volume",
mock.Mock(side_effect=exception.NetAppDriverException)
)
- self.mock_object(self.driver._client, "delete_volume")
+ self.mock_object(self.library._client, "delete_volume")
- self.driver.create_volume_from_snapshot(
+ self.library.create_volume_from_snapshot(
get_fake_volume(), fake_snapshot.fake_snapshot_obj(None))
self.assertEqual(
- 1, self.driver._schedule_and_create_volume.call_count)
- self.assertEqual(1, self.driver._create_snapshot_volume.call_count)
+ 1, self.library._schedule_and_create_volume.call_count)
+ self.assertEqual(1, self.library._create_snapshot_volume.call_count)
self.assertEqual(
- 1, self.driver._client.delete_snapshot_volume.call_count)
+ 1, self.library._client.delete_snapshot_volume.call_count)
# Ensure the volume we created is not cleaned up
- self.assertEqual(0, self.driver._client.delete_volume.call_count)
+ self.assertEqual(0, self.library._client.delete_volume.call_count)
- def test_initialize_connection_volume_not_mapped(self):
- """Map the volume directly to destination host.
- """
- connector = {'initiator': eseries_fakes.INITIATOR_NAME_2}
- self.mock_object(self.driver._client, 'get_volume_mappings',
+ def test_map_volume_to_host_volume_not_mapped(self):
+ """Map the volume directly to destination host."""
+ self.mock_object(self.library._client, 'get_volume_mappings',
mock.Mock(return_value=[]))
self.mock_object(host_mapper, 'map_volume_to_single_host',
mock.Mock(
return_value=eseries_fakes.VOLUME_MAPPING))
- self.driver.initialize_connection(get_fake_volume(), connector)
+ self.library.map_volume_to_host(get_fake_volume(),
+ eseries_fakes.VOLUME,
+ eseries_fakes.INITIATOR_NAME_2)
- self.assertTrue(self.driver._client.get_volume_mappings.called)
+ self.assertTrue(self.library._client.get_volume_mappings.called)
self.assertTrue(host_mapper.map_volume_to_single_host.called)
- def test_initialize_connection_volume_not_mapped_host_does_not_exist(self):
+ def test_map_volume_to_host_volume_not_mapped_host_does_not_exist(self):
"""Should create the host map directly to the host."""
- connector = {'initiator': eseries_fakes.INITIATOR_NAME_2}
- self.mock_object(self.driver._client, 'list_hosts',
+ self.mock_object(self.library._client, 'list_hosts',
mock.Mock(return_value=[]))
- self.mock_object(self.driver._client, 'create_host_with_port',
+ self.mock_object(self.library._client, 'create_host_with_port',
mock.Mock(
return_value=eseries_fakes.HOST_2))
- self.mock_object(self.driver._client, 'get_volume_mappings',
+ self.mock_object(self.library._client, 'get_volume_mappings',
mock.Mock(return_value=[]))
self.mock_object(host_mapper, 'map_volume_to_single_host',
mock.Mock(
return_value=eseries_fakes.VOLUME_MAPPING))
- self.driver.initialize_connection(get_fake_volume(), connector)
+ self.library.map_volume_to_host(get_fake_volume(),
+ eseries_fakes.VOLUME,
+ eseries_fakes.INITIATOR_NAME_2)
- self.assertTrue(self.driver._client.create_host_with_port.called)
- self.assertTrue(self.driver._client.get_volume_mappings.called)
+ self.assertTrue(self.library._client.create_host_with_port.called)
+ self.assertTrue(self.library._client.get_volume_mappings.called)
self.assertTrue(host_mapper.map_volume_to_single_host.called)
- def test_initialize_connection_volume_already_mapped(self):
+ def test_map_volume_to_host_volume_already_mapped(self):
"""Should be a no-op."""
- connector = {'initiator': eseries_fakes.INITIATOR_NAME}
self.mock_object(host_mapper, 'map_volume_to_multiple_hosts',
mock.Mock(
return_value=eseries_fakes.VOLUME_MAPPING))
- self.driver.initialize_connection(get_fake_volume(), connector)
+ self.library.map_volume_to_host(get_fake_volume(),
+ eseries_fakes.VOLUME,
+ eseries_fakes.INITIATOR_NAME)
self.assertTrue(host_mapper.map_volume_to_multiple_hosts.called)