return_value=(HNAS_RESULT5, ''))
@mock.patch.object(utils, 'execute')
@mock.patch.object(time, 'sleep')
- def test_run_cmd(self, m_sleep, m_utl, m_ssh, m_ssh_cli,
- m_pvt_key, m_file, m_open):
+ def test_run_cmd(self, m_sleep, m_utl, m_ssh, m_ssh_cli, m_pvt_key,
+ m_file, m_open):
save_hkey_file = CONF.ssh_hosts_key_file
save_spath = CONF.state_path
CONF.ssh_hosts_key_file = '/var/lib/cinder/ssh_known_hosts'
CONF.state_path = '/var/lib/cinder'
# Test main flow
+ self.hnas_bend.drv_configs['ssh_enabled'] = 'True'
out, err = self.hnas_bend.run_cmd('ssh', '0.0.0.0',
'supervisor', 'supervisor',
'df', '-a')
self.assertIn('11.2.3319.14', out)
self.assertIn('83-68-96-AA-DA-5D', out)
+ @mock.patch.object(hnas_backend.HnasBackend, 'run_cmd',
+ side_effect=m_run_cmd)
+ def test_get_version_ssh_cluster(self, m_cmd):
+ self.hnas_bend.drv_configs['ssh_enabled'] = 'True'
+ self.hnas_bend.drv_configs['cluster_admin_ip0'] = '1.1.1.1'
+ out = self.hnas_bend.get_version("ssh", "1.0", "0.0.0.0", "supervisor",
+ "supervisor")
+ self.assertIn('11.2.3319.14', out)
+ self.assertIn('83-68-96-AA-DA-5D', out)
+
+ @mock.patch.object(hnas_backend.HnasBackend, 'run_cmd',
+ side_effect=m_run_cmd)
+ @mock.patch.object(utils, 'execute', return_value=UTILS_EXEC_OUT)
+ def test_get_version_ssh_disable(self, m_cmd, m_exec):
+ self.hnas_bend.drv_configs['ssh_enabled'] = 'False'
+ out = self.hnas_bend.get_version("ssh", "1.0", "0.0.0.0", "supervisor",
+ "supervisor")
+ self.assertIn('11.2.3319.14', out)
+ self.assertIn('83-68-96-AA-DA-5D', out)
+ self.assertIn('Utility_version', out)
+
@mock.patch.object(hnas_backend.HnasBackend, 'run_cmd',
side_effect=m_run_cmd)
def test_get_iscsi_info(self, m_execute):
raise exception.HNASConnError(msg)
else:
raise
-
else:
if self.drv_configs['cluster_admin_ip0'] is None:
# Connect to SMU through SSH and run ssc locally
:param ip0: string IP address of controller
:param user: string user authentication for array
:param pw: string password authentication for array
- :returns: formated string with version information
+ :returns: formatted string with version information
"""
- if (self.drv_configs['ssh_enabled'] == 'True' and
- self.drv_configs['cluster_admin_ip0'] is not None):
- util = 'SMU ' + cmd
- else:
- out, err = utils.execute(cmd,
- "-version",
- check_exit_code=True)
- util = out.split()[1]
-
out, err = self.run_cmd(cmd, ip0, user, pw, "cluster-getmac",
check_exit_code=True)
hardware = out.split()[2]
+
out, err = self.run_cmd(cmd, ip0, user, pw, "ver",
check_exit_code=True)
lines = out.split('\n')
if 'Software:' in line:
ver = line.split()[1]
- out = "Array_ID: %s (%s) version: %s LU: 256 RG: 0 RG_LU: 0 \
- Utility_version: %s" % (hardware, model, ver, util)
+ # If not using SSH, the local utility version can be different from the
+ # one used in HNAS
+ if self.drv_configs['ssh_enabled'] != 'True':
+ out, err = utils.execute(cmd, "-version", check_exit_code=True)
+ util = out.split()[1]
+
+ out = ("Array_ID: %(arr)s (%(mod)s) version: %(ver)s LU: 256 "
+ "RG: 0 RG_LU: 0 Utility_version: %(util)s" %
+ {'arr': hardware, 'mod': model, 'ver': ver, 'util': util})
+ else:
+ out = ("Array_ID: %(arr)s (%(mod)s) version: %(ver)s LU: 256 "
+ "RG: 0 RG_LU: 0" %
+ {'arr': hardware, 'mod': model, 'ver': ver})
LOG.debug('get_version: %(out)s -- %(err)s', {'out': out, 'err': err})
return out