aboutsummaryrefslogtreecommitdiff
path: root/src/garage/cli/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/garage/cli/util.rs')
-rw-r--r--src/garage/cli/util.rs137
1 files changed, 1 insertions, 136 deletions
diff --git a/src/garage/cli/util.rs b/src/garage/cli/util.rs
index c591cadd..acf7923e 100644
--- a/src/garage/cli/util.rs
+++ b/src/garage/cli/util.rs
@@ -5,51 +5,17 @@ use format_table::format_table;
use garage_util::background::*;
use garage_util::crdt::*;
use garage_util::data::*;
-use garage_util::error::*;
use garage_util::time::*;
use garage_block::manager::BlockResyncErrorInfo;
use garage_model::bucket_table::*;
use garage_model::key_table::*;
-use garage_model::s3::mpu_table::{self, MultipartUpload};
-use garage_model::s3::object_table;
+use garage_model::s3::mpu_table::MultipartUpload;
use garage_model::s3::version_table::*;
use crate::cli::structs::WorkerListOpt;
-pub fn print_bucket_list(bl: Vec<Bucket>) {
- println!("List of buckets:");
-
- let mut table = vec![];
- for bucket in bl {
- let aliases = bucket
- .aliases()
- .iter()
- .filter(|(_, _, active)| *active)
- .map(|(name, _, _)| name.to_string())
- .collect::<Vec<_>>();
- let local_aliases_n = match &bucket
- .local_aliases()
- .iter()
- .filter(|(_, _, active)| *active)
- .collect::<Vec<_>>()[..]
- {
- [] => "".into(),
- [((k, n), _, _)] => format!("{}:{}", k, n),
- s => format!("[{} local aliases]", s.len()),
- };
-
- table.push(format!(
- "\t{}\t{}\t{}",
- aliases.join(","),
- local_aliases_n,
- hex::encode(bucket.id),
- ));
- }
- format_table(table);
-}
-
pub fn print_key_list(kl: Vec<(String, String)>) {
println!("List of keys:");
let mut table = vec![];
@@ -132,107 +98,6 @@ pub fn print_key_info(key: &Key, relevant_buckets: &HashMap<Uuid, Bucket>) {
}
}
-pub fn print_bucket_info(
- bucket: &Bucket,
- relevant_keys: &HashMap<String, Key>,
- counters: &HashMap<String, i64>,
- mpu_counters: &HashMap<String, i64>,
-) {
- let key_name = |k| {
- relevant_keys
- .get(k)
- .map(|k| k.params().unwrap().name.get().as_str())
- .unwrap_or("<deleted>")
- };
-
- println!("Bucket: {}", hex::encode(bucket.id));
- match &bucket.state {
- Deletable::Deleted => println!("Bucket is deleted."),
- Deletable::Present(p) => {
- let size =
- bytesize::ByteSize::b(*counters.get(object_table::BYTES).unwrap_or(&0) as u64);
- println!(
- "\nSize: {} ({})",
- size.to_string_as(true),
- size.to_string_as(false)
- );
- println!(
- "Objects: {}",
- *counters.get(object_table::OBJECTS).unwrap_or(&0)
- );
- println!(
- "Unfinished uploads (multipart and non-multipart): {}",
- *counters.get(object_table::UNFINISHED_UPLOADS).unwrap_or(&0)
- );
- println!(
- "Unfinished multipart uploads: {}",
- *mpu_counters.get(mpu_table::UPLOADS).unwrap_or(&0)
- );
- let mpu_size =
- bytesize::ByteSize::b(*mpu_counters.get(mpu_table::BYTES).unwrap_or(&0) as u64);
- println!(
- "Size of unfinished multipart uploads: {} ({})",
- mpu_size.to_string_as(true),
- mpu_size.to_string_as(false),
- );
-
- println!("\nWebsite access: {}", p.website_config.get().is_some());
-
- let quotas = p.quotas.get();
- if quotas.max_size.is_some() || quotas.max_objects.is_some() {
- println!("\nQuotas:");
- if let Some(ms) = quotas.max_size {
- let ms = bytesize::ByteSize::b(ms);
- println!(
- " maximum size: {} ({})",
- ms.to_string_as(true),
- ms.to_string_as(false)
- );
- }
- if let Some(mo) = quotas.max_objects {
- println!(" maximum number of objects: {}", mo);
- }
- }
-
- println!("\nGlobal aliases:");
- for (alias, _, active) in p.aliases.items().iter() {
- if *active {
- println!(" {}", alias);
- }
- }
-
- println!("\nKey-specific aliases:");
- let mut table = vec![];
- for ((key_id, alias), _, active) in p.local_aliases.items().iter() {
- if *active {
- table.push(format!("\t{} ({})\t{}", key_id, key_name(key_id), alias));
- }
- }
- format_table(table);
-
- println!("\nAuthorized keys:");
- let mut table = vec![];
- for (k, perm) in p.authorized_keys.items().iter() {
- if !perm.is_any() {
- continue;
- }
- let rflag = if perm.allow_read { "R" } else { " " };
- let wflag = if perm.allow_write { "W" } else { " " };
- let oflag = if perm.allow_owner { "O" } else { " " };
- table.push(format!(
- "\t{}{}{}\t{}\t{}",
- rflag,
- wflag,
- oflag,
- k,
- key_name(k)
- ));
- }
- format_table(table);
- }
- };
-}
-
pub fn print_worker_list(wi: HashMap<usize, WorkerInfo>, wlo: WorkerListOpt) {
let mut wi = wi.into_iter().collect::<Vec<_>>();
wi.sort_by_key(|(tid, info)| {