From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v2 proxmox-backup 05/15] api2: add 'is_available' to DataStoreConfig
Date: Mon, 30 Aug 2021 13:14:55 +0200 [thread overview]
Message-ID: <20210830111505.38694-6-h.laimer@proxmox.com> (raw)
In-Reply-To: <20210830111505.38694-1-h.laimer@proxmox.com>
---
src/api2/admin/datastore.rs | 14 ++++++++++++++
src/api2/status.rs | 19 ++++++++++++++++++-
src/api2/types/mod.rs | 2 ++
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index f3c52413..16559678 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -606,6 +606,19 @@ pub fn status(
_info: &ApiMethod,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<DataStoreStatus, Error> {
+ let (config, _digest) = datastore::config()?;
+ let store_config = config.lookup("datastore", &store)?;
+ if !check_if_available(&store_config).is_ok() {
+ return Ok(DataStoreStatus {
+ total: 0,
+ used: 0,
+ avail: 0,
+ is_available: false,
+ gc_status: None,
+ counts: None,
+ });
+ }
+
let datastore = DataStore::lookup_datastore(&store)?;
let storage = crate::tools::disks::disk_usage(&datastore.base_path())?;
let (counts, gc_status) = if verbose {
@@ -631,6 +644,7 @@ pub fn status(
total: storage.total,
used: storage.used,
avail: storage.avail,
+ is_available: true,
gc_status,
counts,
})
diff --git a/src/api2/status.rs b/src/api2/status.rs
index 3aff91e7..06990743 100644
--- a/src/api2/status.rs
+++ b/src/api2/status.rs
@@ -21,7 +21,7 @@ use crate::api2::types::{
Authid,
};
-use crate::backup::DataStore;
+use crate::backup::{check_if_available, DataStore};
use crate::config::datastore;
use crate::tools::statistics::{linear_regression};
use crate::config::cached_user_info::CachedUserInfo;
@@ -53,6 +53,10 @@ use crate::config::acl::{
type: Integer,
description: "The available bytes of the underlying storage",
},
+ "is-available": {
+ type: bool,
+ description: "The datastore is available, relevent if it is removable",
+ },
history: {
type: Array,
optional: true,
@@ -103,6 +107,18 @@ pub fn datastore_status(
continue;
}
+ let store_config = config.lookup("datastore", &store)?;
+ if !check_if_available(&store_config).is_ok() {
+ list.push(json!({
+ "store": store,
+ "total": -1,
+ "used": -1,
+ "avail": -1,
+ "is-available": false,
+ }));
+ continue;
+ }
+
let datastore = match DataStore::lookup_datastore(&store) {
Ok(datastore) => datastore,
Err(err) => {
@@ -123,6 +139,7 @@ pub fn datastore_status(
"total": status.total,
"used": status.used,
"avail": status.avail,
+ "is-available": true,
"gc-status": datastore.last_gc_status(),
});
diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs
index bd3c7ac5..4d9ed691 100644
--- a/src/api2/types/mod.rs
+++ b/src/api2/types/mod.rs
@@ -371,6 +371,8 @@ pub struct DataStoreStatus {
pub used: u64,
/// Available space (bytes).
pub avail: u64,
+ /// Datastore is available, relevant if it is removable
+ pub is_available: bool,
/// Status of last GC
#[serde(skip_serializing_if="Option::is_none")]
pub gc_status: Option<GarbageCollectionStatus>,
--
2.30.2
next prev parent reply other threads:[~2021-08-30 11:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 11:14 [pbs-devel] [PATCH v2 proxmox-backup 00/15] (partially)close #3156: Add support for removable datastores Hannes Laimer
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 01/15] tools: add disks utility functions Hannes Laimer
2021-09-01 14:48 ` Dominik Csapak
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 02/15] config: add uuid+mountpoint to DataStoreConfig Hannes Laimer
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 03/15] api2: add support for removable datastore creation Hannes Laimer
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 04/15] backup: add check_if_available function to ds Hannes Laimer
2021-08-30 11:14 ` Hannes Laimer [this message]
2021-09-01 14:48 ` [pbs-devel] [PATCH v2 proxmox-backup 05/15] api2: add 'is_available' to DataStoreConfig Dominik Csapak
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 06/15] api2: add 'removable' to DataStoreListItem Hannes Laimer
2021-09-01 14:48 ` Dominik Csapak
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 07/15] api2: add (un)mount endpoint for removable ds's Hannes Laimer
2021-09-01 14:48 ` Dominik Csapak
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 08/15] pbs: add mount-removable command to commandSocket Hannes Laimer
2021-08-30 11:14 ` [pbs-devel] [PATCH v2 proxmox-backup 09/15] pbs-manager: add 'send-command' command Hannes Laimer
2021-08-30 11:15 ` [pbs-devel] [PATCH v2 proxmox-backup 10/15] debian: add udev rule for removable datastores Hannes Laimer
2021-08-30 11:15 ` [pbs-devel] [PATCH v2 proxmox-backup 11/15] ui: show usb icon for removable datastore in list Hannes Laimer
2021-08-30 11:15 ` [pbs-devel] [PATCH v2 proxmox-backup 12/15] ui: add 'removable' checkbox in datastore creation Hannes Laimer
2021-08-30 11:15 ` [pbs-devel] [PATCH v2 proxmox-backup 13/15] ui: display row as disabled in ds statistics Hannes Laimer
2021-08-30 11:15 ` [pbs-devel] [PATCH v2 proxmox-backup 14/15] ui: show backing device UUID and mount-point in option tab Hannes Laimer
2021-08-30 11:15 ` [pbs-devel] [PATCH v2 proxmox-backup 15/15] ui: add (un)mount button to summary Hannes Laimer
2021-09-01 14:48 ` Dominik Csapak
2021-09-01 14:48 ` [pbs-devel] [PATCH v2 proxmox-backup 00/15] (partially)close #3156: Add support for removable datastores Dominik Csapak
2021-09-02 6:09 ` Thomas Lamprecht
2021-09-02 6:18 ` Dominik Csapak
2021-09-02 6:28 ` Thomas Lamprecht
2021-09-03 9:27 ` Hannes Laimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210830111505.38694-6-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox