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,
|
type: BackupNamespace,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
"recursion-depth": {
|
"max-depth": {
|
||||||
schema: crate::NS_MAX_DEPTH_SCHEMA,
|
schema: crate::NS_MAX_DEPTH_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
@ -308,7 +308,7 @@ pub struct TapeBackupJobSetup {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||||
pub ns: Option<BackupNamespace>,
|
pub ns: Option<BackupNamespace>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||||
pub recursion_depth: Option<usize>,
|
pub max_depth: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
|
@ -134,6 +134,10 @@ pub enum DeletableProperty {
|
|||||||
NotifyUser,
|
NotifyUser,
|
||||||
/// Delete the 'group_filter' property
|
/// Delete the 'group_filter' property
|
||||||
GroupFilter,
|
GroupFilter,
|
||||||
|
/// Delete the 'max-depth' property
|
||||||
|
MaxDepth,
|
||||||
|
/// Delete the 'ns' property
|
||||||
|
Ns,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
@ -207,6 +211,12 @@ pub fn update_tape_backup_job(
|
|||||||
DeletableProperty::GroupFilter => {
|
DeletableProperty::GroupFilter => {
|
||||||
data.setup.group_filter = None;
|
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() {
|
if update.setup.group_filter.is_some() {
|
||||||
data.setup.group_filter = update.setup.group_filter;
|
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;
|
let schedule_changed = data.schedule != update.schedule;
|
||||||
if update.schedule.is_some() {
|
if update.schedule.is_some() {
|
||||||
|
@ -405,7 +405,7 @@ fn backup_worker(
|
|||||||
let changer_name = update_media_online_status(&setup.drive)?;
|
let changer_name = update_media_online_status(&setup.drive)?;
|
||||||
|
|
||||||
let root_namespace = setup.ns.clone().unwrap_or_default();
|
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)?;
|
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)?;
|
PoolWriter::new(pool, &setup.drive, worker, email, force_media_set, ns_magic)?;
|
||||||
|
|
||||||
let mut group_list = Vec::new();
|
let mut group_list = Vec::new();
|
||||||
let namespaces =
|
let namespaces = datastore.recursive_iter_backup_ns_ok(root_namespace, setup.max_depth)?;
|
||||||
datastore.recursive_iter_backup_ns_ok(root_namespace, setup.recursion_depth)?;
|
|
||||||
for ns in namespaces {
|
for ns in namespaces {
|
||||||
group_list.extend(datastore.list_backup_groups(ns)?);
|
group_list.extend(datastore.list_backup_groups(ns)?);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user