if self.USESIM:
self.driver = StorwizeSVCISCSIFakeDriver(
configuration=conf.Configuration(None))
+ self._driver = storwize_svc_iscsi.StorwizeSVCISCSIDriver(
+ configuration=conf.Configuration(None))
self._def_flags = {'san_ip': 'hostname',
+ 'storwize_san_secondary_ip': 'secondaryname',
'san_login': 'user',
'san_password': 'pass',
- 'storwize_svc_volpool_name': 'openstack',
+ 'storwize_svc_volpool_name':
+ ['openstack', 'openstack1'],
'storwize_svc_flashcopy_timeout': 20,
'storwize_svc_flashcopy_rate': 49,
'storwize_svc_allow_tenant_qos': True}
# Finally, check with good parameters
self.driver.do_setup(None)
+ @mock.patch.object(ssh_utils, 'SSHPool')
+ @mock.patch.object(processutils, 'ssh_execute')
+ def test_run_ssh_set_up_with_san_ip(self, mock_ssh_execute, mock_ssh_pool):
+ ssh_cmd = ['svcinfo']
+ self._driver._run_ssh(ssh_cmd)
+
+ mock_ssh_pool.assert_called_once_with(
+ self._driver.configuration.san_ip,
+ self._driver.configuration.san_ssh_port,
+ self._driver.configuration.ssh_conn_timeout,
+ self._driver.configuration.san_login,
+ password=self._driver.configuration.san_password,
+ privatekey=self._driver.configuration.san_private_key,
+ min_size=self._driver.configuration.ssh_min_pool_conn,
+ max_size=self._driver.configuration.ssh_max_pool_conn)
+
+ @mock.patch.object(ssh_utils, 'SSHPool')
+ @mock.patch.object(processutils, 'ssh_execute')
+ def test_run_ssh_set_up_with_secondary_ip(self, mock_ssh_execute,
+ mock_ssh_pool):
+ mock_ssh_pool.side_effect = [paramiko.SSHException, mock.MagicMock()]
+ ssh_cmd = ['svcinfo']
+ self._driver._run_ssh(ssh_cmd)
+
+ mock_ssh_pool.assert_called_with(
+ self._driver.configuration.storwize_san_secondary_ip,
+ self._driver.configuration.san_ssh_port,
+ self._driver.configuration.ssh_conn_timeout,
+ self._driver.configuration.san_login,
+ password=self._driver.configuration.san_password,
+ privatekey=self._driver.configuration.san_private_key,
+ min_size=self._driver.configuration.ssh_min_pool_conn,
+ max_size=self._driver.configuration.ssh_max_pool_conn)
+
+ @mock.patch.object(ssh_utils, 'SSHPool')
+ @mock.patch.object(processutils, 'ssh_execute')
+ def test_run_ssh_fail_to_secondary_ip(self, mock_ssh_execute,
+ mock_ssh_pool):
+ mock_ssh_execute.side_effect = [processutils.ProcessExecutionError,
+ mock.MagicMock()]
+ ssh_cmd = ['svcinfo']
+ self._driver._run_ssh(ssh_cmd)
+
+ mock_ssh_pool.assert_called_with(
+ self._driver.configuration.storwize_san_secondary_ip,
+ self._driver.configuration.san_ssh_port,
+ self._driver.configuration.ssh_conn_timeout,
+ self._driver.configuration.san_login,
+ password=self._driver.configuration.san_password,
+ privatekey=self._driver.configuration.san_private_key,
+ min_size=self._driver.configuration.ssh_min_pool_conn,
+ max_size=self._driver.configuration.ssh_max_pool_conn)
+
def _generate_vol_info(self, vol_name, vol_id):
+ pool = self._def_flags['storwize_svc_volpool_name'][0]
rand_id = six.text_type(random.randint(10000, 99999))
if vol_name:
return {'name': 'snap_volume%s' % rand_id,