]> git.proxmox.com Git - qemu-server.git/commitdiff
cloud-init: make cipassword interactive on the CLI
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 12 Mar 2018 12:04:16 +0000 (13:04 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 13 Mar 2018 10:32:52 +0000 (11:32 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
PVE/CLI/qm.pm

index 3347612556bc3689abd783540bb9ea2d1cffeaba..c017a597e1dd9413ffeb3cd1a28808dc8600c1eb 100755 (executable)
@@ -13,6 +13,7 @@ use IO::Select;
 use URI::Escape;
 
 use PVE::Tools qw(extract_param);
+use PVE::PTY;
 use PVE::Cluster;
 use PVE::SafeSyslog;
 use PVE::INotify;
@@ -670,9 +671,18 @@ sub param_mapping {
     my $ssh_key_map = ['sshkeys', sub {
        return URI::Escape::uri_escape(PVE::Tools::file_get_contents($_[0]));
     }];
+    my $cipassword_map = ['cipassword', sub {
+       my ($value) = @_;
+       return $value if $value;
+
+       my $pw = PVE::PTY::read_password('New cloud-init user password: ');
+       my $pw2 = PVE::PTY::read_password('Repeat password: ');
+       die "passwords do not match\n" if $pw ne $pw2;
+       return $pw;
+    }, '<password>', 1];
     my $mapping = {
-       'update_vm' => [$ssh_key_map],
-       'create_vm' => [$ssh_key_map],
+       'update_vm' => [$ssh_key_map, $cipassword_map],
+       'create_vm' => [$ssh_key_map, $cipassword_map],
     };
 
     return $mapping->{$name};