datastore status: impl empty-status constructor for item type
we can now use it for the error case and will further use it for the can access namespace but not datastore case in a future patch Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
513da8ed10
commit
997c96d6a3
|
@ -1361,6 +1361,23 @@ pub struct DataStoreStatusListItem {
|
|||
pub gc_status: Option<GarbageCollectionStatus>,
|
||||
}
|
||||
|
||||
impl DataStoreStatusListItem {
|
||||
pub fn empty(store: &str, err: Option<String>) -> Self {
|
||||
DataStoreStatusListItem {
|
||||
store: store.to_owned(),
|
||||
total: -1,
|
||||
used: -1,
|
||||
avail: -1,
|
||||
history: None,
|
||||
history_start: None,
|
||||
history_delta: None,
|
||||
estimated_full_date: None,
|
||||
error: err,
|
||||
gc_status: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const ADMIN_DATASTORE_LIST_SNAPSHOTS_RETURN_TYPE: ReturnType = ReturnType {
|
||||
optional: false,
|
||||
schema: &ArraySchema::new(
|
||||
|
|
|
@ -53,18 +53,7 @@ pub fn datastore_status(
|
|||
let datastore = match DataStore::lookup_datastore(&store, Some(Operation::Read)) {
|
||||
Ok(datastore) => datastore,
|
||||
Err(err) => {
|
||||
list.push(DataStoreStatusListItem {
|
||||
store: store.clone(),
|
||||
total: -1,
|
||||
used: -1,
|
||||
avail: -1,
|
||||
history: None,
|
||||
history_start: None,
|
||||
history_delta: None,
|
||||
estimated_full_date: None,
|
||||
error: Some(err.to_string()),
|
||||
gc_status: None,
|
||||
});
|
||||
list.push(DataStoreStatusListItem::empty(store, Some(err.to_string())));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue