annotate src/command.rs @ 15:e6dc51066703

cargo clippy
author AnaTofuZ <anatofuz@gmail.com>
date Sun, 01 Nov 2020 12:52:13 +0900
parents 56e9763abeef
children 1da4937628be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 use super::virsh;
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 pub fn list_command(user_name: &'static str) {
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 let (ldump_msg, vm_list_strs) = virsh::get_vm_list(user_name);
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 println!("{}", ldump_msg.info_msg);
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 println!("{}", ldump_msg.border_line);
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 for vm_info in vm_list_strs {
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 println!("{}", vm_info);
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 }
0df4d067badb move each crates
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 }
13
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
11
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
12 pub fn start_command(user_name: &'static str, vm_name: String) {
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
13 let vm_name = match vm_name.parse::<u8>() {
15
e6dc51066703 cargo clippy
AnaTofuZ <anatofuz@gmail.com>
parents: 13
diff changeset
14 Ok(_) => format!("{}-{}", user_name, vm_name),
13
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
15 Err(_) => vm_name,
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
16 };
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
17
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
18 let vm_name = if vm_name.starts_with(user_name) {
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
19 vm_name
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
20 } else {
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
21 format!("{}-{}", user_name, vm_name)
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
22 };
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
23 virsh::start_vm(vm_name);
56e9763abeef define start cmd
AnaTofuZ <k198584@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
24 }