1239
1239
super(StorwizeSVCDriverTestCase, self).setUp()
1240
1240
self.USESIM = True
1241
1241
if self.USESIM:
1242
self.driver = StorwizeSVCFakeDriver(
1243
configuration=conf.Configuration(None))
1242
1244
self._def_flags = {'san_ip': 'hostname',
1243
1245
'san_login': 'user',
1244
1246
'san_password': 'pass',
1245
1247
'storwize_svc_flashcopy_timeout': 20,
1246
'storwize_svc_connection_protocol': 'iscsi',
1248
# Test ignore capitalization
1249
'storwize_svc_connection_protocol': 'iScSi',
1247
1250
'storwize_svc_multipath_enabled': False}
1248
1251
self._host_name = 'storwize-svc-test'
1249
1252
self._host_ip = '1.234.56.78'
1252
1255
str(random.randint(0, 9999999999999999)).zfill(16)]
1253
1256
self._iscsi_name = ('test.initiator.%s' %
1254
1257
str(random.randint(10000, 99999)))
1256
1258
self.sim = StorwizeSVCManagementSimulator('volpool')
1258
configuration = mox.MockObject(conf.Configuration)
1259
configuration.san_is_local = False
1260
configuration.append_config_values(mox.IgnoreArg())
1262
self.driver = StorwizeSVCFakeDriver(configuration=configuration)
1263
1260
self.driver.set_fake_storage(self.sim)
1262
self.driver = storwize_svc.StorwizeSVCDriver(
1263
configuration=conf.Configuration(None))
1265
1264
self._def_flags = {'san_ip': '1.111.11.11',
1266
1265
'san_login': 'user',
1267
1266
'san_password': 'password',
1268
1267
'storwize_svc_volpool_name': 'openstack',
1269
'storwize_svc_connection_protocol': 'iscsi',
1268
# Test ignore capitalization
1269
'storwize_svc_connection_protocol': 'iScSi',
1270
1270
'storwize_svc_multipath_enabled': False,
1271
1271
'ssh_conn_timeout': 0}
1272
1272
self._host_name = socket.gethostname()
1288
1288
if l.startswith('InitiatorName='):
1289
1289
self._iscsi_name = l[l.index('=') + 1:].strip()
1292
self.driver = storwize_svc.StorwizeSVCDriver()
1294
1292
self.driver.db = StorwizeSVCFakeDB()
1295
1293
self.driver.do_setup(None)
1296
1294
self.driver.check_for_setup_error()
1297
1295
self.stubs.Set(storwize_svc.time, 'sleep', lambda s: None)
1297
def _set_flag(self, flag, value):
1298
group = self.driver.configuration.config_group
1299
self.driver.configuration.set_override(flag, value, group)
1299
1301
def _reset_flags(self):
1301
self.flags(**self._def_flags)
1302
self.driver.configuration.local_conf.reset()
1303
for k, v in self._def_flags.iteritems():
1304
self._set_flag(k, v)
1303
1306
def _assert_vol_exists(self, name, exists):
1304
1307
is_vol_defined = self.driver._is_vdisk_defined(name)
1340
1343
self.driver.do_setup, None)
1342
1345
# Check with bad parameters
1343
self.flags(san_ip='')
1344
self.assertRaises(exception.InvalidInput,
1345
self.driver.check_for_setup_error)
1348
self.flags(san_password=None)
1349
self.flags(san_private_key=None)
1350
self.assertRaises(exception.InvalidInput,
1351
self.driver.check_for_setup_error)
1354
self.flags(storwize_svc_vol_rsize=101)
1355
self.assertRaises(exception.InvalidInput,
1356
self.driver.check_for_setup_error)
1359
self.flags(storwize_svc_vol_warning=101)
1360
self.assertRaises(exception.InvalidInput,
1361
self.driver.check_for_setup_error)
1364
self.flags(storwize_svc_vol_grainsize=42)
1365
self.assertRaises(exception.InvalidInput,
1366
self.driver.check_for_setup_error)
1369
self.flags(storwize_svc_flashcopy_timeout=601)
1370
self.assertRaises(exception.InvalidInput,
1371
self.driver.check_for_setup_error)
1374
self.flags(storwize_svc_vol_compression=True)
1375
self.flags(storwize_svc_vol_rsize=-1)
1376
self.assertRaises(exception.InvalidInput,
1377
self.driver.check_for_setup_error)
1380
self.flags(storwize_svc_connection_protocol='foo')
1381
self.assertRaises(exception.InvalidInput,
1382
self.driver.check_for_setup_error)
1385
self.flags(storwize_svc_connection_protocol='iscsi')
1386
self.flags(storwize_svc_multipath_enabled=True)
1346
self._set_flag('san_ip', '')
1347
self.assertRaises(exception.InvalidInput,
1348
self.driver.check_for_setup_error)
1351
self._set_flag('san_password', None)
1352
self._set_flag('san_private_key', None)
1353
self.assertRaises(exception.InvalidInput,
1354
self.driver.check_for_setup_error)
1357
self._set_flag('storwize_svc_vol_rsize', 101)
1358
self.assertRaises(exception.InvalidInput,
1359
self.driver.check_for_setup_error)
1362
self._set_flag('storwize_svc_vol_warning', 101)
1363
self.assertRaises(exception.InvalidInput,
1364
self.driver.check_for_setup_error)
1367
self._set_flag('storwize_svc_vol_grainsize', 42)
1368
self.assertRaises(exception.InvalidInput,
1369
self.driver.check_for_setup_error)
1372
self._set_flag('storwize_svc_flashcopy_timeout', 601)
1373
self.assertRaises(exception.InvalidInput,
1374
self.driver.check_for_setup_error)
1377
self._set_flag('storwize_svc_vol_compression', True)
1378
self._set_flag('storwize_svc_vol_rsize', -1)
1379
self.assertRaises(exception.InvalidInput,
1380
self.driver.check_for_setup_error)
1383
self._set_flag('storwize_svc_connection_protocol', 'foo')
1384
self.assertRaises(exception.InvalidInput,
1385
self.driver.check_for_setup_error)
1388
self._set_flag('storwize_svc_connection_protocol', 'iSCSI')
1389
self._set_flag('storwize_svc_multipath_enabled', True)
1387
1390
self.assertRaises(exception.InvalidInput,
1388
1391
self.driver.check_for_setup_error)
1389
1392
self._reset_flags()
1391
1394
if self.USESIM:
1392
1395
self.sim.error_injection('lslicense', 'no_compression')
1393
self.flags(storwize_svc_vol_compression=True)
1396
self._set_flag('storwize_svc_vol_compression', True)
1394
1397
self.driver.do_setup(None)
1395
1398
self.assertRaises(exception.InvalidInput,
1396
1399
self.driver.check_for_setup_error)
1690
1692
'host': self._host_name,
1691
1693
'wwpns': self._host_wwpns}
1693
for protocol in ['fc', 'iscsi']:
1695
for protocol in ['FC', 'iSCSI']:
1694
1696
volume1['volume_type_id'] = types[protocol]['id']
1695
1697
volume2['volume_type_id'] = types[protocol]['id']
1697
1699
# Check case where no hosts exist
1698
ret = self.driver._get_host_from_connector(conn)
1699
self.assertEqual(ret, None)
1701
ret = self.driver._get_host_from_connector(conn)
1702
self.assertEqual(ret, None)
1701
1704
# Make sure that the volumes have been created
1702
1705
self._assert_vol_exists(volume1['name'], True)
1703
1706
self._assert_vol_exists(volume2['name'], True)
1705
# Check bad output from lsfabric
1706
if protocol == 'fc' and self.USESIM:
1707
for error in ['remove_field', 'header_mismatch']:
1708
self.sim.error_injection('lsfabric', error)
1709
self.assertRaises(exception.VolumeBackendAPIException,
1710
self.driver.initialize_connection,
1712
host_name = self.driver._get_host_from_connector(conn)
1713
self.assertEqual(host_name, None)
1715
1708
# Initialize connection from the first volume to a host
1716
1709
self.driver.initialize_connection(volume1, conn)
1723
1716
self.driver.delete_volume,
1719
# Check bad output from lsfabric for the 2nd volume
1720
if protocol == 'FC' and self.USESIM:
1721
for error in ['remove_field', 'header_mismatch']:
1722
self.sim.error_injection('lsfabric', error)
1723
self.assertRaises(exception.VolumeBackendAPIException,
1724
self.driver.initialize_connection,
1726
1727
self.driver.terminate_connection(volume1, conn)
1729
host_name = self.driver._get_host_from_connector(conn)
1730
self.assertEqual(host_name, None)
1728
1732
# Check cases with no auth set for host
1729
1733
if self.USESIM: