tape/send_load_media_email: move to server/email_notifications
and reuse 'send_job_status_mail' there so that we get consistent formatted mails from pbs (e.g. html part and author) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
2c10410b0d
commit
2892624783
@ -448,6 +448,30 @@ pub fn send_tape_backup_status(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send email to a person to request a manual media change
|
||||||
|
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));
|
||||||
|
text.push_str(&format!("Media: {}\n", label_text));
|
||||||
|
|
||||||
|
send_job_status_mail(to, &subject, &text)
|
||||||
|
}
|
||||||
|
|
||||||
fn get_server_url() -> (String, usize) {
|
fn get_server_url() -> (String, usize) {
|
||||||
|
|
||||||
// user will surely request that they can change this
|
// user will surely request that they can change this
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
use anyhow::Error;
|
|
||||||
|
|
||||||
use proxmox::tools::email::sendmail;
|
|
||||||
|
|
||||||
/// Send email to a person to request a manual media change
|
|
||||||
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));
|
|
||||||
text.push_str(&format!("Media: {}\n", label_text));
|
|
||||||
|
|
||||||
sendmail(
|
|
||||||
&[to],
|
|
||||||
&subject,
|
|
||||||
Some(&text),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,8 +1,5 @@
|
|||||||
//! Media changer implementation (SCSI media changer)
|
//! Media changer implementation (SCSI media changer)
|
||||||
|
|
||||||
mod email;
|
|
||||||
pub use email::*;
|
|
||||||
|
|
||||||
pub mod sg_pt_changer;
|
pub mod sg_pt_changer;
|
||||||
|
|
||||||
pub mod mtx;
|
pub mod mtx;
|
||||||
|
@ -51,7 +51,10 @@ use crate::{
|
|||||||
VirtualTapeDrive,
|
VirtualTapeDrive,
|
||||||
LinuxTapeDrive,
|
LinuxTapeDrive,
|
||||||
},
|
},
|
||||||
server::WorkerTask,
|
server::{
|
||||||
|
send_load_media_email,
|
||||||
|
WorkerTask,
|
||||||
|
},
|
||||||
tape::{
|
tape::{
|
||||||
TapeWrite,
|
TapeWrite,
|
||||||
TapeRead,
|
TapeRead,
|
||||||
@ -66,7 +69,6 @@ use crate::{
|
|||||||
changer::{
|
changer::{
|
||||||
MediaChange,
|
MediaChange,
|
||||||
MtxMediaChanger,
|
MtxMediaChanger,
|
||||||
send_load_media_email,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user