From c11c7004ffcf3a5c739a4e076cd20554dd2ffc7d Mon Sep 17 00:00:00 2001 From: John Griffith Date: Thu, 20 Aug 2015 15:49:59 -0600 Subject: [PATCH] Add SolidFire svip to config options The SolidFire driver uses a simple method of gathering the Storage Virtual IP, it just queries the Cluster and asks for the SVIP. This is great almost all the time, BUT it doesn't take into consideration that the deployer may be using VLAN's and accessing the cluster from multiple clouds, or multiple networks. This patch just adds a config option to specify an SVIP if the admin has configured VLANs in their environment and on their cluster. The default behavior is to still use the global SVIP. Change-Id: I10b784f903cd8d16580110f01d338a3ad867eada Closes-Bug: #1487194 --- cinder/tests/unit/test_solidfire.py | 29 +++++++++++++++++++++++++++++ cinder/volume/drivers/solidfire.py | 12 +++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cinder/tests/unit/test_solidfire.py b/cinder/tests/unit/test_solidfire.py index 805145731..6ae121dd6 100644 --- a/cinder/tests/unit/test_solidfire.py +++ b/cinder/tests/unit/test_solidfire.py @@ -49,6 +49,7 @@ class SolidFireVolumeTestCase(test.TestCase): self.configuration.iscsi_helper = None self.configuration.sf_template_account_name = 'openstack-vtemplate' self.configuration.sf_allow_template_caching = False + self.configuration.sf_svip = None super(SolidFireVolumeTestCase, self).setUp() self.stubs.Set(solidfire.SolidFireDriver, @@ -984,3 +985,31 @@ class SolidFireVolumeTestCase(test.TestCase): side_effect=_fake_issue_api_req): self.assertEqual(1, sfv._create_template_account('foo')) + + def test_configured_svip(self): + sfv = solidfire.SolidFireDriver(configuration=self.configuration) + + def _fake_get_volumes(account_id): + return [{'volumeID': 1, + 'iqn': ''}] + + def _fake_get_cluster_info(): + return {'clusterInfo': {'svip': 1}} + + with mock.patch.object(sfv, + '_get_volumes_by_sfaccount', + side_effect=_fake_get_volumes),\ + mock.patch.object(sfv, + '_issue_api_request', + side_effect=self.fake_issue_api_request): + + sfaccount = {'targetSecret': 'yakitiyak', + 'accountID': 5, + 'username': 'bobthebuilder'} + v = sfv._get_model_info(sfaccount, 1) + self.assertEqual('1.1.1.1:3260 0', v['provider_location']) + + configured_svip = '9.9.9.9:6500' + self.configuration.sf_svip = configured_svip + v = sfv._get_model_info(sfaccount, 1) + self.assertEqual('%s 0' % configured_svip, v['provider_location']) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index c209c088b..0d9d27c44 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -68,6 +68,13 @@ sf_opts = [ 'a bootable volume is created to eliminate fetch from ' 'glance and qemu-conversion on subsequent calls.'), + cfg.StrOpt('sf_svip', + default=None, + help='Overrides default cluster SVIP with the one specified. ' + 'This is required or deployments that have implemented ' + 'the use of VLANs for iSCSI networks in their cloud.'), + + cfg.IntOpt('sf_api_port', default=443, min=1, max=65535, @@ -320,7 +327,10 @@ class SolidFireDriver(san.SanISCSIDriver): def _get_model_info(self, sfaccount, sf_volume_id): """Gets the connection info for specified account and volume.""" cluster_info = self._get_cluster_info() - iscsi_portal = cluster_info['clusterInfo']['svip'] + ':3260' + if self.configuration.sf_svip is None: + iscsi_portal = cluster_info['clusterInfo']['svip'] + ':3260' + else: + iscsi_portal = self.configuration.sf_svip chap_secret = sfaccount['targetSecret'] found_volume = False -- 2.45.2