From ff30caeaf8cc122bb3377fee0809d841fc73b829 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 6 Jun 2020 11:48:58 +0200 Subject: [PATCH] src/api2/disks.rs - list-disks: add usage-type filter --- src/api2/disks.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/api2/disks.rs b/src/api2/disks.rs index 61786ed9..be8d8e7d 100644 --- a/src/api2/disks.rs +++ b/src/api2/disks.rs @@ -7,8 +7,8 @@ use proxmox::api::router::{Router, SubdirMap}; use proxmox::{sortable, identity}; use proxmox::{http_err, list_subdirs_api_method}; -use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_MODIFY}; -use crate::tools::disks::{DiskUsageInfo, get_disks}; +use crate::config::acl::{PRIV_SYS_AUDIT}; +use crate::tools::disks::{DiskUsageInfo, DiskUsageType, get_disks}; #[api( input: { @@ -18,7 +18,11 @@ use crate::tools::disks::{DiskUsageInfo, get_disks}; type: bool, optional: true, default: false, - } + }, + "usage-type": { + type: DiskUsageType, + optional: true, + }, }, }, returns: { @@ -35,12 +39,19 @@ use crate::tools::disks::{DiskUsageInfo, get_disks}; /// List local disks pub fn list_disks( skipsmart: bool, + usage_type: Option, ) -> Result, Error> { let mut list = Vec::new(); for (_, info) in get_disks(None, skipsmart)? { - list.push(info); + if let Some(ref usage_type) = usage_type { + if info.used == *usage_type { + list.push(info); + } + } else { + list.push(info); + } } Ok(list)