aboutsummaryrefslogtreecommitdiff
path: root/src/garage/cli.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-19 16:16:10 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-19 23:39:45 +0200
commita8ae78af0ad2174480e64f9d4dd43b8381932f42 (patch)
treeb8b5c71a231f938af633be8502c78e7193f9f6ab /src/garage/cli.rs
parent65070f3c05775f6692f4a16b6a304991d0510301 (diff)
downloadgarage-a8ae78af0ad2174480e64f9d4dd43b8381932f42.tar.gz
garage-a8ae78af0ad2174480e64f9d4dd43b8381932f42.zip
Adapt tests to new syntax with public keys
Diffstat (limited to 'src/garage/cli.rs')
-rw-r--r--src/garage/cli.rs35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/garage/cli.rs b/src/garage/cli.rs
index 940a5a85..67606b97 100644
--- a/src/garage/cli.rs
+++ b/src/garage/cli.rs
@@ -1,5 +1,4 @@
use std::collections::HashSet;
-use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
@@ -21,7 +20,12 @@ use crate::admin_rpc::*;
pub enum Command {
/// Run Garage server
#[structopt(name = "server")]
- Server(ServerOpt),
+ Server,
+
+ /// Print identifier (public key) of this garage node.
+ /// Generates a new keypair if necessary.
+ #[structopt(name = "node-id")]
+ NodeId(NodeIdOpt),
/// Get network status
#[structopt(name = "status")]
@@ -49,13 +53,6 @@ pub enum Command {
}
#[derive(StructOpt, Debug)]
-pub struct ServerOpt {
- /// Configuration file
- #[structopt(short = "c", long = "config", default_value = "./config.toml")]
- pub config_file: PathBuf,
-}
-
-#[derive(StructOpt, Debug)]
pub enum NodeOperation {
/// Connect to Garage node that is currently isolated from the system
#[structopt(name = "connect")]
@@ -71,6 +68,13 @@ pub enum NodeOperation {
}
#[derive(StructOpt, Debug)]
+pub struct NodeIdOpt {
+ /// Do not print usage instructions to stderr
+ #[structopt(short = "q", long = "quiet")]
+ pub(crate) quiet: bool,
+}
+
+#[derive(StructOpt, Debug)]
pub struct ConnectNodeOpt {
/// Node public key and address, in the format:
/// `<public key hexadecimal>@<ip or hostname>:<port>`
@@ -384,7 +388,8 @@ pub async fn cmd_status(rpc_cli: &Endpoint<SystemRpc, ()>, rpc_host: NodeID) ->
.any(|(id, _)| !status_keys.contains(id));
if failure_case_1 || failure_case_2 {
println!("\nFailed nodes:");
- let mut failed_nodes = vec!["ID\tHostname\tAddress\tTag\tZone\tCapacity\tLast seen".to_string()];
+ let mut failed_nodes =
+ vec!["ID\tHostname\tAddress\tTag\tZone\tCapacity\tLast seen".to_string()];
for adv in status.iter().filter(|adv| !adv.is_up) {
if let Some(cfg) = config.members.get(&adv.id) {
failed_nodes.push(format!(
@@ -421,14 +426,15 @@ pub async fn cmd_connect(
rpc_host: NodeID,
args: ConnectNodeOpt,
) -> Result<(), Error> {
- match rpc_cli.call(&rpc_host, &SystemRpc::Connect(args.node), PRIO_NORMAL).await?? {
+ match rpc_cli
+ .call(&rpc_host, &SystemRpc::Connect(args.node), PRIO_NORMAL)
+ .await??
+ {
SystemRpc::Ok => {
println!("Success.");
Ok(())
}
- r => {
- Err(Error::BadRpc(format!("Unexpected response: {:?}", r)))
- }
+ r => Err(Error::BadRpc(format!("Unexpected response: {:?}", r))),
}
}
@@ -654,4 +660,3 @@ pub fn find_matching_node(
Ok(candidates[0])
}
}
-