Merge "SSH driver: Remove pipes from virsh's list_{all, running}"

This commit is contained in:
Jenkins 2016-03-12 14:25:10 +00:00 committed by Gerrit Code Review
commit 34ed06b9be
3 changed files with 9 additions and 6 deletions

View File

@ -196,10 +196,8 @@ def _get_command_sets(virt_type):
'start_cmd': 'start {_NodeName_}',
'stop_cmd': 'destroy {_NodeName_}',
'reboot_cmd': 'reset {_NodeName_}',
'list_all': "list --all | tail -n +2 | awk -F\" \" '{print $2}'",
'list_running': (
"list --all|grep running | "
"awk -v qc='\"' -F\" \" '{print qc$2qc}'"),
'list_all': 'list --all --name',
'list_running': 'list --name',
'get_node_macs': (
"dumpxml {_NodeName_} | "
"awk -F \"'\" '/mac address/{print $2}'| tr -d ':'"),

View File

@ -40,12 +40,12 @@ def get_test_ipmi_bridging_parameters():
}
def get_test_ssh_info(auth_type='password'):
def get_test_ssh_info(auth_type='password', virt_type='virsh'):
result = {
"ssh_address": "1.2.3.4",
"ssh_username": "admin",
"ssh_port": 22,
"ssh_virt_type": "vbox",
"ssh_virt_type": virt_type,
}
if 'password' == auth_type:
result['ssh_password'] = 'fake'

View File

@ -318,6 +318,9 @@ class SSHPrivateMethodsTestCase(db_base.DbTestCase):
pstate = ssh._get_power_status(self.sshclient, info)
self.assertEqual(states.POWER_OFF, pstate)
ssh_cmd = "%s %s" % (info['cmd_set']['base_cmd'],
info['cmd_set']['list_running'])
exec_ssh_mock.assert_called_once_with(self.sshclient, ssh_cmd)
@mock.patch.object(processutils, 'ssh_execute', autospec=True)
def test__get_hosts_name_for_node_match(self, exec_ssh_mock):
@ -1099,6 +1102,8 @@ class SSHDriverTestCase(db_base.DbTestCase):
def test_console_validate_not_virsh(self):
with task_manager.acquire(
self.context, self.node.uuid, shared=True) as task:
task.node.driver_info = db_utils.get_test_ssh_info(
virt_type='vbox')
self.assertRaisesRegex(exception.InvalidParameterValue,
'not supported for non-virsh types',
task.driver.console.validate, task)