[pve-devel] r5452 - in qemu-server/pve2: . PVE/API2/Qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Jan 28 06:12:25 CET 2011


Author: dietmar
Date: 2011-01-28 06:12:25 +0100 (Fri, 28 Jan 2011)
New Revision: 5452

Modified:
   qemu-server/pve2/PVE/API2/Qemu/Config.pm
   qemu-server/pve2/PVE/API2/Qemu/Status.pm
   qemu-server/pve2/PVE/API2/Qemu/VNC.pm
   qemu-server/pve2/control.in
   qemu-server/pve2/qm
Log:
start using new PVE::Cluster code


Modified: qemu-server/pve2/PVE/API2/Qemu/Config.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/Config.pm	2011-01-27 13:28:52 UTC (rev 5451)
+++ qemu-server/pve2/PVE/API2/Qemu/Config.pm	2011-01-28 05:12:25 UTC (rev 5452)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
+use PVE::Cluster;
 use PVE::SafeSyslog;
 use PVE::Tools qw(extract_param);
 use PVE::Exception qw(raise raise_param_exc);
@@ -25,7 +26,6 @@
 # PUT    /vms/qemu/config/{node}/{vmid}  set VM config
 # DELETE /vms/qemu/config/{node}/{vmid}  destroy VM
 
-# GET    /vms/qemu/status  status of all Qemu VMs (cluster wide)
 # GET    /vms/qemu/status/{node}/  status of all Qemu VMs (per node)
 # GET    /vms/qemu/status/{node}/{vmid}  get VM status
 # PUT    /vms/qemu/status/{node}/{vmid}  set VM status
@@ -67,7 +67,7 @@
 	my ($param) = @_;
 
 	my $rpcenv = PVE::RPCEnvironment::get();
