Mercurial > hg > Members > anatofuz > ie-virsh
changeset 37:0f966575a56a
use commond_cmd
author | AnaTofuZ <anatofuz@gmail.com> |
---|---|
date | Sun, 22 Nov 2020 11:20:34 +0900 |
parents | 91a99ff9c4c5 |
children | 6f1b90844b7f |
files | src/command.rs src/main.rs |
diffstat | 2 files changed, 11 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/command.rs Sun Nov 22 11:03:09 2020 +0900 +++ b/src/command.rs Sun Nov 22 11:20:34 2020 +0900 @@ -35,41 +35,10 @@ virsh::command_require_vm_name(get_vm_name(user_name, vm_name), "start"); } -pub fn shutdown(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "shutdown") -} - -pub fn destroy(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "destroy") -} - -pub fn console(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "console") -} - -pub fn vncdisplay(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "vncdisplay") +pub fn common_cmd(user_name: &str, vm_name: &str, command: &str) { + exec_cmd_from_name_or_id(user_name, vm_name, command) } -pub fn ttyconsole(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "ttyconsole") -} - -pub fn dumpxml(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "dumpxml") -} - -pub fn undefine(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "undefine") -} - -pub fn domiflist(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "domiflist") -} - -pub fn dominfo(user_name: &str, vm_name: &str) { - exec_cmd_from_name_or_id(user_name, vm_name, "dominfo") -} pub fn dumpvncpasswd(_user_name: &str, _vm_name: &str) {}
--- a/src/main.rs Sun Nov 22 11:03:09 2020 +0900 +++ b/src/main.rs Sun Nov 22 11:20:34 2020 +0900 @@ -137,47 +137,47 @@ SubCommand::Shutdown(arg) => { user::set_root_id(); - command::shutdown(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "shutdown"); } SubCommand::Console(arg) => { user::set_root_id(); - command::console(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "console"); } SubCommand::Destroy(arg) => { user::set_root_id(); - command::destroy(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "destroy"); } SubCommand::Vncdisplay(arg) => { user::set_root_id(); - command::vncdisplay(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "vncdisplay"); } SubCommand::Ttyconsole(arg) => { user::set_root_id(); - command::ttyconsole(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "ttyconsole"); } SubCommand::Dumpxml(arg) => { user::set_root_id(); - command::dumpxml(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "dumpxml"); } SubCommand::Undefine(arg) => { user::set_root_id(); - command::undefine(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "undefine"); } SubCommand::Domiflist(arg) => { user::set_root_id(); - command::domiflist(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "domiflist"); } SubCommand::Dominfo(arg) => { user::set_root_id(); - command::dominfo(&user_name, &arg.name); + command::common_cmd(&user_name, &arg.name, "dominfo"); } SubCommand::Templates(_) => {