* [pbs-devel] [PATCH proxmox-backup 0/4] add notify-user to tape backup/restore
@ 2021-03-05 8:45 Dominik Csapak
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable Dominik Csapak
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Dominik Csapak @ 2021-03-05 8:45 UTC (permalink / raw)
To: pbs-devel
by adding it to the backup jobs as well as the backup/restore api calls
an alternative of this would be to store the notify-user on the
tape pool, maybe that would be better?
Dominik Csapak (4):
api2/types/userid: make Userid updatable
config/tape_job: add notify-user config to tape jobs
api2/tape: add notify_user to backup(-jobs) and restore api calls
ui: tape: add notify-user fields
src/api2/config/tape_backup_job.rs | 2 ++
src/api2/tape/backup.rs | 7 ++++++-
src/api2/tape/restore.rs | 20 ++++++++++++++++++--
src/api2/types/userid.rs | 4 ++--
src/config/tape_job.rs | 8 ++++++++
src/server/email_notifications.rs | 2 +-
src/tape/drive/mod.rs | 8 ++++----
src/tape/pool_writer.rs | 6 ++++--
www/tape/window/TapeBackup.js | 9 +++++++++
www/tape/window/TapeBackupJob.js | 9 +++++++++
www/tape/window/TapeRestore.js | 9 +++++++++
11 files changed, 72 insertions(+), 12 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable
2021-03-05 8:45 [pbs-devel] [PATCH proxmox-backup 0/4] add notify-user to tape backup/restore Dominik Csapak
@ 2021-03-05 8:45 ` Dominik Csapak
2021-03-05 12:02 ` Dietmar Maurer
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 2/4] config/tape_job: add notify-user config to tape jobs Dominik Csapak
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Dominik Csapak @ 2021-03-05 8:45 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/types/userid.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/api2/types/userid.rs b/src/api2/types/userid.rs
index 7c73e69f..3b47ccdf 100644
--- a/src/api2/types/userid.rs
+++ b/src/api2/types/userid.rs
@@ -30,7 +30,7 @@ use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use proxmox::api::api;
-use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema};
+use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema, Updatable};
use proxmox::const_regex;
// we only allow a limited set of characters
@@ -393,7 +393,7 @@ impl<'a> TryFrom<&'a str> for &'a TokennameRef {
}
/// A complete user id consisting of a user name and a realm
-#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Updatable)]
pub struct Userid {
data: String,
name_len: usize,
--
2.20.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 2/4] config/tape_job: add notify-user config to tape jobs
2021-03-05 8:45 [pbs-devel] [PATCH proxmox-backup 0/4] add notify-user to tape backup/restore Dominik Csapak
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable Dominik Csapak
@ 2021-03-05 8:45 ` Dominik Csapak
2021-03-05 12:02 ` [pbs-devel] applied: " Dietmar Maurer
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 3/4] api2/tape: add notify_user to backup(-jobs) and restore api calls Dominik Csapak
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape: add notify-user fields Dominik Csapak
3 siblings, 1 reply; 9+ messages in thread
From: Dominik Csapak @ 2021-03-05 8:45 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/config/tape_backup_job.rs | 2 ++
src/config/tape_job.rs | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/src/api2/config/tape_backup_job.rs b/src/api2/config/tape_backup_job.rs
index fbd36a53..fbb8d979 100644
--- a/src/api2/config/tape_backup_job.rs
+++ b/src/api2/config/tape_backup_job.rs
@@ -145,6 +145,8 @@ pub enum DeletableProperty {
ExportMediaSet,
/// Delete the 'latest-only' property
LatestOnly,
+ /// Delete the 'notify-user' property
+ NotifyUser,
}
#[api(
diff --git a/src/config/tape_job.rs b/src/config/tape_job.rs
index 7e1ad37d..26295d1f 100644
--- a/src/config/tape_job.rs
+++ b/src/config/tape_job.rs
@@ -16,6 +16,7 @@ use proxmox::api::{
use proxmox::tools::{fs::replace_file, fs::CreateOptions};
use crate::api2::types::{
+ Userid,
JOB_ID_SCHEMA,
DATASTORE_SCHEMA,
DRIVE_NAME_SCHEMA,
@@ -55,6 +56,10 @@ lazy_static! {
type: bool,
optional: true,
},
+ "notify-user": {
+ optional: true,
+ type: Userid,
+ },
}
)]
#[serde(rename_all="kebab-case")]
@@ -70,6 +75,9 @@ pub struct TapeBackupJobSetup {
pub export_media_set: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
pub latest_only: Option<bool>,
+ /// Send job email notification to this user
+ #[serde(skip_serializing_if="Option::is_none")]
+ pub notify_user: Option<Userid>,
}
#[api(
--
2.20.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 3/4] api2/tape: add notify_user to backup(-jobs) and restore api calls
2021-03-05 8:45 [pbs-devel] [PATCH proxmox-backup 0/4] add notify-user to tape backup/restore Dominik Csapak
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable Dominik Csapak
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 2/4] config/tape_job: add notify-user config to tape jobs Dominik Csapak
@ 2021-03-05 8:45 ` Dominik Csapak
2021-03-05 12:03 ` Dietmar Maurer
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape: add notify-user fields Dominik Csapak
3 siblings, 1 reply; 9+ messages in thread
From: Dominik Csapak @ 2021-03-05 8:45 UTC (permalink / raw)
To: pbs-devel
so that a user can be given that will be notified for
manual intervention (e.g. inserting a tape)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/tape/backup.rs | 7 ++++++-
src/api2/tape/restore.rs | 20 ++++++++++++++++++--
src/server/email_notifications.rs | 2 +-
src/tape/drive/mod.rs | 8 ++++----
src/tape/pool_writer.rs | 6 ++++--
5 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
index 2f9f03d0..621fcf4d 100644
--- a/src/api2/tape/backup.rs
+++ b/src/api2/tape/backup.rs
@@ -29,6 +29,7 @@ use crate::{
},
},
server::{
+ lookup_user_email,
jobstate::{
Job,
JobState,
@@ -45,6 +46,7 @@ use crate::{
UPID_SCHEMA,
JOB_ID_SCHEMA,
MediaPoolConfig,
+ Userid,
},
server::WorkerTask,
task::TaskState,
@@ -295,7 +297,10 @@ fn backup_worker(
let pool = MediaPool::with_config(status_path, &pool_config, changer_name)?;
- let mut pool_writer = PoolWriter::new(pool, &setup.drive)?;
+ let notify_user = setup.notify_user.as_ref().unwrap_or_else(|| &Userid::root_userid());
+ let email = lookup_user_email(notify_user);
+
+ let mut pool_writer = PoolWriter::new(pool, &setup.drive, email)?;
let mut group_list = BackupInfo::list_backup_groups(&datastore.base_path())?;
diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs
index e506c36c..157e3513 100644
--- a/src/api2/tape/restore.rs
+++ b/src/api2/tape/restore.rs
@@ -32,6 +32,7 @@ use crate::{
DRIVE_NAME_SCHEMA,
UPID_SCHEMA,
Authid,
+ Userid,
},
config,
backup::{
@@ -47,7 +48,10 @@ use crate::{
DynamicIndexReader,
FixedIndexReader,
},
- server::WorkerTask,
+ server::{
+ lookup_user_email,
+ WorkerTask,
+ },
tape::{
TAPE_STATUS_DIR,
TapeRead,
@@ -90,6 +94,10 @@ pub const ROUTER: Router = Router::new()
description: "Media set UUID.",
type: String,
},
+ "notify-user": {
+ type: Userid,
+ optional: true,
+ },
},
},
returns: {
@@ -101,6 +109,7 @@ pub fn restore(
store: String,
drive: String,
media_set: String,
+ notify_user: Option<Userid>,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<Value, Error> {
@@ -183,6 +192,7 @@ pub fn restore(
&drive,
&datastore,
&auth_id,
+ ¬ify_user,
)?;
}
@@ -212,6 +222,7 @@ pub fn request_and_restore_media(
drive_name: &str,
datastore: &DataStore,
authid: &Authid,
+ notify_user: &Option<Userid>,
) -> Result<(), Error> {
let media_set_uuid = match media_id.media_set_label {
@@ -219,7 +230,12 @@ pub fn request_and_restore_media(
Some(ref set) => &set.uuid,
};
- let (mut drive, info) = request_and_load_media(worker, &drive_config, &drive_name, &media_id.label)?;
+ let email = notify_user
+ .as_ref()
+ .and_then(|userid| lookup_user_email(userid))
+ .or_else(|| lookup_user_email(&authid.clone().into()));
+
+ let (mut drive, info) = request_and_load_media(worker, &drive_config, &drive_name, &media_id.label, &email)?;
match info.media_set_label {
None => {
diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index 6af6bd38..3ff1be7c 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -397,7 +397,7 @@ pub fn send_updates_available(
}
/// Lookup users email address
-fn lookup_user_email(userid: &Userid) -> Option<String> {
+pub fn lookup_user_email(userid: &Userid) -> Option<String> {
use crate::config::user::{self, User};
diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs
index 8bbca98c..c3021dc3 100644
--- a/src/tape/drive/mod.rs
+++ b/src/tape/drive/mod.rs
@@ -319,6 +319,7 @@ pub fn request_and_load_media(
config: &SectionConfigData,
drive: &str,
label: &MediaLabel,
+ notify_email: &Option<String>,
) -> Result<(
Box<dyn TapeDriver>,
MediaId,
@@ -375,9 +376,6 @@ pub fn request_and_load_media(
return Ok((handle, media_id));
}
-
- let to = "root@localhost"; // fixme
-
let mut last_media_uuid = None;
let mut last_error = None;
@@ -390,7 +388,9 @@ pub fn request_and_load_media(
if tried {
if let Some(reason) = failure_reason {
task_log!(worker, "Please insert media '{}' into drive '{}'", label_text, drive);
- send_load_media_email(drive, &label_text, to, Some(reason))?;
+ if let Some(to) = notify_email {
+ send_load_media_email(drive, &label_text, to, Some(reason))?;
+ }
}
failure_reason = None;
diff --git a/src/tape/pool_writer.rs b/src/tape/pool_writer.rs
index 149c1913..40a3f783 100644
--- a/src/tape/pool_writer.rs
+++ b/src/tape/pool_writer.rs
@@ -64,11 +64,12 @@ pub struct PoolWriter {
drive_name: String,
status: Option<PoolWriterState>,
media_set_catalog: MediaSetCatalog,
+ notify_email: Option<String>,
}
impl PoolWriter {
- pub fn new(mut pool: MediaPool, drive_name: &str) -> Result<Self, Error> {
+ pub fn new(mut pool: MediaPool, drive_name: &str, notify_email: Option<String>) -> Result<Self, Error> {
let current_time = proxmox::tools::time::epoch_i64();
@@ -92,6 +93,7 @@ impl PoolWriter {
drive_name: drive_name.to_string(),
status: None,
media_set_catalog,
+ notify_email,
})
}
@@ -218,7 +220,7 @@ impl PoolWriter {
let (drive_config, _digest) = crate::config::drive::config()?;
let (mut drive, old_media_id) =
- request_and_load_media(worker, &drive_config, &self.drive_name, media.label())?;
+ request_and_load_media(worker, &drive_config, &self.drive_name, media.label(), &self.notify_email)?;
// test for critical tape alert flags
if let Ok(alert_flags) = drive.tape_alert_flags() {
--
2.20.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape: add notify-user fields
2021-03-05 8:45 [pbs-devel] [PATCH proxmox-backup 0/4] add notify-user to tape backup/restore Dominik Csapak
` (2 preceding siblings ...)
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 3/4] api2/tape: add notify_user to backup(-jobs) and restore api calls Dominik Csapak
@ 2021-03-05 8:45 ` Dominik Csapak
2021-03-05 12:02 ` [pbs-devel] applied: " Dietmar Maurer
3 siblings, 1 reply; 9+ messages in thread
From: Dominik Csapak @ 2021-03-05 8:45 UTC (permalink / raw)
To: pbs-devel
to backup jobs, backups and restores
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/tape/window/TapeBackup.js | 9 +++++++++
www/tape/window/TapeBackupJob.js | 9 +++++++++
www/tape/window/TapeRestore.js | 9 +++++++++
3 files changed, 27 insertions(+)
diff --git a/www/tape/window/TapeBackup.js b/www/tape/window/TapeBackup.js
index 30180146..ca9d3b5f 100644
--- a/www/tape/window/TapeBackup.js
+++ b/www/tape/window/TapeBackup.js
@@ -49,5 +49,14 @@ Ext.define('PBS.TapeManagement.TapeBackupWindow', {
name: 'eject-media',
fieldLabel: gettext('Eject Media'),
},
+ {
+ xtype: 'pbsUserSelector',
+ name: 'notify-user',
+ fieldLabel: gettext('Notify User'),
+ emptyText: 'root@pam',
+ value: null,
+ allowBlank: true,
+ renderer: Ext.String.htmlEncode,
+ },
],
});
diff --git a/www/tape/window/TapeBackupJob.js b/www/tape/window/TapeBackupJob.js
index e7f89d69..b5e98572 100644
--- a/www/tape/window/TapeBackupJob.js
+++ b/www/tape/window/TapeBackupJob.js
@@ -35,6 +35,7 @@ Ext.define('PBS.TapeManagement.BackupJobEdit', {
if (values['export-media-set'] && !me.up('pbsTapeBackupJobEdit').isCreate) {
Proxmox.Utils.assemble_field_data(values, { "delete": 'eject-media' });
}
+ PBS.Utils.delete_if_default(values, 'notify-user');
return values;
},
column1: [
@@ -63,6 +64,14 @@ Ext.define('PBS.TapeManagement.BackupJobEdit', {
fieldLabel: gettext('Drive'),
name: 'drive',
},
+ {
+ xtype: 'pbsUserSelector',
+ name: 'notify-user',
+ fieldLabel: gettext('Notify User'),
+ emptyText: 'root@pam',
+ allowBlank: true,
+ renderer: Ext.String.htmlEncode,
+ },
],
column2: [
diff --git a/www/tape/window/TapeRestore.js b/www/tape/window/TapeRestore.js
index 9e0a5edb..8d26e81e 100644
--- a/www/tape/window/TapeRestore.js
+++ b/www/tape/window/TapeRestore.js
@@ -41,5 +41,14 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
fieldLabel: gettext('Drive'),
name: 'drive',
},
+ {
+ xtype: 'pbsUserSelector',
+ name: 'notify-user',
+ fieldLabel: gettext('Notify User'),
+ emptyText: gettext('Current User'),
+ value: null,
+ allowBlank: true,
+ renderer: Ext.String.htmlEncode,
+ },
],
});
--
2.20.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable Dominik Csapak
@ 2021-03-05 12:02 ` Dietmar Maurer
0 siblings, 0 replies; 9+ messages in thread
From: Dietmar Maurer @ 2021-03-05 12:02 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dominik Csapak
instead, I avoid using Updatable for now ...
> On 03/05/2021 9:45 AM Dominik Csapak <d.csapak@proxmox.com> wrote:
>
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/api2/types/userid.rs | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/api2/types/userid.rs b/src/api2/types/userid.rs
> index 7c73e69f..3b47ccdf 100644
> --- a/src/api2/types/userid.rs
> +++ b/src/api2/types/userid.rs
> @@ -30,7 +30,7 @@ use lazy_static::lazy_static;
> use serde::{Deserialize, Serialize};
>
> use proxmox::api::api;
> -use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema};
> +use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema, Updatable};
> use proxmox::const_regex;
>
> // we only allow a limited set of characters
> @@ -393,7 +393,7 @@ impl<'a> TryFrom<&'a str> for &'a TokennameRef {
> }
>
> /// A complete user id consisting of a user name and a realm
> -#[derive(Clone, Debug, PartialEq, Eq, Hash)]
> +#[derive(Clone, Debug, PartialEq, Eq, Hash, Updatable)]
> pub struct Userid {
> data: String,
> name_len: usize,
> --
> 2.20.1
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup 2/4] config/tape_job: add notify-user config to tape jobs
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 2/4] config/tape_job: add notify-user config to tape jobs Dominik Csapak
@ 2021-03-05 12:02 ` Dietmar Maurer
0 siblings, 0 replies; 9+ messages in thread
From: Dietmar Maurer @ 2021-03-05 12:02 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dominik Csapak
applied
^ permalink raw reply [flat|nested] 9+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup 4/4] ui: tape: add notify-user fields
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape: add notify-user fields Dominik Csapak
@ 2021-03-05 12:02 ` Dietmar Maurer
0 siblings, 0 replies; 9+ messages in thread
From: Dietmar Maurer @ 2021-03-05 12:02 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dominik Csapak
applied
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup 3/4] api2/tape: add notify_user to backup(-jobs) and restore api calls
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 3/4] api2/tape: add notify_user to backup(-jobs) and restore api calls Dominik Csapak
@ 2021-03-05 12:03 ` Dietmar Maurer
0 siblings, 0 replies; 9+ messages in thread
From: Dietmar Maurer @ 2021-03-05 12:03 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dominik Csapak
please can you rebase this?
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-03-05 12:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 8:45 [pbs-devel] [PATCH proxmox-backup 0/4] add notify-user to tape backup/restore Dominik Csapak
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 1/4] api2/types/userid: make Userid updatable Dominik Csapak
2021-03-05 12:02 ` Dietmar Maurer
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 2/4] config/tape_job: add notify-user config to tape jobs Dominik Csapak
2021-03-05 12:02 ` [pbs-devel] applied: " Dietmar Maurer
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 3/4] api2/tape: add notify_user to backup(-jobs) and restore api calls Dominik Csapak
2021-03-05 12:03 ` Dietmar Maurer
2021-03-05 8:45 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape: add notify-user fields Dominik Csapak
2021-03-05 12:02 ` [pbs-devel] applied: " Dietmar Maurer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox