[pve-devel] r5070 - in pve-manager/pve2: . bin lib/PVE/API2
svn-commits at proxmox.com
svn-commits at proxmox.com
Fri Aug 27 09:23:12 CEST 2010
Author: dietmar
Date: 2010-08-27 07:23:12 +0000 (Fri, 27 Aug 2010)
New Revision: 5070
Modified:
pve-manager/pve2/ChangeLog
pve-manager/pve2/bin/pvesh
pve-manager/pve2/lib/PVE/API2/VM.pm
Log:
* bin/pvesh (list_dir): do not display all data - instead display
some info about available methods.
Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog 2010-08-27 06:47:37 UTC (rev 5069)
+++ pve-manager/pve2/ChangeLog 2010-08-27 07:23:12 UTC (rev 5070)
@@ -1,3 +1,8 @@
+2010-08-27 Proxmox Support Team <support at proxmox.com>
+
+ * bin/pvesh (list_dir): do not display all data - instead display
+ some info about available methods.
+
2010-08-26 Proxmox Support Team <support at proxmox.com>
* bin/pvesh: use new cli_handler2(), implement help, cleanups
Modified: pve-manager/pve2/bin/pvesh
===================================================================
--- pve-manager/pve2/bin/pvesh 2010-08-27 06:47:37 UTC (rev 5069)
+++ pve-manager/pve2/bin/pvesh 2010-08-27 07:23:12 UTC (rev 5070)
@@ -128,6 +128,46 @@
print $handler->usage_str($info->{name}, "$cmd $dir", [], $uri_param, 'full', 1);
}
+sub resource_cap {
+ my ($path) = @_;
+
+ my $res = '';
+
+ my ($handler, $info) = PVE::API2->find_handler('GET', $path);
+ if (!($handler && $info)) {
+ $res .= '--';
+ } else {
+ if (PVE::JSONSchema::method_get_child_link($info)) {
+ $res .= 'Dr';
+ } else {
+ $res .= '-r';
+ }
+ }
+
+ ($handler, $info) = PVE::API2->find_handler('PUT', $path);
+ if (!($handler && $info)) {
+ $res .= '-';
+ } else {
+ $res .= 'w';
+ }
+
+ ($handler, $info) = PVE::API2->find_handler('POST', $path);
+ if (!($handler && $info)) {
+ $res .= '-';
+ } else {
+ $res .= 'c';
+ }
+
+ ($handler, $info) = PVE::API2->find_handler('DELETE', $path);
+ if (!($handler && $info)) {
+ $res .= '-';
+ } else {
+ $res .= 'd';
+ }
+
+ return $res;
+}
+
sub list_dir {
my ($dir, $args) = @_;
@@ -154,12 +194,8 @@
if (defined(my $value = $elem->{$prop})) {
if ($value ne '') {
- if (scalar(keys %$elem) > 1) {
- my $tv = to_json($elem, {allow_nonref => 1, canonical => 1});
- print "$value $tv\n";
- } else {
- print "$value\n";
- }
+ my $cap = resource_cap(abs_path($dir, $value));
+ print "$cap $value\n";
}
}
}
Modified: pve-manager/pve2/lib/PVE/API2/VM.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/VM.pm 2010-08-27 06:47:37 UTC (rev 5069)
+++ pve-manager/pve2/lib/PVE/API2/VM.pm 2010-08-27 07:23:12 UTC (rev 5070)
@@ -3,18 +3,59 @@
use strict;
use warnings;
-use PVE::SafeSyslog;
-use Apache2::Const qw(:http);
-use JSON;
-
use PVE::RESTHandler;
use base qw(PVE::RESTHandler);
+use PVE::API2::QemuServer;
+
__PACKAGE__->register_method ({
+ subclass => "PVE::API2::QemuServer",
+ path => 'qm',
+});
+
+__PACKAGE__->register_method ({
name => 'index',
path => '',
method => 'GET',
+ description => "Directory index.",
+ parameters => {
+ additionalProperties => 0,
+ properties => {},
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ subdir => { type => 'string' },
+ },
+ },
+ links => [ { rel => 'child', href => "{subdir}" } ],
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $res = [];
+
+ my $ma = __PACKAGE__->method_attributes();
+
+ foreach my $info (@$ma) {
+ next if !$info->{subclass};
+
+ my $subpath = $info->{match_re}->[0];
+
+ push @$res, { subdir => $subpath };
+ }
+
+ return $res;
+ }});
+
+# fixme:remove
+__PACKAGE__->register_method ({
+ name => 'oldindex',
+ path => 'oldindex',
+ method => 'GET',
description => "Virtual machine index.",
parameters => {
additionalProperties => 0,
More information about the pve-devel
mailing list