public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject
@ 2021-03-03 14:00 Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 2/5] add proxmox-tape zsh-completions Dominik Csapak
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Dominik Csapak @ 2021-03-03 14:00 UTC (permalink / raw)
  To: pbs-devel

We call 'ejectMedia' not 'eject', so rename the function.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/DriveStatus.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index f39ee88e..c064ecc5 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -74,7 +74,7 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    }).show();
 	},
 
-	eject: function() {
+	ejectMedia: function() {
 	    let me = this;
 	    let view = me.getView();
 	    let driveid = view.drive;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/5] add proxmox-tape zsh-completions
  2021-03-03 14:00 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dominik Csapak
@ 2021-03-03 14:00 ` Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape: only add tapestore and nav element once Dominik Csapak
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2021-03-03 14:00 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 debian/proxmox-backup-server.install |  1 +
 zsh-completions/_proxmox-tape        | 13 +++++++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 zsh-completions/_proxmox-tape

diff --git a/debian/proxmox-backup-server.install b/debian/proxmox-backup-server.install
index 28df7756..cebf84a3 100644
--- a/debian/proxmox-backup-server.install
+++ b/debian/proxmox-backup-server.install
@@ -32,5 +32,6 @@ usr/share/man/man5/media-pool.cfg.5
 usr/share/man/man5/tape.cfg.5
 usr/share/man/man5/tape-job.cfg.5
 usr/share/zsh/vendor-completions/_proxmox-backup-manager
+usr/share/zsh/vendor-completions/_proxmox-tape
 usr/share/zsh/vendor-completions/_pmtx
 usr/share/zsh/vendor-completions/_pmt
diff --git a/zsh-completions/_proxmox-tape b/zsh-completions/_proxmox-tape
new file mode 100644
index 00000000..d1490c85
--- /dev/null
+++ b/zsh-completions/_proxmox-tape
@@ -0,0 +1,13 @@
+#compdef _proxmox-tape() proxmox-tape
+
+function _proxmox-tape() {
+    local cwords line point cmd curr prev
+    cworkds=${#words[@]}
+    line=$words
+    point=${#line}
+    cmd=${words[1]}
+    curr=${words[cwords]}
+    prev=${words[cwords-1]}
+    compadd -- $(COMP_CWORD="$cwords" COMP_LINE="$line" COMP_POINT="$point" \
+        proxmox-tape bashcomplete "$cmd" "$curr" "$prev")
+}
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape: only add tapestore and nav element once
  2021-03-03 14:00 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 2/5] add proxmox-tape zsh-completions Dominik Csapak
@ 2021-03-03 14:00 ` Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 4/5] tape/drive: improve error and email handling for requesting a tape load Dominik Csapak
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2021-03-03 14:00 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/NavigationTree.js | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index 1c33d52d..4b25114e 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -119,25 +119,28 @@ Ext.define('PBS.view.main.NavigationTree', {
 	    view.on('destroy', view.rstore.stopUpdate);
 
 	    if (PBS.enableTapeUI) {
-		view.tapestore = Ext.create('Proxmox.data.UpdateStore', {
-		    autoStart: true,
-		    interval: 2 * 1000,
-		    storeid: 'pbs-tape-drive-list',
-		    model: 'pbs-tape-drive-list',
-		});
+		if (view.tapestore === undefined) {
+		    view.tapestore = Ext.create('Proxmox.data.UpdateStore', {
+			autoStart: true,
+			interval: 2 * 1000,
+			storeid: 'pbs-tape-drive-list',
+			model: 'pbs-tape-drive-list',
+		    });
+		    view.tapestore.on('load', this.onTapeDriveLoad, this);
+		    view.on('destroy', view.tapestore.stopUpdate);
+		}
 
 		let root = view.getStore().getRoot();
-		root.insertChild(3, {
-		    text: "Tape Backup",
-		    iconCls: 'pbs-icon-tape',
-		    id: 'tape_management',
-		    path: 'pbsTapeManagement',
-		    expanded: true,
-		    children: [],
-		});
-
-		view.tapestore.on('load', this.onTapeDriveLoad, this);
-		view.on('destroy', view.tapestore.stopUpdate);
+		if (root.findChild('id', 'tape_management', false) === null) {
+		    root.insertChild(3, {
+			text: "Tape Backup",
+			iconCls: 'pbs-icon-tape',
+			id: 'tape_management',
+			path: 'pbsTapeManagement',
+			expanded: true,
+			children: [],
+		    });
+		}
 	    }
 	},
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 4/5] tape/drive: improve error and email handling for requesting a tape load
  2021-03-03 14:00 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 2/5] add proxmox-tape zsh-completions Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape: only add tapestore and nav element once Dominik Csapak
@ 2021-03-03 14:00 ` Dominik Csapak
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape: add missing monStoreErrors calls for the grids Dominik Csapak
  2021-03-03 15:11 ` [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dietmar Maurer
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2021-03-03 14:00 UTC (permalink / raw)
  To: pbs-devel

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>
---
 src/tape/changer/email.rs |  5 +++++
 src/tape/drive/mod.rs     | 43 ++++++++++++++++++++++++---------------
 2 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/src/tape/changer/email.rs b/src/tape/changer/email.rs
index 9be06196..abd7ead8 100644
--- a/src/tape/changer/email.rs
+++ b/src/tape/changer/email.rs
@@ -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));
diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs
index ba63f4d4..8bbca98c 100644
--- a/src/tape/drive/mod.rs
+++ b/src/tape/drive/mod.rs
@@ -375,18 +375,34 @@ pub fn request_and_load_media(
                         return Ok((handle, media_id));
                     }
 
-                    task_log!(worker, "Please insert media '{}' into drive '{}'", label_text, drive);
 
                     let to = "root@localhost"; // fixme
 
-                    send_load_media_email(drive, &label_text, to)?;
-
                     let mut last_media_uuid = None;
                     let mut last_error = None;
 
+                    let mut tried = false;
+                    let mut failure_reason = None;
+
                     loop {
                         worker.check_abort()?;
 
+                        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))?;
+                            }
+
+                            failure_reason = None;
+
+                            for _ in 0..50 { // delay 5 seconds
+                                worker.check_abort()?;
+                                std::thread::sleep(std::time::Duration::from_millis(100));
+                            }
+                        }
+
+                        tried = true;
+
                         let mut handle = match drive_config.open() {
                             Ok(handle) => handle,
                             Err(err) => {
@@ -394,10 +410,7 @@ pub fn request_and_load_media(
                                 if Some(err.clone()) != last_error {
                                     task_log!(worker, "tape open failed - {}", err);
                                     last_error = Some(err);
-                                }
-                                for _ in 0..50 { // delay 5 seconds
-                                    worker.check_abort()?;
-                                    std::thread::sleep(std::time::Duration::from_millis(100));
+                                    failure_reason = last_error.clone();
                                 }
                                 continue;
                             }
@@ -414,19 +427,22 @@ pub fn request_and_load_media(
                                     );
                                     return Ok((Box::new(handle), media_id));
                                 } else if Some(media_id.label.uuid.clone()) != last_media_uuid {
-                                    task_log!(
-                                        worker,
+                                    let err = format!(
                                         "wrong media label {} ({})",
                                         media_id.label.label_text,
                                         media_id.label.uuid.to_string(),
                                     );
+                                    task_log!(worker, "{}", err);
                                     last_media_uuid = Some(media_id.label.uuid);
+                                    failure_reason = Some(err);
                                 }
                             }
                             Ok((None, _)) => {
                                 if last_media_uuid.is_some() {
-                                    task_log!(worker, "found empty media without label (please label all tapes first)");
+                                    let err = "found empty media without label (please label all tapes first)";
+                                    task_log!(worker, "{}", err);
                                     last_media_uuid = None;
+                                    failure_reason = Some(err.to_string());
                                 }
                             }
                             Err(err) => {
@@ -434,15 +450,10 @@ pub fn request_and_load_media(
                                 if Some(err.clone()) != last_error {
                                     task_log!(worker, "tape open failed - {}", err);
                                     last_error = Some(err);
+                                    failure_reason = last_error.clone();
                                 }
                             }
                         }
-
-                        // eprintln!("read label failed -  test again in 5 secs");
-                        for _ in 0..50 { // delay 5 seconds
-                            worker.check_abort()?;
-                            std::thread::sleep(std::time::Duration::from_millis(100));
-                        }
                     }
                 }
                 _ => bail!("drive type '{}' not implemented!"),
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape: add missing monStoreErrors calls for the grids
  2021-03-03 14:00 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dominik Csapak
                   ` (2 preceding siblings ...)
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 4/5] tape/drive: improve error and email handling for requesting a tape load Dominik Csapak
@ 2021-03-03 14:00 ` Dominik Csapak
  2021-03-03 15:11 ` [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dietmar Maurer
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2021-03-03 14:00 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/ChangerConfig.js  | 4 ++++
 www/tape/DriveConfig.js    | 4 ++++
 www/tape/EncryptionKeys.js | 4 ++++
 www/tape/PoolConfig.js     | 4 ++++
 www/tape/TapeInventory.js  | 4 ++++
 5 files changed, 20 insertions(+)

diff --git a/www/tape/ChangerConfig.js b/www/tape/ChangerConfig.js
index a4258dfd..1646ddef 100644
--- a/www/tape/ChangerConfig.js
+++ b/www/tape/ChangerConfig.js
@@ -49,6 +49,10 @@ Ext.define('PBS.TapeManagement.ChangerPanel', {
 	startStore: function() {
 	    this.getView().getStore().rstore.startUpdate();
 	},
+
+	init: function(view) {
+	    Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
+	},
     },
 
     listeners: {
diff --git a/www/tape/DriveConfig.js b/www/tape/DriveConfig.js
index 0dfd2b89..de6a0525 100644
--- a/www/tape/DriveConfig.js
+++ b/www/tape/DriveConfig.js
@@ -94,6 +94,10 @@ Ext.define('PBS.TapeManagement.DrivePanel', {
 	startStore: function() {
 	    this.getView().getStore().rstore.startUpdate();
 	},
+
+	init: function(view) {
+	    Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
+	},
     },
 
     listeners: {
diff --git a/www/tape/EncryptionKeys.js b/www/tape/EncryptionKeys.js
index ac540d21..2c70736c 100644
--- a/www/tape/EncryptionKeys.js
+++ b/www/tape/EncryptionKeys.js
@@ -68,6 +68,10 @@ Ext.define('PBS.TapeManagement.EncryptionPanel', {
 	startStore: function() {
 	    this.getView().getStore().rstore.startUpdate();
 	},
+
+	init: function(view) {
+	    Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
+	},
     },
 
     listeners: {
diff --git a/www/tape/PoolConfig.js b/www/tape/PoolConfig.js
index cb2b9a05..3f3e1a18 100644
--- a/www/tape/PoolConfig.js
+++ b/www/tape/PoolConfig.js
@@ -58,6 +58,10 @@ Ext.define('PBS.TapeManagement.PoolPanel', {
 	startStore: function() {
 	    this.getView().getStore().rstore.startUpdate();
 	},
+
+	init: function(view) {
+	    Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
+	},
     },
 
     listeners: {
diff --git a/www/tape/TapeInventory.js b/www/tape/TapeInventory.js
index 28909754..555445ff 100644
--- a/www/tape/TapeInventory.js
+++ b/www/tape/TapeInventory.js
@@ -160,6 +160,10 @@ Ext.define('PBS.TapeManagement.TapeInventory', {
 		params: { 'update-status': true },
 	    });
 	},
+
+	init: function(view) {
+	    Proxmox.Utils.monStoreErrors(view, view.getStore());
+	},
     },
 
     listeners: {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject
  2021-03-03 14:00 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dominik Csapak
                   ` (3 preceding siblings ...)
  2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape: add missing monStoreErrors calls for the grids Dominik Csapak
@ 2021-03-03 15:11 ` Dietmar Maurer
  4 siblings, 0 replies; 6+ messages in thread
From: Dietmar Maurer @ 2021-03-03 15:11 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

applied all 5 patches




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-03 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 14:00 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dominik Csapak
2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 2/5] add proxmox-tape zsh-completions Dominik Csapak
2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape: only add tapestore and nav element once Dominik Csapak
2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 4/5] tape/drive: improve error and email handling for requesting a tape load Dominik Csapak
2021-03-03 14:00 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape: add missing monStoreErrors calls for the grids Dominik Csapak
2021-03-03 15:11 ` [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape/DriveStatus: fix handler name for eject Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal