# License for the specific language governing permissions and limitations
# under the License.
+import mock
import mox
from oslo.utils import timeutils
from oslo.utils import units
sfv.create_cloned_volume(testvol_b, testvol)
def test_initialize_connector_with_blocksizes(self):
+ expected_iqn = 'iqn.2010-01.com.solidfire:'\
+ '87hg.uuid-2cc06226-cc74-4cb7-bd55-14aed659a0cc.4060'
+ expected_properties = \
+ {'driver_volume_type': 'iscsi',
+ 'data': {'target_discovered': False,
+ 'encrypted': False,
+ 'logical_block_size': '4096',
+ 'physical_block_size': '4096',
+ 'target_iqn': expected_iqn,
+ 'target_portal': '10.10.7.1:3260',
+ 'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
+ 'target_lun': 0,
+ 'auth_password': '2FE0CQ8J196R',
+ 'auth_username':
+ 'stack-1-a60e2611875f40199931f2c76370d66b',
+ 'auth_method': 'CHAP'}}
+
+ connector = {'initiator': 'iqn.2012-07.org.fake:01'}
+ testvol = {'project_id': 'testprjid',
+ 'name': 'testvol',
+ 'size': 1,
+ 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
+ 'volume_type_id': None,
+ 'provider_location': '10.10.7.1:3260 iqn.2010-01.com.'
+ 'solidfire:87hg.uuid-2cc06226-cc'
+ '74-4cb7-bd55-14aed659a0cc.4060 0',
+ 'provider_auth': 'CHAP stack-1-a60e2611875f40199931f2'
+ 'c76370d66b 2FE0CQ8J196R',
+ 'provider_geometry': '4096 4096',
+ 'created_at': timeutils.utcnow(),
+ }
+
+ sfv = SolidFireDriver(configuration=self.configuration)
+ self.assertEqual(sfv.initialize_connection(testvol, connector),
+ expected_properties)
+
+ @mock.patch('cinder.volume.driver.CONF')
+ def test_iscsi_helpers_not_in_base_iscsi_driver(self, mock_conf):
+ # This test is added to check for bug: 1400804
+ # The base iscsi driver should be clean from specifics
+ # regarding tgtadm or LVM driver, this check is here
+ # to make sure nothing regarding specific iscsi_helpers
+ # sneak back in
+ expected_iqn = 'iqn.2010-01.com.solidfire:'\
+ '87hg.uuid-2cc06226-cc74-4cb7-bd55-14aed659a0cc.4060'
+ expected_properties = \
+ {'driver_volume_type': 'iscsi',
+ 'data': {'target_discovered': False,
+ 'encrypted': False,
+ 'logical_block_size': '4096',
+ 'physical_block_size': '4096',
+ 'target_iqn': expected_iqn,
+ 'target_portal': '10.10.7.1:3260',
+ 'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
+ 'target_lun': 0,
+ 'auth_password': '2FE0CQ8J196R',
+ 'auth_username':
+ 'stack-1-a60e2611875f40199931f2c76370d66b',
+ 'auth_method': 'CHAP'}}
+
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
testvol = {'project_id': 'testprjid',
'name': 'testvol',
'created_at': timeutils.utcnow(),
}
+ mock_conf.iscsi_helper = 'lioadm'
+ sfv = SolidFireDriver(configuration=self.configuration)
+ self.assertEqual(sfv.initialize_connection(testvol, connector),
+ expected_properties)
+
+ mock_conf.iscsi_helper = 'iseradm'
+ sfv = SolidFireDriver(configuration=self.configuration)
+ self.assertEqual(sfv.initialize_connection(testvol, connector),
+ expected_properties)
+
+ mock_conf.iscsi_helper = 'tgtadm'
sfv = SolidFireDriver(configuration=self.configuration)
- properties = sfv.initialize_connection(testvol, connector)
- self.assertEqual(properties['data']['physical_block_size'], '4096')
- self.assertEqual(properties['data']['logical_block_size'], '4096')
+ self.assertEqual(sfv.initialize_connection(testvol, connector),
+ expected_properties)
def test_create_volume_with_qos(self):
preset_qos = {}
}
"""
-
- if CONF.iscsi_helper == 'lioadm':
- self.target_helper.initialize_connection(volume, connector)
-
iscsi_properties = self._get_iscsi_properties(volume)
return {
'driver_volume_type': 'iscsi',
raise exception.VolumeBackendAPIException(data=err_msg)
def terminate_connection(self, volume, connector, **kwargs):
- if CONF.iscsi_helper == 'lioadm':
- self.target_helper.terminate_connection(volume, connector)
+ pass
def get_volume_stats(self, refresh=False):
"""Get volume stats.
def get_target_helper(self, db):
root_helper = utils.get_root_helper()
+ # FIXME(jdg): These work because the driver will overide
+ # but we need to move these to use self.configuraiton
if CONF.iscsi_helper == 'iseradm':
return iscsi.ISERTgtAdm(root_helper, CONF.volumes_dir,
CONF.iscsi_target_prefix, db=db)
}
"""
-
iser_properties = self._get_iscsi_properties(volume)
return {
'driver_volume_type': 'iser',
def create_export(self, context, volume):
return self._create_export(context, volume)
+ def initialize_connection(self, volume, connector):
+ """Initializes the connection and returns connection info. """
+
+ # We have a special case for lioadm here, that's fine, we can
+ # keep the call in the parent class (driver:ISCSIDriver) generic
+ # and still use it throughout, just override and call super here
+ # no duplication, same effect but doesn't break things
+ # see bug: #1400804
+ if self.configuration.iscsi_helper == 'lioadm':
+ self.target_helper.initialize_connection(volume, connector)
+ return super(LVMISCSIDriver, self).initialize_connection(volume,
+ connector)
+
+ def terminate_connection(self, volume, connector, **kwargs):
+ if self.configuration.iscsi_helper == 'lioadm':
+ self.target_helper.terminate_connection(volume, connector)
+
def _create_export(self, context, volume, vg=None):
"""Creates an export for a logical volume."""
if vg is None: