'san_login': 'user',
'san_password': 'pass',
'storwize_svc_flashcopy_timeout': 20,
- 'storwize_svc_connection_protocol': 'iscsi',
+ # Test ignore capitalization
+ 'storwize_svc_connection_protocol': 'iScSi',
'storwize_svc_multipath_enabled': False}
self._host_name = 'storwize-svc-test'
self._host_ip = '1.234.56.78'
'san_login': 'user',
'san_password': 'password',
'storwize_svc_volpool_name': 'openstack',
- 'storwize_svc_connection_protocol': 'iscsi',
+ # Test ignore capitalization
+ 'storwize_svc_connection_protocol': 'iScSi',
'storwize_svc_multipath_enabled': False,
'ssh_conn_timeout': 0}
self._host_name = socket.gethostname()
self.driver.check_for_setup_error)
self._reset_flags()
- self.flags(storwize_svc_connection_protocol='iscsi')
+ self.flags(storwize_svc_connection_protocol='iSCSI')
self.flags(storwize_svc_multipath_enabled=True)
self.assertRaises(exception.InvalidInput,
self.driver.check_for_setup_error)
def test_storwize_svc_unicode_host_and_volume_names(self):
# We'll check with iSCSI only - nothing protocol-dependednt here
- self.flags(storwize_svc_connection_protocol='iscsi')
+ self.flags(storwize_svc_connection_protocol='iSCSI')
self.driver.do_setup(None)
rand_id = random.randint(10000, 99999)
# Create volume types that we created
types = {}
- for protocol in ['fc', 'iscsi']:
- opts = {'protocol': protocol}
+ for protocol in ['FC', 'iSCSI']:
+ opts = {'storage_protocol': '<in> ' + protocol}
types[protocol] = volume_types.create(ctxt, protocol, opts)
conn = {'initiator': self._iscsi_name,
'host': self._host_name,
'wwpns': self._host_wwpns}
- for protocol in ['fc', 'iscsi']:
+ for protocol in ['FC', 'iSCSI']:
volume1['volume_type_id'] = types[protocol]['id']
volume2['volume_type_id'] = types[protocol]['id']
self._assert_vol_exists(volume2['name'], True)
# Check bad output from lsfabric
- if protocol == 'fc' and self.USESIM:
+ if protocol == 'FC' and self.USESIM:
for error in ['remove_field', 'header_mismatch']:
self.sim.error_injection('lsfabric', error)
self.assertRaises(exception.VolumeBackendAPIException,
'ip': '11.11.11.11',
'host': 'host-%s' % case}
self.sim._add_host_to_list(conn_na)
- volume1['volume_type_id'] = types['iscsi']['id']
+ volume1['volume_type_id'] = types['iSCSI']['id']
if case == 'no_info':
self.sim.error_injection('lsiscsiauth', 'no_info')
self.driver.initialize_connection(volume1, conn_na)
self._assert_vol_exists(volume2['name'], False)
# Delete volume types that we created
- for protocol in ['fc', 'iscsi']:
+ for protocol in ['FC', 'iSCSI']:
volume_types.destroy(ctxt, types[protocol]['id'])
# Check if our host still exists (it should not)
self.fail('%s not less than or equal to %s' % (repr(a), repr(b)))
def test_storwize_svc_get_volume_stats(self):
- #first call, no refresh, expect None
stats = self.driver.get_volume_stats()
- self.assertEqual(stats, {})
-
- #call with refresh
- stats = self.driver.get_volume_stats(refresh=True)
self.assertLessEqual(stats['free_capacity_gb'],
stats['total_capacity_gb'])
if self.USESIM:
help='Maximum number of seconds to wait for FlashCopy to be '
'prepared. Maximum value is 600 seconds (10 minutes).'),
cfg.StrOpt('storwize_svc_connection_protocol',
- default='iscsi',
- help='Connection protocol (iscsi/fc)'),
+ default='iSCSI',
+ help='Connection protocol (iSCSI/FC)'),
cfg.BoolOpt('storwize_svc_multipath_enabled',
default=False,
help='Connect with multipath (currently FC-only)'),
super(StorwizeSVCDriver, self).__init__(*args, **kwargs)
self._storage_nodes = {}
self._enabled_protocols = set()
- self._supported_protocols = ['iscsi', 'fc']
self._compression_enabled = False
self._context = None
for k, node in self._storage_nodes.iteritems():
if ((len(node['ipv4']) or len(node['ipv6']))
and len(node['iscsi_name'])):
- node['enabled_protocols'].append('iscsi')
- self._enabled_protocols.add('iscsi')
+ node['enabled_protocols'].append('iSCSI')
+ self._enabled_protocols.add('iSCSI')
if len(node['WWPN']):
- node['enabled_protocols'].append('fc')
- self._enabled_protocols.add('fc')
+ node['enabled_protocols'].append('FC')
+ self._enabled_protocols.add('FC')
if not len(node['enabled_protocols']):
to_delete.append(k)
LOG.debug(_('leave: do_setup'))
def _build_default_opts(self):
+ # Ignore capitalization
+ protocol = FLAGS.storwize_svc_connection_protocol
+ if protocol.lower() == 'fc':
+ protocol = 'FC'
+ elif protocol.lower() == 'iscsi':
+ protocol = 'iSCSI'
+
opts = {'rsize': FLAGS.storwize_svc_vol_rsize,
'warning': FLAGS.storwize_svc_vol_warning,
'autoexpand': FLAGS.storwize_svc_vol_autoexpand,
'grainsize': FLAGS.storwize_svc_vol_grainsize,
'compression': FLAGS.storwize_svc_vol_compression,
'easytier': FLAGS.storwize_svc_vol_easytier,
- 'protocol': FLAGS.storwize_svc_connection_protocol,
+ 'protocol': protocol,
'multipath': FLAGS.storwize_svc_multipath_enabled}
return opts
host_name is not None,
_('_create_host failed to return the host name.'))
- if vol_opts['protocol'] == 'iscsi':
+ if vol_opts['protocol'] == 'iSCSI':
chap_secret = self._get_chap_secret_for_host(host_name)
if chap_secret is None:
chap_secret = self._add_chapsecret_to_host(host_name)
properties['target_discovered'] = False
properties['target_lun'] = lun_id
properties['volume_id'] = volume['id']
- if vol_opts['protocol'] == 'iscsi':
+ if vol_opts['protocol'] == 'iSCSI':
type_str = 'iscsi'
# We take the first IP address for now. Ideally, OpenStack will
# support iSCSI multipath for improved performance.
ctxt = context.get_admin_context()
volume_type = volume_types.get_volume_type(ctxt, type_id)
specs = volume_type.get('extra_specs')
+ key_trans = {'storage_protocol': 'protocol'}
for key, value in specs.iteritems():
+ if key in key_trans:
+ key = key_trans[key]
+ if key == 'protocol':
+ words = value.split()
+ self._driver_assert(words and
+ len(words) == 2 and
+ words[0] == '<in>',
+ _('protocol must be specified as '
+ '\'<in> iSCSI\' or \'<in> FC\''))
+ del words[0]
+ value = words[0]
if key in opts:
this_type = type(opts[key]).__name__
if this_type == 'int':
def copy_image_to_volume(self, context, volume, image_service, image_id):
opts = self._get_vdisk_params(volume['volume_type_id'])
- if opts['protocol'] == 'iscsi':
+ if opts['protocol'] == 'iSCSI':
# Implemented in base iSCSI class
return super(StorwizeSVCDriver, self).copy_image_to_volume(
context, volume, image_service, image_id)
def copy_volume_to_image(self, context, volume, image_service, image_meta):
opts = self._get_vdisk_params(volume['volume_type_id'])
- if opts['protocol'] == 'iscsi':
+ if opts['protocol'] == 'iSCSI':
# Implemented in base iSCSI class
return super(StorwizeSVCDriver, self).copy_volume_to_image(
context, volume, image_service, image_meta)
def get_volume_stats(self, refresh=False):
"""Get volume status.
- If 'refresh' is True, run update the stats first."""
- if refresh:
+ If we haven't gotten stats yet or 'refresh' is True,
+ run update the stats first."""
+ if not self._stats or refresh:
self._update_volume_status()
return self._stats
data['volume_backend_name'] = 'IBM_STORWIZE_SVC' # To be overwritten
data['vendor_name'] = 'IBM'
data['driver_version'] = '1.1'
- data['storage_protocol'] = 'iSCSI'
- data['storage_protocols'] = self._enabled_protocols
+ data['storage_protocol'] = list(self._enabled_protocols)
- data['total_capacity_gb'] = 0
- data['free_capacity_gb'] = 0
+ data['total_capacity_gb'] = 0 # To be overwritten
+ data['free_capacity_gb'] = 0 # To be overwritten
data['reserved_percentage'] = 0
data['QoS_support'] = False
'enabled': ','.join(self._enabled_protocols)})
# Check that multipath is only enabled for fc
- if opts['protocol'] != 'fc' and opts['multipath']:
+ if opts['protocol'] != 'FC' and opts['multipath']:
raise exception.InvalidInput(
reason=_('Multipath is currently only supported for FC '
'connections and not iSCSI. (This is a Nova '