api: tape/backup: fix namespace/max-depth parameters
by adding the 'default' serde hint and renaming 'recursion_depth' to 'max_depth' (to be in line with sync job config) also add the logic to actually add/update the tape backup job config Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
1e37156a6b
commit
12d334615b
@ -281,7 +281,7 @@ pub struct VerificationJobStatus {
|
||||
type: BackupNamespace,
|
||||
optional: true,
|
||||
},
|
||||
"recursion-depth": {
|
||||
"max-depth": {
|
||||
schema: crate::NS_MAX_DEPTH_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
@ -308,7 +308,7 @@ pub struct TapeBackupJobSetup {
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ns: Option<BackupNamespace>,
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub recursion_depth: Option<usize>,
|
||||
pub max_depth: Option<usize>,
|
||||
}
|
||||
|
||||
#[api(
|
||||
|
@ -134,6 +134,10 @@ pub enum DeletableProperty {
|
||||
NotifyUser,
|
||||
/// Delete the 'group_filter' property
|
||||
GroupFilter,
|
||||
/// Delete the 'max-depth' property
|
||||
MaxDepth,
|
||||
/// Delete the 'ns' property
|
||||
Ns,
|
||||
}
|
||||
|
||||
#[api(
|
||||
@ -207,6 +211,12 @@ pub fn update_tape_backup_job(
|
||||
DeletableProperty::GroupFilter => {
|
||||
data.setup.group_filter = None;
|
||||
}
|
||||
DeletableProperty::MaxDepth => {
|
||||
data.setup.max_depth = None;
|
||||
}
|
||||
DeletableProperty::Ns => {
|
||||
data.setup.ns = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,6 +246,12 @@ pub fn update_tape_backup_job(
|
||||
if update.setup.group_filter.is_some() {
|
||||
data.setup.group_filter = update.setup.group_filter;
|
||||
}
|
||||
if update.setup.ns.is_some() {
|
||||
data.setup.ns = update.setup.ns;
|
||||
}
|
||||
if update.setup.max_depth.is_some() {
|
||||
data.setup.max_depth = update.setup.max_depth;
|
||||
}
|
||||
|
||||
let schedule_changed = data.schedule != update.schedule;
|
||||
if update.schedule.is_some() {
|
||||
|
@ -405,7 +405,7 @@ fn backup_worker(
|
||||
let changer_name = update_media_online_status(&setup.drive)?;
|
||||
|
||||
let root_namespace = setup.ns.clone().unwrap_or_default();
|
||||
let ns_magic = !root_namespace.is_root() || setup.recursion_depth != Some(0);
|
||||
let ns_magic = !root_namespace.is_root() || setup.max_depth != Some(0);
|
||||
|
||||
let pool = MediaPool::with_config(status_path, pool_config, changer_name, false)?;
|
||||
|
||||
@ -413,8 +413,7 @@ fn backup_worker(
|
||||
PoolWriter::new(pool, &setup.drive, worker, email, force_media_set, ns_magic)?;
|
||||
|
||||
let mut group_list = Vec::new();
|
||||
let namespaces =
|
||||
datastore.recursive_iter_backup_ns_ok(root_namespace, setup.recursion_depth)?;
|
||||
let namespaces = datastore.recursive_iter_backup_ns_ok(root_namespace, setup.max_depth)?;
|
||||
for ns in namespaces {
|
||||
group_list.extend(datastore.list_backup_groups(ns)?);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user