def test_power_action(self):
temp_arg_dict = {'host_uuid': 'fake_host_uuid'}
self.host._run_command.return_value = None
cmds = {"reboot": "host-reboot",
"startup": "host-power-on",
"shutdown": "host-shutdown"}
fake_action = 'reboot' # 'statup' and 'shutdown' should be same
expected_cmd_arg_list = [call(["xe", "host-disable", "uuid=%s"
% 'fake_host_uuid']),
call(["xe", "vm-shutdown", "--multiple",
"resident-on=%s" % 'fake_host_uuid']),
call(["xe", cmds[fake_action], "uuid=%s" %
'fake_host_uuid'])]
expected_result = {"power_action": fake_action}
action_result = self.host._power_action(fake_action, temp_arg_dict)
self.assertEqual(self.host._run_command.call_args_list,
expected_cmd_arg_list)
self.assertEqual(action_result, expected_result)
评论列表
文章目录