api: tape/restore: add namespace mapping

by adding a new parameter 'namespaces', which contains a mapping
for a namespace like this:

store=datastore,source=foo,target=bar,max-depth=2

if source or target are omitted the root namespace is used for its value

this mapping can be given several times (on the cli) or as an array (via
api) to have mappings for multiple datastores

if a specific snapshot list is given simultaneously, the given snapshots
will be restored according to this mapping, or to the source namespace
if no mapping was found.

to do this, we reutilize the restore_list_worker, but change it so that
it does not hold a lock for the duration of the restore, but fails
if the snapshot does exist at the end. also the snapshot will now
be temporarily restored into the target datastore into the
'.tmp/<media-set-uuid>' folder.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2022-05-05 15:59:36 +02:00
parent fc99c2791b
commit 07ffb86451
5 changed files with 415 additions and 160 deletions

View File

@ -995,6 +995,27 @@ impl MediaSetCatalog {
}
None
}
/// Returns an iterator over all registered snapshots per datastore
/// as (datastore, snapshot).
/// The snapshot contains namespaces in the format 'ns/namespace'.
pub fn list_snapshots(&self) -> impl Iterator<Item = (&str, &str)> {
self.catalog_list
.values()
.map(|catalog| {
catalog
.content
.iter()
.map(|(store, content)| {
content
.snapshot_index
.keys()
.map(move |key| (store.as_str(), key.as_str()))
})
.flatten()
})
.flatten()
}
}
// Type definitions for internal binary catalog encoding