12
|
1 use super::virsh;
|
|
2
|
|
3 pub fn list_command(user_name: &'static str) {
|
|
4 let (ldump_msg, vm_list_strs) = virsh::get_vm_list(user_name);
|
|
5 println!("{}", ldump_msg.info_msg);
|
|
6 println!("{}", ldump_msg.border_line);
|
|
7 for vm_info in vm_list_strs {
|
|
8 println!("{}", vm_info);
|
|
9 }
|
|
10 }
|
13
|
11
|
|
12 pub fn start_command(user_name: &'static str, vm_name: String) {
|
|
13 let vm_name = match vm_name.parse::<u8>() {
|
15
|
14 Ok(_) => format!("{}-{}", user_name, vm_name),
|
13
|
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 }
|