tape/drive: improve error and email handling for requesting a tape load

Try once first to load the correct tape before sending an email to
insert the correct one. This way, the admin does not get a mail
if the correct tape is already inserted.

Also include the error we got that prompted the email to insert the
tape. This means that if the admin gets prompted to insert e.g.
"FOO" but inserts "BAR", he'll get an email that the wrong
tape is inserted.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2021-03-03 15:00:52 +01:00
committed by Dietmar Maurer
parent 7d6f03a7fe
commit 78593b5b5c
2 changed files with 32 additions and 16 deletions

View File

@ -7,12 +7,17 @@ pub fn send_load_media_email(
drive: &str,
label_text: &str,
to: &str,
reason: Option<String>,
) -> Result<(), Error> {
let subject = format!("Load Media '{}' request for drive '{}'", label_text, drive);
let mut text = String::new();
if let Some(reason) = reason {
text.push_str(&format!("The drive has the wrong or no tape inserted. Error:\n{}\n\n", reason));
}
text.push_str("Please insert the requested media into the backup drive.\n\n");
text.push_str(&format!("Drive: {}\n", drive));