comparison 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
comparison
equal deleted inserted replaced
12:0df4d067badb 13:56e9763abeef
6 println!("{}", ldump_msg.border_line); 6 println!("{}", ldump_msg.border_line);
7 for vm_info in vm_list_strs { 7 for vm_info in vm_list_strs {
8 println!("{}", vm_info); 8 println!("{}", vm_info);
9 } 9 }
10 } 10 }
11
12 pub fn start_command(user_name: &'static str, vm_name: String) {
13 let vm_name = match vm_name.parse::<u8>() {
14 Ok(_) => String::from(format!("{}-{}", user_name, vm_name)),
15 Err(_) => vm_name,
16 };
17
18 let vm_name = if vm_name.starts_with(user_name) {
19 vm_name
20 } else {
21 format!("{}-{}", user_name, vm_name)
22 };
23 virsh::start_vm(vm_name);
24 }