prune: allow passing namespace
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
a7f5e64154
commit
2f5417f845
@ -1007,6 +1007,10 @@ pub fn prune(
|
|||||||
store: {
|
store: {
|
||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
},
|
},
|
||||||
|
ns: {
|
||||||
|
type: BackupNamespace,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns: {
|
returns: {
|
||||||
@ -1022,6 +1026,7 @@ pub fn prune_datastore(
|
|||||||
dry_run: bool,
|
dry_run: bool,
|
||||||
prune_options: PruneOptions,
|
prune_options: PruneOptions,
|
||||||
store: String,
|
store: String,
|
||||||
|
ns: Option<BackupNamespace>,
|
||||||
_param: Value,
|
_param: Value,
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<String, Error> {
|
) -> Result<String, Error> {
|
||||||
@ -1043,8 +1048,8 @@ pub fn prune_datastore(
|
|||||||
worker,
|
worker,
|
||||||
auth_id,
|
auth_id,
|
||||||
prune_options,
|
prune_options,
|
||||||
&store,
|
|
||||||
datastore,
|
datastore,
|
||||||
|
ns.unwrap_or_default(),
|
||||||
dry_run,
|
dry_run,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,7 @@ use anyhow::Error;
|
|||||||
|
|
||||||
use proxmox_sys::{task_log, task_warn};
|
use proxmox_sys::{task_log, task_warn};
|
||||||
|
|
||||||
use pbs_api_types::{Authid, Operation, PruneOptions, PRIV_DATASTORE_MODIFY};
|
use pbs_api_types::{Authid, BackupNamespace, Operation, PruneOptions, PRIV_DATASTORE_MODIFY};
|
||||||
use pbs_config::CachedUserInfo;
|
use pbs_config::CachedUserInfo;
|
||||||
use pbs_datastore::prune::compute_prune_info;
|
use pbs_datastore::prune::compute_prune_info;
|
||||||
use pbs_datastore::DataStore;
|
use pbs_datastore::DataStore;
|
||||||
@ -16,10 +16,12 @@ pub fn prune_datastore(
|
|||||||
worker: Arc<WorkerTask>,
|
worker: Arc<WorkerTask>,
|
||||||
auth_id: Authid,
|
auth_id: Authid,
|
||||||
prune_options: PruneOptions,
|
prune_options: PruneOptions,
|
||||||
store: &str,
|
|
||||||
datastore: Arc<DataStore>,
|
datastore: Arc<DataStore>,
|
||||||
|
ns: BackupNamespace,
|
||||||
|
//max_depth: Option<usize>, // FIXME
|
||||||
dry_run: bool,
|
dry_run: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
let store = &datastore.name();
|
||||||
task_log!(worker, "Starting datastore prune on store \"{}\"", store);
|
task_log!(worker, "Starting datastore prune on store \"{}\"", store);
|
||||||
|
|
||||||
if dry_run {
|
if dry_run {
|
||||||
@ -42,8 +44,8 @@ pub fn prune_datastore(
|
|||||||
let privs = user_info.lookup_privs(&auth_id, &["datastore", store]);
|
let privs = user_info.lookup_privs(&auth_id, &["datastore", store]);
|
||||||
let has_privs = privs & PRIV_DATASTORE_MODIFY != 0;
|
let has_privs = privs & PRIV_DATASTORE_MODIFY != 0;
|
||||||
|
|
||||||
// FIXME: Namespaces and recursion!
|
// FIXME: Namespace recursion!
|
||||||
for group in datastore.iter_backup_groups(Default::default())? {
|
for group in datastore.iter_backup_groups(ns)? {
|
||||||
let group = group?;
|
let group = group?;
|
||||||
let list = group.list_backups()?;
|
let list = group.list_backups()?;
|
||||||
|
|
||||||
@ -115,8 +117,8 @@ pub fn do_prune_job(
|
|||||||
worker.clone(),
|
worker.clone(),
|
||||||
auth_id,
|
auth_id,
|
||||||
prune_options,
|
prune_options,
|
||||||
&store,
|
|
||||||
datastore,
|
datastore,
|
||||||
|
BackupNamespace::default(),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user