* [pbs-devel] [PATCH proxmox-backup] tape: include used tapes in tape notification e-mails
@ 2022-07-01 12:11 Dominik Csapak
2022-07-05 6:58 ` [pbs-devel] applied: " Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2022-07-01 12:11 UTC (permalink / raw)
To: pbs-devel
by saving them in the pool-writer, and setting them in the
TapeBackupJobSummary
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/tape/backup.rs | 8 ++++++++
src/server/email_notifications.rs | 16 +++++++++++++++-
src/tape/pool_writer/mod.rs | 15 +++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
index 8f7ee5cb..a1c84b55 100644
--- a/src/api2/tape/backup.rs
+++ b/src/api2/tape/backup.rs
@@ -564,6 +564,14 @@ fn backup_worker(
bail!("Tape backup finished with some errors. Please check the task log.");
}
+ summary.used_tapes = match pool_writer.get_used_media_labels() {
+ Ok(tapes) => Some(tapes),
+ Err(err) => {
+ task_warn!(worker, "could not collect list of used tapes: {err}");
+ None
+ }
+ };
+
summary.duration = start.elapsed();
Ok(())
diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index 44a2ecf1..6fca4133 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -148,7 +148,12 @@ Snapshots included:
{{/each~}}
{{/if}}
Duration: {{duration}}
-
+{{#if used-tapes }}
+Used Tapes:
+{{#each used-tapes~}}
+{{this}}
+{{/each~}}
+{{/if}}
Tape Backup successful.
@@ -174,6 +179,12 @@ Snapshots included:
{{this}}
{{/each~}}
{{/if}}
+{{#if used-tapes }}
+Used Tapes:
+{{#each used-tapes~}}
+{{this}}
+{{/each~}}
+{{/if}}
Tape Backup failed: {{error}}
@@ -241,6 +252,8 @@ pub struct TapeBackupJobSummary {
pub snapshot_list: Vec<String>,
/// The total time of the backup job
pub duration: std::time::Duration,
+ /// The labels of the used tapes of the backup job
+ pub used_tapes: Option<Vec<String>>,
}
fn send_job_status_mail(email: &str, subject: &str, text: &str) -> Result<(), Error> {
@@ -432,6 +445,7 @@ pub fn send_tape_backup_status(
"port": port,
"id": id,
"snapshot-list": summary.snapshot_list,
+ "used-tapes": summary.used_tapes,
"duration": duration.to_string(),
});
diff --git a/src/tape/pool_writer/mod.rs b/src/tape/pool_writer/mod.rs
index 0a2e45fb..d87f7dec 100644
--- a/src/tape/pool_writer/mod.rs
+++ b/src/tape/pool_writer/mod.rs
@@ -4,6 +4,7 @@ pub use catalog_set::*;
mod new_chunks_iterator;
pub use new_chunks_iterator::*;
+use std::collections::HashSet;
use std::fs::File;
use std::path::Path;
use std::sync::{Arc, Mutex};
@@ -49,6 +50,7 @@ pub struct PoolWriter {
catalog_set: Arc<Mutex<CatalogSet>>,
notify_email: Option<String>,
ns_magic: bool,
+ used_tapes: HashSet<Uuid>,
}
impl PoolWriter {
@@ -87,6 +89,7 @@ impl PoolWriter {
catalog_set: Arc::new(Mutex::new(catalog_set)),
notify_email,
ns_magic,
+ used_tapes: HashSet::new(),
})
}
@@ -100,6 +103,16 @@ impl PoolWriter {
Ok(())
}
+ pub fn get_used_media_labels(&self) -> Result<Vec<String>, Error> {
+ let mut res = Vec::with_capacity(self.used_tapes.len());
+ for media_uuid in &self.used_tapes {
+ let media_info = self.pool.lookup_media(&media_uuid)?;
+ res.push(media_info.label_text().to_string());
+ }
+
+ Ok(res)
+ }
+
pub fn contains_snapshot(
&self,
store: &str,
@@ -208,6 +221,7 @@ impl PoolWriter {
};
if !media_changed {
+ self.used_tapes.insert(media_uuid.clone());
return Ok(media_uuid);
}
@@ -278,6 +292,7 @@ impl PoolWriter {
self.append_media_set_catalogs(worker)?;
}
+ self.used_tapes.insert(media_uuid.clone());
Ok(media_uuid)
}
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup] tape: include used tapes in tape notification e-mails
2022-07-01 12:11 [pbs-devel] [PATCH proxmox-backup] tape: include used tapes in tape notification e-mails Dominik Csapak
@ 2022-07-05 6:58 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2022-07-05 6:58 UTC (permalink / raw)
To: Dominik Csapak; +Cc: pbs-devel
applied, thanks
On Fri, Jul 01, 2022 at 02:11:04PM +0200, Dominik Csapak wrote:
> by saving them in the pool-writer, and setting them in the
> TapeBackupJobSummary
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/api2/tape/backup.rs | 8 ++++++++
> src/server/email_notifications.rs | 16 +++++++++++++++-
> src/tape/pool_writer/mod.rs | 15 +++++++++++++++
> 3 files changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
> index 8f7ee5cb..a1c84b55 100644
> --- a/src/api2/tape/backup.rs
> +++ b/src/api2/tape/backup.rs
> @@ -564,6 +564,14 @@ fn backup_worker(
> bail!("Tape backup finished with some errors. Please check the task log.");
> }
>
> + summary.used_tapes = match pool_writer.get_used_media_labels() {
> + Ok(tapes) => Some(tapes),
> + Err(err) => {
> + task_warn!(worker, "could not collect list of used tapes: {err}");
> + None
> + }
> + };
> +
> summary.duration = start.elapsed();
>
> Ok(())
> diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
> index 44a2ecf1..6fca4133 100644
> --- a/src/server/email_notifications.rs
> +++ b/src/server/email_notifications.rs
> @@ -148,7 +148,12 @@ Snapshots included:
> {{/each~}}
> {{/if}}
> Duration: {{duration}}
> -
> +{{#if used-tapes }}
> +Used Tapes:
> +{{#each used-tapes~}}
> +{{this}}
> +{{/each~}}
> +{{/if}}
> Tape Backup successful.
>
>
> @@ -174,6 +179,12 @@ Snapshots included:
> {{this}}
> {{/each~}}
> {{/if}}
> +{{#if used-tapes }}
> +Used Tapes:
> +{{#each used-tapes~}}
> +{{this}}
> +{{/each~}}
> +{{/if}}
> Tape Backup failed: {{error}}
>
>
> @@ -241,6 +252,8 @@ pub struct TapeBackupJobSummary {
> pub snapshot_list: Vec<String>,
> /// The total time of the backup job
> pub duration: std::time::Duration,
> + /// The labels of the used tapes of the backup job
> + pub used_tapes: Option<Vec<String>>,
> }
>
> fn send_job_status_mail(email: &str, subject: &str, text: &str) -> Result<(), Error> {
> @@ -432,6 +445,7 @@ pub fn send_tape_backup_status(
> "port": port,
> "id": id,
> "snapshot-list": summary.snapshot_list,
> + "used-tapes": summary.used_tapes,
> "duration": duration.to_string(),
> });
>
> diff --git a/src/tape/pool_writer/mod.rs b/src/tape/pool_writer/mod.rs
> index 0a2e45fb..d87f7dec 100644
> --- a/src/tape/pool_writer/mod.rs
> +++ b/src/tape/pool_writer/mod.rs
> @@ -4,6 +4,7 @@ pub use catalog_set::*;
> mod new_chunks_iterator;
> pub use new_chunks_iterator::*;
>
> +use std::collections::HashSet;
> use std::fs::File;
> use std::path::Path;
> use std::sync::{Arc, Mutex};
> @@ -49,6 +50,7 @@ pub struct PoolWriter {
> catalog_set: Arc<Mutex<CatalogSet>>,
> notify_email: Option<String>,
> ns_magic: bool,
> + used_tapes: HashSet<Uuid>,
> }
>
> impl PoolWriter {
> @@ -87,6 +89,7 @@ impl PoolWriter {
> catalog_set: Arc::new(Mutex::new(catalog_set)),
> notify_email,
> ns_magic,
> + used_tapes: HashSet::new(),
> })
> }
>
> @@ -100,6 +103,16 @@ impl PoolWriter {
> Ok(())
> }
>
> + pub fn get_used_media_labels(&self) -> Result<Vec<String>, Error> {
> + let mut res = Vec::with_capacity(self.used_tapes.len());
> + for media_uuid in &self.used_tapes {
> + let media_info = self.pool.lookup_media(&media_uuid)?;
> + res.push(media_info.label_text().to_string());
> + }
> +
> + Ok(res)
> + }
> +
> pub fn contains_snapshot(
> &self,
> store: &str,
> @@ -208,6 +221,7 @@ impl PoolWriter {
> };
>
> if !media_changed {
> + self.used_tapes.insert(media_uuid.clone());
> return Ok(media_uuid);
> }
>
> @@ -278,6 +292,7 @@ impl PoolWriter {
> self.append_media_set_catalogs(worker)?;
> }
>
> + self.used_tapes.insert(media_uuid.clone());
> Ok(media_uuid)
> }
>
> --
> 2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-05 6:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-01 12:11 [pbs-devel] [PATCH proxmox-backup] tape: include used tapes in tape notification e-mails Dominik Csapak
2022-07-05 6:58 ` [pbs-devel] applied: " Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox