Mercurial > hg > Members > anatofuz > ie-virsh
changeset 62:aefbef761450
add edit cmd
author | AnaTofuZ <anatofuz@gmail.com> |
---|---|
date | Fri, 27 Nov 2020 20:32:06 +0900 |
parents | b6e9e473678c |
children | f0985ebd068b 8dc2c9351a67 |
files | src/command.rs src/main.rs |
diffstat | 2 files changed, 29 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/command.rs Fri Nov 27 20:20:01 2020 +0900 +++ b/src/command.rs Fri Nov 27 20:32:06 2020 +0900 @@ -62,14 +62,14 @@ virsh::subshell_virsh_command(&get_vm_name(user_name, vm_name), "start"); } -pub fn common(user_name: &str, vm_name: &str, command: &str) { +pub fn subshell(user_name: &str, vm_name: &str, operation: &str) { let vm_name = exec_cmd_from_name_or_id(user_name, vm_name); - virsh::subshell_virsh_command(&vm_name, command); + virsh::subshell_virsh_command(&vm_name, operation); } -pub fn console(user_name: &str, vm_name: &str) { +pub fn exec(user_name: &str, vm_name: &str, operation: &str) { let vm_name = exec_cmd_from_name_or_id(user_name, vm_name); - virsh::exec_virsh_command(&vm_name, "console"); + virsh::exec_virsh_command(&vm_name, operation); } pub fn dumpvncpasswd(_user_name: &str, _vm_name: &str) {}
--- a/src/main.rs Fri Nov 27 20:20:01 2020 +0900 +++ b/src/main.rs Fri Nov 27 20:32:06 2020 +0900 @@ -24,6 +24,7 @@ Domiflist(Domiflist), Dominfo(Dominfo), Templates(Templates), + Edit(Edit), } /// show templates vm @@ -85,6 +86,12 @@ #[derive(Clap)] struct List {} +/// edit XML configuration for a domain +#[derive(Clap)] +struct Edit { + name: String, +} + /// destroy (stop) a domain #[derive(Clap)] struct Destroy { @@ -147,47 +154,52 @@ SubCommand::Shutdown(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "shutdown"); - } - - SubCommand::Console(arg) => { - user::set_root_id(); - command::console(&user_name, &arg.name); + command::subshell(&user_name, &arg.name, "shutdown"); } SubCommand::Destroy(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "destroy"); + command::subshell(&user_name, &arg.name, "destroy"); } SubCommand::Vncdisplay(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "vncdisplay"); + command::subshell(&user_name, &arg.name, "vncdisplay"); } SubCommand::Ttyconsole(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "ttyconsole"); + command::subshell(&user_name, &arg.name, "ttyconsole"); } SubCommand::Dumpxml(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "dumpxml"); + command::subshell(&user_name, &arg.name, "dumpxml"); } SubCommand::Undefine(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "undefine"); + command::subshell(&user_name, &arg.name, "undefine"); } SubCommand::Domiflist(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "domiflist"); + command::subshell(&user_name, &arg.name, "domiflist"); } SubCommand::Dominfo(arg) => { user::set_root_id(); - command::common(&user_name, &arg.name, "dominfo"); + command::subshell(&user_name, &arg.name, "dominfo"); + } + + SubCommand::Console(arg) => { + user::set_root_id(); + command::exec(&user_name, &arg.name, "console"); + } + + SubCommand::Edit(arg) => { + user::set_root_id(); + command::exec(&user_name, &arg.name, "edit"); } SubCommand::Templates(_) => {