Mercurial > hg > Members > anatofuz > ie-virsh
changeset 64:8dc2c9351a67
Merge branch 'vol-delete' into 'master'
add vol-delete
See merge request ie-syskan/ie-virsh!2
author | 清水 隆博 <k198584@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Dec 2020 17:15:34 +0900 |
parents | aefbef761450 (current diff) f0985ebd068b (diff) |
children | dbf17c045f7a |
files | |
diffstat | 3 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/command.rs Fri Nov 27 20:32:06 2020 +0900 +++ b/src/command.rs Tue Dec 08 17:15:34 2020 +0900 @@ -67,6 +67,11 @@ virsh::subshell_virsh_command(&vm_name, operation); } +pub fn vol_delete(user_name: &str, vm_name: &str, operation: &str) { + let vm_name = exec_cmd_from_name_or_id(user_name, vm_name); + virsh::virsh_vol_delete_command(&vm_name, operation); +} + 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, operation);
--- a/src/main.rs Fri Nov 27 20:32:06 2020 +0900 +++ b/src/main.rs Tue Dec 08 17:15:34 2020 +0900 @@ -180,6 +180,7 @@ SubCommand::Undefine(arg) => { user::set_root_id(); command::subshell(&user_name, &arg.name, "undefine"); + command::vol_delete(&user_name, &arg.name, "vol-delete"); } SubCommand::Domiflist(arg) => {
--- a/src/virsh.rs Fri Nov 27 20:32:06 2020 +0900 +++ b/src/virsh.rs Tue Dec 08 17:15:34 2020 +0900 @@ -9,6 +9,7 @@ const TEMPLATE_DIR: &str = "/ie-ryukyu/kvm/images/templates/"; const TEMPLATE_SUFFIX: &str = "template-"; const TEMPLATE_FILE_EXTENSION: &str = ".qcow2"; +const TEMPLATE_POOL: &str = "rental"; const QCOW2: &str = "qcow2"; pub struct ListDumpMsg { @@ -70,6 +71,19 @@ io::stderr().write_all(&output.stderr).unwrap(); } +pub fn virsh_vol_delete_command(vm_name: &str, operation: &str) { + let output = Command::new("virsh") + .arg(operation) + .arg("--pool") + .arg(TEMPLATE_POOL) + .arg(vm_name) + .output() + .unwrap_or_else(|_| panic!("failed to {}", operation)); + + io::stdout().write_all(&output.stdout).unwrap(); + io::stderr().write_all(&output.stderr).unwrap(); +} + pub fn exec_virsh_command(vm_name: &str, operation: &str) { let err = Command::new("virsh").arg(operation).arg(vm_name).exec(); println!("after exec !!{}", err);