[pve-devel] [PATCH v2 storage 1/1] replace read_password with param_mapping

Dominik Csapak d.csapak at proxmox.com
Fri Jun 15 15:28:48 CEST 2018


we only need this for cifs as this is the only type
of storage where we expect a password

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/CLI/pvesm.pm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm
index 5774364..d95b5f5 100755
--- a/PVE/CLI/pvesm.pm
+++ b/PVE/CLI/pvesm.pm
@@ -27,8 +27,21 @@ my $KNOWN_EXPORT_FORMATS = ['raw+size', 'tar+size', 'qcow2+size', 'vmdk+size', '
 
 my $nodename = PVE::INotify::nodename();
 
-sub read_password {
-    return PVE::PTY::read_password("Enter Password: ");
+sub param_mapping {
+    my ($name) = @_;
+
+    my $password_map = PVE::CLIHandler::get_standard_mapping('pve-password', {
+	func => sub {
+	    my ($value) = @_;
+	    return $value if $value;
+	    return PVE::PTY::read_password("Enter Password: ");
+	},
+    });
+    my $mapping = {
+	'cifsscan' => [ $password_map ],
+	'create' => [ $password_map ],
+    };
+    return $mapping->{$name};
 }
 
 sub setup_environment {
-- 
2.11.0





More information about the pve-devel mailing list