From: Kurt Martin Date: Wed, 13 Feb 2013 19:30:17 +0000 (-0800) Subject: Fibre Channel base class for Cinder drivers X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=af64eac392eb8fc490df3efc3e1f217890c44897;p=openstack-build%2Fcinder-build.git Fibre Channel base class for Cinder drivers This is the base class, FibreChannelDriver, for all fibre channel drivers to extend. Currently, it has only initialize_connection with comments, but this will be a place to put common functions similar to the iSCSI base class. This patch depends on the following nova and devstack changes to be functional(both still in the review process but approved for Grizzly): https://review.openstack.org/#/c/19992/ https://review.openstack.org/#/c/20003/ This patch does not support copy_image_to_volume and copy_volume_to_image in the Grizzly release. We'll revisit this in Havana and add that support. Partially Implements: blueprint fibre-channel-block-storage Change-Id: I8bd28b8bd96deaec1db219457f407169ed172f69 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 6c47f1b95..7fef8478c 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -966,6 +966,17 @@ class ISCSITestCase(DriverTestCase): self.assertEquals(result["target_lun"], 0) +class FibreChannelTestCase(DriverTestCase): + """Test Case for FibreChannelDriver""" + driver_name = "cinder.volume.driver.FibreChannelDriver" + + def test_initialize_connection(self): + self.driver = driver.FibreChannelDriver() + self.driver.do_setup(None) + self.assertRaises(NotImplementedError, + self.driver.initialize_connection, {}, {}) + + class VolumePolicyTestCase(test.TestCase): def setUp(self): diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 96391f028..798a9909c 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -490,3 +490,47 @@ class FakeISCSIDriver(ISCSIDriver): """Execute that simply logs the command.""" LOG.debug(_("FAKE ISCSI: %s"), cmd) return (None, None) + + +class FibreChannelDriver(VolumeDriver): + """Executes commands relating to Fibre Channel volumes.""" + def __init__(self, *args, **kwargs): + super(FibreChannelDriver, self).__init__(*args, **kwargs) + + def initialize_connection(self, volume, connector): + """Initializes the connection and returns connection info. + + The driver returns a driver_volume_type of 'fibre_channel'. + The target_wwn can be a single entry or a list of wwns that + correspond to the list of remote wwn(s) that will export the volume. + Example return values: + + { + 'driver_volume_type': 'fibre_channel' + 'data': { + 'target_discovered': True, + 'target_lun': 1, + 'target_wwn': '1234567890123', + } + } + + or + + { + 'driver_volume_type': 'fibre_channel' + 'data': { + 'target_discovered': True, + 'target_lun': 1, + 'target_wwn': ['1234567890123', '0987654321321'], + } + } + + """ + msg = _("Driver must implement initialize_connection") + raise NotImplementedError(msg) + + def copy_image_to_volume(self, context, volume, image_service, image_id): + raise NotImplementedError() + + def copy_volume_to_image(self, context, volume, image_service, image_meta): + raise NotImplementedError()