[pve-devel] r5048 - in pve-manager/pve2: . bin lib/PVE lib/PVE/API2 www
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Aug 24 13:44:57 CEST 2010
Author: dietmar
Date: 2010-08-24 11:44:57 +0000 (Tue, 24 Aug 2010)
New Revision: 5048
Modified:
pve-manager/pve2/ChangeLog
pve-manager/pve2/bin/pvesh
pve-manager/pve2/lib/PVE/API2.pm
pve-manager/pve2/lib/PVE/API2/AccessControl.pm
pve-manager/pve2/lib/PVE/API2/Cluster.pm
pve-manager/pve2/lib/PVE/API2/VM.pm
pve-manager/pve2/lib/PVE/APIDaemon.pm
pve-manager/pve2/lib/PVE/REST.pm
pve-manager/pve2/www/startup.pl
Log:
* lib/PVE/APIDaemon.pm: use new RPCEnvironment
* www/startup.pl: use new RPCEnvironment
* lib/PVE/API2/*.pm: remove $conn everywhere
Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/ChangeLog 2010-08-24 11:44:57 UTC (rev 5048)
@@ -1,3 +1,11 @@
+2010-08-24 Proxmox Support Team <support at proxmox.com>
+
+ * lib/PVE/APIDaemon.pm: use new RPCEnvironment
+
+ * www/startup.pl: use new RPCEnvironment
+
+ * lib/PVE/API2/*.pm: remove $conn everywhere
+
2010-08-17 Proxmox Support Team <support at proxmox.com>
* lib/PVE/API2/Makefile.am (pvelib_DATA): moved API2::Storage.pm
Modified: pve-manager/pve2/bin/pvesh
===================================================================
--- pve-manager/pve2/bin/pvesh 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/bin/pvesh 2010-08-24 11:44:57 UTC (rev 5048)
@@ -7,16 +7,26 @@
# implement auto-completion
use strict;
-use PVE::API2;
use Term::ReadLine;
use File::Basename;
use HTTP::Status qw(:constants :is status_message);
use Text::ParseWords;
use PVE::JSONSchema;
+use PVE::INotify;
+use PVE::RPCEnvironment;
+use PVE::API2;
use JSON;
use Data::Dumper; # fixme: remove
+PVE::INotify::inotify_init();
+
+my $rpcenv = PVE::RPCEnvironment->init('cli');
+
+$rpcenv->set_language($ENV{LANG});
+
+$rpcenv->set_user('root');
+
my $basedir = '/api2/json';
my $cdir = '';
@@ -55,15 +65,8 @@
sub call_handler {
my ($handler, $info, $dir, $params, $nooutput) = @_;
- my $conn = {
- abs_uri => "$basedir/$dir",
- rel_uri => $dir,
- user => 'root', # fixme ?
- params => $params,
- };
+ my $data = $handler->handle($info, $params);
- my $data = $handler->handle($info, $conn);
-
return $data if $nooutput;
warn "200 OK\n"; # always print OK status if successful
Modified: pve-manager/pve2/lib/PVE/API2/AccessControl.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/AccessControl.pm 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/lib/PVE/API2/AccessControl.pm 2010-08-24 11:44:57 UTC (rev 5048)
@@ -54,7 +54,7 @@
links => [ { rel => 'child', href => "{subdir}" } ],
},
code => sub {
- my ($conn, $param) = @_;
+ my ($param) = @_;
my $res = [];
Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm 2010-08-24 11:44:57 UTC (rev 5048)
@@ -29,7 +29,7 @@
links => [ { rel => 'child', href => "{name}" } ],
},
code => sub {
- my ($conn, $param) = @_;
+ my ($param) = @_;
# fixme: this is just some test code
Modified: pve-manager/pve2/lib/PVE/API2/VM.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/VM.pm 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/lib/PVE/API2/VM.pm 2010-08-24 11:44:57 UTC (rev 5048)
@@ -29,7 +29,7 @@
links => [ { rel => 'child', href => "{id}" } ],
},
code => sub {
- my ($conn, $param) = @_;
+ my ($param) = @_;
my $ctime = int(time()/3);
$ctime = 0;
Modified: pve-manager/pve2/lib/PVE/API2.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2.pm 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/lib/PVE/API2.pm 2010-08-24 11:44:57 UTC (rev 5048)
@@ -54,7 +54,7 @@
links => [ { rel => 'child', href => "{subdir}" } ],
},
code => sub {
- my ($conn, $resp, $param) = @_;
+ my ($resp, $param) = @_;
my $res = [];
Modified: pve-manager/pve2/lib/PVE/APIDaemon.pm
===================================================================
--- pve-manager/pve2/lib/PVE/APIDaemon.pm 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/lib/PVE/APIDaemon.pm 2010-08-24 11:44:57 UTC (rev 5048)
@@ -4,7 +4,9 @@
use warnings;
use vars qw(@ISA);
use PVE::SafeSyslog;
-use PVE::Config;
+use PVE::INotify;
+use PVE::RPCEnvironment;
+
use POSIX qw(EINTR);
use POSIX ":sys_wait_h";
use IO::Handle;
@@ -95,9 +97,10 @@
eval {
# try to init inotify
- PVE::Config::inotify_init();
+ PVE::INotify::inotify_init();
+ my $rpcenv = PVE::RPCEnvironment->init('priv');
- $self->handle_requests ();
+ $self->handle_requests($rpcenv);
};
syslog ('err', $@) if $@;
@@ -198,7 +201,7 @@
}
sub handle_requests {
- my $self = shift;
+ my ($self, $rpcenv) = @_;
my $rcount = 0;
@@ -239,7 +242,6 @@
} else {
-
my $headers = $r->headers;
my $cookie = $headers->header('Cookie');
@@ -293,7 +295,7 @@
last if $child_terminate;
# timeout
- PVE::Config::poll(); # read inotify events
+ PVE::INotify::poll(); # read inotify events
}
}
}
Modified: pve-manager/pve2/lib/PVE/REST.pm
===================================================================
--- pve-manager/pve2/lib/PVE/REST.pm 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/lib/PVE/REST.pm 2010-08-24 11:44:57 UTC (rev 5048)
@@ -300,25 +300,22 @@
$uri_param->{$p} = $params->{$p};
}
- # fixme: language ?
- my $conn = {
- abs_uri => $abs_uri,
- rel_uri => $rel_uri,
- user => $username,
- params => $uri_param,
- };
-
# fixme: not sure if we should do that here, because we can't proxy those
# methods to other hosts?
return { proxy => 'localhost' } if $info->{protected} && ($euid != 0);
+ # setup environment
+ my $rpcenv = PVE::RPCEnvironment::get();
+ $rpcenv->set_language('C'); # fixme:
+ $rpcenv->set_user($username);
+
my $resp = {
info => $info, # useful to format output
status => HTTP_OK,
};
eval {
- $resp->{data} = $handler->handle($info, $conn);
+ $resp->{data} = $handler->handle($info, $uri_param);
};
my $err = $@;
if ($err) {
Modified: pve-manager/pve2/www/startup.pl
===================================================================
--- pve-manager/pve2/www/startup.pl 2010-08-24 11:41:01 UTC (rev 5047)
+++ pve-manager/pve2/www/startup.pl 2010-08-24 11:44:57 UTC (rev 5048)
@@ -30,11 +30,13 @@
use PVE::pvecfg;
use PVE::AuthCookieHandler;
use PVE::REST;
-use PVE::Config;
+use PVE::INotify;
+use PVE::RPCEnvironment;
sub childinit {
syslog ('info', "Starting new child $$");
- PVE::Config::inotify_init();
+ PVE::INotify::inotify_init();
+ PVE::RPCEnvironment->init('pub');
}
sub childexit {
More information about the pve-devel
mailing list