# current status is available
volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
'provider_location': ''})
+ connector = {'initiator': 'iqn.2012-07.org.fake:01'}
# start service to handle rpc messages for attach requests
svc = self.start_service('volume', host='test')
self.volume_api.reserve_volume(ctx, volume)
- self.volume_api.initialize_connection(ctx, volume, {})
+ self.volume_api.initialize_connection(ctx, volume, connector)
mountpoint = '/dev/vbd'
self.volume_api.attach(ctx, volume, stubs.FAKE_UUID, mountpoint)
# volume is attached
# current status is available
volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
'provider_location': ''})
+ connector = {'initiator': 'iqn.2012-07.org.fake:01'}
# start service to handle rpc messages for attach requests
svc = self.start_service('volume', host='test')
self.volume_api.reserve_volume(ctx, volume)
- self.volume_api.initialize_connection(ctx, volume, {})
+ self.volume_api.initialize_connection(ctx, volume, connector)
mountpoint = '/dev/vbd'
self.volume_api.attach(ctx, volume, stubs.FAKE_UUID, mountpoint)
self.assertRaises(exception.InvalidVolume,
# cleanup
svc.stop()
+ def test_invalid_iscsi_connector(self):
+ """Test connector without the initiator (required by iscsi driver)."""
+ # admin context
+ ctx = context.RequestContext('admin', 'fake', True)
+ # current status is available
+ volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
+ 'provider_location': ''})
+ connector = {}
+ # start service to handle rpc messages for attach requests
+ svc = self.start_service('volume', host='test')
+ self.assertRaises(exception.VolumeBackendAPIException,
+ self.volume_api.initialize_connection,
+ ctx, volume, connector)
+ # cleanup
+ svc.stop()
+
def test_attach_attaching_volume_with_different_instance(self):
"""Test that attaching volume reserved for another instance fails."""
# admin context
# current status is available
volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
'provider_location': ''})
+ connector = {'initiator': 'iqn.2012-07.org.fake:01'}
# start service to handle rpc messages for attach requests
svc = self.start_service('volume', host='test')
- self.volume_api.initialize_connection(ctx, volume, {})
+ self.volume_api.initialize_connection(ctx, volume, connector)
values = {'status': 'attaching',
'instance_uuid': fakes.get_fake_uuid()}
db.volume_update(ctx, volume['id'], values)
self.assertEquals(stats['total_capacity_gb'], float('5.52'))
self.assertEquals(stats['free_capacity_gb'], float('0.52'))
+ def test_validate_connector(self):
+ iscsi_driver = driver.ISCSIDriver()
+ # Validate a valid connector
+ connector = {'ip': '10.0.0.2',
+ 'host': 'fakehost',
+ 'initiator': 'iqn.2012-07.org.fake:01'}
+ iscsi_driver.validate_connector(connector)
+
+ # Validate a connector without the initiator
+ connector = {'ip': '10.0.0.2', 'host': 'fakehost'}
+ self.assertRaises(exception.VolumeBackendAPIException,
+ iscsi_driver.validate_connector, connector)
+
class FibreChannelTestCase(DriverTestCase):
"""Test Case for FibreChannelDriver"""
"""Any initialization the volume driver does while starting"""
pass
+ def validate_connector(self, connector):
+ """Fail if connector doesn't contain all the data needed by driver"""
+ pass
+
def copy_image_to_volume(self, context, volume, image_service, image_id):
"""Fetch the image from image_service and write it to the volume."""
raise NotImplementedError()
'data': iscsi_properties
}
+ def validate_connector(self, connector):
+ # iSCSI drivers require the initiator information
+ if 'initiator' not in connector:
+ err_msg = (_('The volume driver requires the iSCSI initiator '
+ 'name in the connector.'))
+ LOG.error(err_msg)
+ raise exception.VolumeBackendAPIException(data=err_msg)
+
def terminate_connection(self, volume, connector, **kwargs):
pass