summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-06-09 21:32:26 -0400
committerCara Salter <cara@devcara.com>2022-06-09 21:32:26 -0400
commit31761bd5fd244900c03f44e98e2d59323c20bfbe (patch)
treee77ca77fcef36ac6002c70fb5d070604dc92d215
parentc3fca2f891372827e37d8aae07bd2223bb3a3327 (diff)
downloadsolarctl-31761bd5fd244900c03f44e98e2d59323c20bfbe.tar.gz
solarctl-31761bd5fd244900c03f44e98e2d59323c20bfbe.zip
view: Open virt-viewer given a server and a UUID
requires that `virt-viewer` is installed on the client machine. Closes #2
-rw-r--r--src/main.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 83d572c..fbe2463 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
+use std::process::Command;
+
use clap::Parser;
mod errors;
use errors::CliError;
@@ -41,6 +43,9 @@ enum Action {
#[clap(long, short)]
force: bool
+ },
+ View {
+ uuid: String
}
}
@@ -67,6 +72,9 @@ fn main() {
Action::Reboot { uuid, force } => {
reboot(root, client, uuid, force).unwrap();
}
+ Action::View { uuid } => {
+ view(root, uuid).unwrap();
+ }
};
}
@@ -160,3 +168,16 @@ fn reboot(server: String, c: Client, u: String, f: bool) -> Result<(), CliError>
Ok(())
}
+
+fn view(server: String, u: String) -> Result<(), CliError> {
+ let host = server.split(':').next().unwrap();
+ let qemu_url = format!("qemu+ssh://{}/system", host);
+
+ let output = Command::new("virt-viewer")
+ .arg("-c")
+ .arg(qemu_url)
+ .arg(u)
+ .output();
+
+ Ok(())
+}