Mercurial > hg > Members > anatofuz > ie-virsh
view src/command.rs @ 13:56e9763abeef
define start cmd
author | AnaTofuZ <k198584@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 29 Oct 2020 17:12:09 +0900 |
parents | 0df4d067badb |
children | e6dc51066703 |
line wrap: on
line source
use super::virsh; pub fn list_command(user_name: &'static str) { let (ldump_msg, vm_list_strs) = virsh::get_vm_list(user_name); println!("{}", ldump_msg.info_msg); println!("{}", ldump_msg.border_line); for vm_info in vm_list_strs { println!("{}", vm_info); } } pub fn start_command(user_name: &'static str, vm_name: String) { let vm_name = match vm_name.parse::<u8>() { Ok(_) => String::from(format!("{}-{}", user_name, vm_name)), Err(_) => vm_name, }; let vm_name = if vm_name.starts_with(user_name) { vm_name } else { format!("{}-{}", user_name, vm_name) }; virsh::start_vm(vm_name); }