diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index df666156..857fb903 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -525,7 +525,14 @@ fn get_snapshots_count(store: &DataStore) -> Result { store: { schema: DATASTORE_SCHEMA, }, + verbose: { + type: bool, + default: false, + optional: true, + description: "Include additional information like snapshot counts and GC status.", + }, }, + }, returns: { type: DataStoreStatus, @@ -537,13 +544,18 @@ fn get_snapshots_count(store: &DataStore) -> Result { /// Get datastore status. pub fn status( store: String, + verbose: bool, _info: &ApiMethod, _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let datastore = DataStore::lookup_datastore(&store)?; let storage = crate::tools::disks::disk_usage(&datastore.base_path())?; - let counts = get_snapshots_count(&datastore)?; - let gc_status = datastore.last_gc_status(); + let (counts, gc_status) = match verbose { + true => { + (Some(get_snapshots_count(&datastore)?), Some(datastore.last_gc_status())) + }, + false => (None, None), + }; Ok(DataStoreStatus { total: storage.total, diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs index 59323327..44cfef94 100644 --- a/src/api2/types/mod.rs +++ b/src/api2/types/mod.rs @@ -707,8 +707,14 @@ pub struct Counts { #[api( properties: { - "gc-status": { type: GarbageCollectionStatus, }, - counts: { type: Counts, } + "gc-status": { + type: GarbageCollectionStatus, + optional: true, + }, + counts: { + type: Counts, + optional: true, + }, }, )] #[derive(Serialize, Deserialize)] @@ -722,9 +728,11 @@ pub struct DataStoreStatus { /// Available space (bytes). pub avail: u64, /// Status of last GC - pub gc_status: GarbageCollectionStatus, + #[serde(skip_serializing_if="Option::is_none")] + pub gc_status: Option, /// Group/Snapshot counts - pub counts: Counts, + #[serde(skip_serializing_if="Option::is_none")] + pub counts: Option, } #[api( diff --git a/www/datastore/Summary.js b/www/datastore/Summary.js index c263846a..1a6515ee 100644 --- a/www/datastore/Summary.js +++ b/www/datastore/Summary.js @@ -78,7 +78,7 @@ Ext.define('PBS.DataStoreInfo', { let datastore = encodeURIComponent(view.datastore); me.store = Ext.create('Proxmox.data.ObjectStore', { interval: 5*1000, - url: `/api2/json/admin/datastore/${datastore}/status`, + url: `/api2/json/admin/datastore/${datastore}/status/?verbose=true`, }); me.store.on('load', me.onLoad, me); },