[pve-devel] [PATCH qemu-server 4/8] add 'set-user-password' to qm

Dominik Csapak d.csapak at proxmox.com
Thu Jun 7 13:16:53 CEST 2018


and implement read_password for qm.pm

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

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index c017a59..ee52c4b 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -665,6 +665,14 @@ my $print_agent_result = sub {
     print to_json($result, { pretty => 1, canonical => 1});
 };
 
+sub read_password {
+    # return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
+    my $pw = PVE::PTY::read_password('New VM user password: ');
+    my $pw2 = PVE::PTY::read_password('Repeat password: ');
+    die "passwords do not match\n" if $pw ne $pw2;
+    return $pw;
+}
+
 sub param_mapping {
     my ($name) = @_;
 
@@ -815,6 +823,8 @@ our $cmddef = {
     agent  => [ "PVE::API2::Qemu::Agent", 'agent', ['vmid', 'command'],
 		{ node => $nodename }, $print_agent_result ],
 
+    'set-user-password' => [ "PVE::API2::Qemu::Agent", 'set-user-password', [ 'vmid', 'username' ], { node => $nodename }],
+
     mtunnel => [ __PACKAGE__, 'mtunnel', []],
 
     nbdstop => [ __PACKAGE__, 'nbdstop', ['vmid']],
-- 
2.11.0




More information about the pve-devel mailing list