self.assertNotEqual(host_name, None)
self.driver._delete_host(host_name)
+ def test_storwize_svc_validate_connector(self):
+ conn_neither = {'host': 'host'}
+ conn_iscsi = {'host': 'host', 'initiator': 'foo'}
+ conn_fc = {'host': 'host', 'wwpns': 'bar'}
+ conn_both = {'host': 'host', 'initiator': 'foo', 'wwpns': 'bar'}
+
+ self.driver._enabled_protocols = set(['iSCSI'])
+ self.driver.validate_connector(conn_iscsi)
+ self.driver.validate_connector(conn_both)
+ self.assertRaises(exception.VolumeBackendAPIException,
+ self.driver.validate_connector, conn_fc)
+ self.assertRaises(exception.VolumeBackendAPIException,
+ self.driver.validate_connector, conn_neither)
+
+ self.driver._enabled_protocols = set(['FC'])
+ self.driver.validate_connector(conn_fc)
+ self.driver.validate_connector(conn_both)
+ self.assertRaises(exception.VolumeBackendAPIException,
+ self.driver.validate_connector, conn_iscsi)
+ self.assertRaises(exception.VolumeBackendAPIException,
+ self.driver.validate_connector, conn_neither)
+
+ self.driver._enabled_protocols = set(['iSCSI', 'FC'])
+ self.driver.validate_connector(conn_iscsi)
+ self.driver.validate_connector(conn_fc)
+ self.driver.validate_connector(conn_both)
+ self.assertRaises(exception.VolumeBackendAPIException,
+ self.driver.validate_connector, conn_neither)
+
def test_storwize_svc_host_maps(self):
# Create two volumes to be used in mappings
return wwpns
+ def validate_connector(self, connector):
+ """Check connector for at least one enabled protocol (iSCSI/FC)."""
+ valid = False
+ if 'iSCSI' in self._enabled_protocols and 'initiator' in connector:
+ valid = True
+ if 'FC' in self._enabled_protocols and 'wwpns' in connector:
+ valid = True
+ if not valid:
+ err_msg = (_('The connector does not contain the required '
+ 'information.'))
+ LOG.error(err_msg)
+ raise exception.VolumeBackendAPIException(data=err_msg)
+
def initialize_connection(self, volume, connector):
"""Perform the necessary work so that an iSCSI/FC connection can
be made.