From 7370974930cd0792a279672f1ef54a1da61b6aa3 Mon Sep 17 00:00:00 2001 From: Mira Limbeck Date: Wed, 5 Jun 2019 11:09:42 +0200 Subject: [PATCH] add new API for dumping cloudinit config Adds the path '{vmid}/cloudinit/dump' and requires the parameter 'type' that's either 'user', 'network' or 'meta'. Returns the generated config as string. Signed-off-by: Mira Limbeck --- PVE/API2/Qemu.pm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 65a192f3..74aa42f7 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -3859,4 +3859,36 @@ __PACKAGE__->register_method({ return undef; }}); +__PACKAGE__->register_method({ + name => 'cloudinit_generated_config_dump', + path => '{vmid}/cloudinit/dump', + method => 'GET', + proxyto => 'node', + description => "Get automatically generated cloudinit config.", + permissions => { + check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }), + type => { + description => 'Config type.', + type => 'string', + enum => ['user', 'network', 'meta'], + }, + }, + }, + returns => { + type => 'string', + }, + code => sub { + my ($param) = @_; + + my $conf = PVE::QemuConfig->load_config($param->{vmid}); + + return PVE::QemuServer::Cloudinit::dump_cloudinit_config($conf, $param->{vmid}, $param->{type}); + }}); + 1;