]> git.proxmox.com Git - pve-storage.git/commitdiff
replace read_password with param_mapping
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 15 Jun 2018 13:28:48 +0000 (15:28 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 27 Jun 2018 11:23:21 +0000 (13:23 +0200)
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@proxmox.com>
PVE/CLI/pvesm.pm

index 57743646e9255f03f10bb451db7646696487321a..d95b5f5ece118cb3d3814e491978625c93bb99a7 100755 (executable)
@@ -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 {