[pve-devel] [PATCH v4 qemu-server 08/10] cloud-init: sshkeys are now files on the CLI

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Mar 1 12:44:15 CET 2018


This requires a pve-common patch since we need to not only
load the file but also url-encode it.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 PVE/CLI/qm.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index d33b949..3347612 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -10,6 +10,7 @@ use Fcntl ':flock';
 use File::Path;
 use IO::Socket::UNIX;
 use IO::Select;
+use URI::Escape;
 
 use PVE::Tools qw(extract_param);
 use PVE::Cluster;
@@ -663,6 +664,20 @@ my $print_agent_result = sub {
     print to_json($result, { pretty => 1, canonical => 1});
 };
 
+sub param_mapping {
+    my ($name) = @_;
+
+    my $ssh_key_map = ['sshkeys', sub {
+	return URI::Escape::uri_escape(PVE::Tools::file_get_contents($_[0]));
+    }];
+    my $mapping = {
+	'update_vm' => [$ssh_key_map],
+	'create_vm' => [$ssh_key_map],
+    };
+
+    return $mapping->{$name};
+}
+
 our $cmddef = {
     list => [ "PVE::API2::Qemu", 'vmlist', [],
 	     { node => $nodename }, sub {
-- 
2.11.0





More information about the pve-devel mailing list