]> git.proxmox.com Git - qemu-server.git/commitdiff
add new API for dumping cloudinit config
authorMira Limbeck <m.limbeck@proxmox.com>
Wed, 5 Jun 2019 09:09:42 +0000 (11:09 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 6 Jun 2019 12:34:11 +0000 (14:34 +0200)
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 <m.limbeck@proxmox.com>
PVE/API2/Qemu.pm

index 65a192f36dc7ed996a275c325197eaa698cdbd05..74aa42f75ef3903ea12cee129cd65fb09e4f6e08 100644 (file)
@@ -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;