-	return $rpcenv->get_nodelist();
+	return PVE::Cluster::get_nodelist();
     }});
 
 __PACKAGE__->register_method ({

Modified: qemu-server/pve2/PVE/API2/Qemu/Status.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/Status.pm	2011-01-27 13:28:52 UTC (rev 5451)
+++ qemu-server/pve2/PVE/API2/Qemu/Status.pm	2011-01-28 05:12:25 UTC (rev 5452)
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
+use PVE::Cluster;
 use PVE::SafeSyslog;
 use PVE::Tools qw(extract_param);
 use PVE::Exception qw(raise raise_param_exc);
@@ -37,7 +38,7 @@
 	my ($param) = @_;
 
 	my $rpcenv = PVE::RPCEnvironment::get();
-	return $rpcenv->get_nodelist();
+	return PVE::Cluster::get_nodelist();
     }});
 
 __PACKAGE__->register_method ({

Modified: qemu-server/pve2/PVE/API2/Qemu/VNC.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/VNC.pm	2011-01-27 13:28:52 UTC (rev 5451)
+++ qemu-server/pve2/PVE/API2/Qemu/VNC.pm	2011-01-28 05:12:25 UTC (rev 5452)
@@ -2,7 +2,6 @@
 
 use strict;
 use warnings;
-use Digest::SHA1;
 
 use PVE::SafeSyslog;
 use PVE::Tools qw(extract_param);
@@ -12,9 +11,12 @@
 use PVE::RESTHandler;
 use PVE::QemuServer;
 use PVE::RPCEnvironment;
+use PVE::AccessControl;
 
 use base qw(PVE::RESTHandler);
 
+my $sslcert;
+
 __PACKAGE__->register_method ({
     name => 'vncproxy', 
     path => '',  
@@ -31,8 +33,11 @@
     returns => { 
     	additionalProperties => 0,
 	properties => {
+	    user => { type => 'string' },
+	    ticket => { type => 'string' },
+	    cert => { type => 'string' },
 	    port => { type => 'integer' },
-	    ticket => { type => 'string' },
+	    upid => { type => 'string' },
 	},
     },
     code => sub {
@@ -41,26 +46,32 @@
 	my $rpcenv = PVE::RPCEnvironment::get();
 
 	my $user = $rpcenv->get_user();
+	# fixme: creat eticket witch short timeout
+	my $ticket = PVE::AccessControl::assemble_ticket($user);
 
-	my $vmid = $param->{vmid};
+	my ($vmid) = $param->{vmid} =~ m/^(\d+)$/; #untaint
 	my $node = $param->{node};
 
-	# generate ticket, olny first 8 character used by vnc
-	my $ticket = Digest::SHA1::sha1_base64 ($user, rand(), time());
+	$sslcert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192)
+	    if !$sslcert;
 
 	my $port = PVE::QemuServer::next_vnc_port();
 
-	my $remip = $rpcenv->get_remote_node_ip($node);
+	# fixme:
+	#my $remip = $rpcenv->get_remote_node_ip($node);
+	my $remip = undef;
+
+	# fixme: select fastest chipher (none?)
 	my $remcmd = $remip ? ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes', $remip] : [];
 
-	my $timeout = 30; 
+	my $timeout = 1; 
 
 	my $realcmd = sub {
 	    my $upid = shift;
 
 	    syslog ('info', "starting vnc proxy $upid\n");
 
-	    my $qmcmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid , $ticket];
+	    my $qmcmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid];
 
 	    my $qmstr = join (' ', @$qmcmd);
 
@@ -68,20 +79,28 @@
 	    my @cmd = ('/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null");
 
 	    my $cmdstr = join (' ', @cmd);
-	    syslog ('info', "CMD: $cmdstr");
+	    syslog ('info', "CMD3: $cmdstr");
 
 	    if (system (@cmd) != 0) {
 		my $msg = "VM $vmid vnc proxy failed - $?";
 		syslog ('err', $msg);
-		exit (-1);
+		return;
 	    }
 
-	    exit (0);
+	    return;
 	};
 
-	my $upid = $rpcenv->fork_worker('vncproxy', "", $realcmd);
+	#my $upid = $rpcenv->fork_worker('vncproxy', "", $realcmd);
+	my $upid = "TESTID";
+	$port = 5910;
 
-	return { port => $port, ticket => $ticket};
+	return {
+	    user => $user,
+	    ticket => $ticket,
+	    port => $port, 
+	    upid => $upid, 
+	    cert => $sslcert, 
+	};
     }});
 
 1;

Modified: qemu-server/pve2/control.in
===================================================================
--- qemu-server/pve2/control.in	2011-01-27 13:28:52 UTC (rev 5451)
+++ qemu-server/pve2/control.in	2011-01-28 05:12:25 UTC (rev 5452)
@@ -3,7 +3,7 @@
 Section: admin
 Priority: optional
 Architecture: @@ARCH@@
-Depends: libc6 (>= 2.7-18), perl (>= 5.10.0-19), libterm-readline-gnu-perl, libio-multiplex-perl, libdigest-sha1-perl, pve-qemu-kvm (>= 0.11.1) | pve-qemu-kvm-2.6.18, netcat-traditional, libpve-storage-perl
+Depends: libc6 (>= 2.7-18), perl (>= 5.10.0-19), libterm-readline-gnu-perl, libdigest-sha1-perl, pve-qemu-kvm (>= 0.11.1) | pve-qemu-kvm-2.6.18, netcat-traditional, libpve-storage-perl
 Conflicts: netcat-openbsd
 Maintainer: Proxmox Support Team <support at proxmox.com>
 Description: Qemu Server Tools

Modified: qemu-server/pve2/qm
===================================================================
--- qemu-server/pve2/qm	2011-01-27 13:28:52 UTC (rev 5451)
+++ qemu-server/pve2/qm	2011-01-28 05:12:25 UTC (rev 5452)
@@ -32,7 +32,7 @@
 
 $rpcenv->set_user('root'); 
 
-my $hostname = $rpcenv->get_hostname();
+my $hostname = PVE::INotify::nodename();
 
 sub run_vnc_proxy {
     my ($vmid) = @_;




More information about the pve-devel mailing list