[pve-devel] [PATCH] pending api : change structure from array to nested objects
Alexandre Derumier
aderumier at odiso.com
Wed Dec 31 09:57:12 CET 2014
fixme : parse digest
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/API2/Qemu.pm | 45 +++++++++++++--------------------------------
1 file changed, 13 insertions(+), 32 deletions(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index a45509e..647fe03 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -689,26 +689,13 @@ __PACKAGE__->register_method({
},
},
returns => {
- type => "array",
- items => {
- type => "object",
- properties => {
- key => {
- description => "Configuration option name.",
- type => 'string',
- },
- value => {
- description => "Current value.",
- type => 'string',
- optional => 1,
- },
- delete => {
- description => "Indicated a pending delete request.",
- type => 'boolean',
- optional => 1,
- },
- },
- },
+ type => "object",
+# properties => {
+# digest => {
+# type => 'string',
+# description => 'SHA1 digest of configuration file. This can be used to prevent concurrent modifications.',
+# }
+# },
},
code => sub {
my ($param) = @_;
@@ -720,33 +707,27 @@ __PACKAGE__->register_method({
$pending_delete_hash->{$opt} = 1;
}
- my $res = [];
+ my $res = {};
foreach my $opt (keys $conf) {
next if ref($conf->{$opt});
- my $item = { key => $opt };
- $item->{value} = $conf->{$opt} if defined($conf->{$opt});
- $item->{pending} = $conf->{pending}->{$opt} if defined($conf->{pending}->{$opt});
- $item->{delete} = 1 if $pending_delete_hash->{$opt};
- push @$res, $item;
+ $res->{$opt}->{value} = $conf->{$opt} if defined($conf->{$opt});
+ $res->{$opt}->{pending} = $conf->{pending}->{$opt} if defined($conf->{pending}->{$opt});
+ $res->{$opt}->{delete} = 1 if $pending_delete_hash->{$opt};
}
foreach my $opt (keys $conf->{pending}) {
next if $opt eq 'delete';
next if ref($conf->{pending}->{$opt}); # just to be sure
next if $conf->{$opt};
- my $item = { key => $opt };
- $item->{pending} = $conf->{pending}->{$opt};
- push @$res, $item;
+ my $res->{$opt}->{pending} = $conf->{pending}->{$opt};
}
foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) {
next if $conf->{pending}->{$opt}; # just to be sure
next if $conf->{$opt};
- my $item = { key => $opt, delete => 1};
- push @$res, $item;
+ my $res->{$opt}->{delete} = 1;
}
-
return $res;
}});
--
1.7.10.4
More information about the pve-devel
mailing list