diff --git a/cinder/tests/unit/volume/drivers/test_infinidat.py b/cinder/tests/unit/volume/drivers/test_infinidat.py index f62960a6709..9b5555992b3 100644 --- a/cinder/tests/unit/volume/drivers/test_infinidat.py +++ b/cinder/tests/unit/volume/drivers/test_infinidat.py @@ -562,6 +562,13 @@ class InfiniboxDriverTestCaseFC(InfiniboxDriverTestCaseBase): result = self.driver.initialize_connection(test_volume, connector) self.assertEqual(1, result["data"]["target_lun"]) + def test_validate_connector(self): + fc_connector = {'wwpns': [TEST_WWN_1, TEST_WWN_2]} + iscsi_connector = {'initiator': TEST_IQN} + self.driver.validate_connector(fc_connector) + self.assertRaises(exception.InvalidConnectorException, + self.driver.validate_connector, iscsi_connector) + class InfiniboxDriverTestCaseISCSI(InfiniboxDriverTestCaseBase): def setUp(self): @@ -628,6 +635,13 @@ class InfiniboxDriverTestCaseISCSI(InfiniboxDriverTestCaseBase): def test_terminate_connection(self): self.driver.terminate_connection(test_volume, test_connector) + def test_validate_connector(self): + fc_connector = {'wwpns': [TEST_WWN_1, TEST_WWN_2]} + iscsi_connector = {'initiator': TEST_IQN} + self.driver.validate_connector(iscsi_connector) + self.assertRaises(exception.InvalidConnectorException, + self.driver.validate_connector, fc_connector) + class InfiniboxDriverTestCaseQoS(InfiniboxDriverTestCaseBase): @mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs") diff --git a/cinder/volume/drivers/infinidat.py b/cinder/volume/drivers/infinidat.py index 40b98dc221b..f5292aa9eb9 100644 --- a/cinder/volume/drivers/infinidat.py +++ b/cinder/volume/drivers/infinidat.py @@ -174,6 +174,13 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): raise exception.VolumeDriverException(message=msg) LOG.debug('setup complete') + def validate_connector(self, connector): + required = 'initiator' if self._protocol == 'iSCSI' else 'wwpns' + if required not in connector: + LOG.error('The volume driver requires %(data)s ' + 'in the connector.', {'data': required}) + raise exception.InvalidConnectorException(missing=required) + def _make_volume_name(self, cinder_volume): return 'openstack-vol-%s' % cinder_volume.id