Merge "INFINIDAT: validate_connector should validate by protocol"

This commit is contained in:
Zuul 2018-07-23 20:03:02 +00:00 committed by Gerrit Code Review
commit 15c45a0312
2 changed files with 21 additions and 0 deletions

View File

@ -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")

View File

@ -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