[pve-devel] [PATCH qemu-server 5/7] add an guest agent index call

Dominik Csapak d.csapak at proxmox.com
Tue Feb 13 16:47:11 CET 2018


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/API2/Qemu/Agent.pm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/PVE/API2/Qemu/Agent.pm b/PVE/API2/Qemu/Agent.pm
index 9d87b43..2743595 100644
--- a/PVE/API2/Qemu/Agent.pm
+++ b/PVE/API2/Qemu/Agent.pm
@@ -37,6 +37,44 @@ my $guest_agent_commands = [
 #	   or a permission object
 my $ga_cmd_properties =  {};
 
+__PACKAGE__->register_method({
+    name => 'index',
+    path => '',
+    proxyto => 'node',
+    method => 'GET',
+    description => "Qemu Agent command index.",
+    permissions => {
+	user => 'all',
+    },
+    parameters => {
+	additionalProperties => 1,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    vmid => get_standard_option('pve-vmid', {
+                   completion => \&PVE::QemuServer::complete_vmid_running }),
+	},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => {},
+	},
+	links => [ { rel => 'child', href => '{name}' } ],
+	description => "Returns the list of Qemu Agent commands",
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $result = [];
+
+	for my $cmd (@$guest_agent_commands) {
+	    push @$result, { name => $cmd };
+	}
+
+	return $result;
+    }});
+
 sub register_command {
     my ($class, $command, $method, $perm) = @_;
 
-- 
2.11.0





More information about the pve-devel mailing list