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

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Sep 14 12:09:49 CEST 2010


Author: dietmar
Date: 2010-09-14 10:09:49 +0000 (Tue, 14 Sep 2010)
New Revision: 5147

Added:
   qemu-server/pve2/PVE/API2/Qemu.pm
Modified:
   qemu-server/pve2/ChangeLog
   qemu-server/pve2/PVE/API2/Makefile
   qemu-server/pve2/PVE/API2/Qemu/Config.pm
   qemu-server/pve2/PVE/API2/Qemu/Status.pm
Log:
	* PVE/API2/Qemu.pm: new index class




Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog	2010-09-14 10:07:26 UTC (rev 5146)
+++ qemu-server/pve2/ChangeLog	2010-09-14 10:09:49 UTC (rev 5147)
@@ -1,9 +1,13 @@
 2010-09-14  Proxmox Support Team  <support at proxmox.com>
 
-	* PVE/API2/Qemu/Status.pm: use better class name
+	* PVE/API2/Qemu.pm: new index class
 
-	* PVE/API2/Qemu/Config.pm: use better class name
+	* PVE/API2/Qemu/Status.pm: use better class name,
+	impl. list cluster nodes
 
+	* PVE/API2/Qemu/Config.pm: use better class name,
+	impl. list cluster nodes
+
 2010-09-13  Proxmox Support Team  <support at proxmox.com>
 
 	* nqm: implement vncticket

Modified: qemu-server/pve2/PVE/API2/Makefile
===================================================================
--- qemu-server/pve2/PVE/API2/Makefile	2010-09-14 10:07:26 UTC (rev 5146)
+++ qemu-server/pve2/PVE/API2/Makefile	2010-09-14 10:09:49 UTC (rev 5147)
@@ -1,4 +1,5 @@
 
 .PHONY: install
 install:
+	install -D -m 0644 Qemu.pm ${DESTDIR}${PERLDIR}/PVE/API2/Qemu.pm
 	make -C Qemu install

Modified: qemu-server/pve2/PVE/API2/Qemu/Config.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/Config.pm	2010-09-14 10:07:26 UTC (rev 5146)
+++ qemu-server/pve2/PVE/API2/Qemu/Config.pm	2010-09-14 10:09:49 UTC (rev 5147)
@@ -19,22 +19,46 @@
 ## GET    /vms/
 ## GET    /vms/index  status of all VMs (cluster wide)
 
-# GET    /vms/config/qm/{node}/  list of all Qemu VMs (per node)
-# POST   /vms/config/qm/{node}/  create VM
-# GET    /vms/config/qm/{node}/{vmid}  get VM config
-# PUT    /vms/config/qm/{node}/{vmid}  set VM config
-# DELETE /vms/config/qm/{node}/{vmid}  destroy VM
+# GET    /vms/qemu/config/{node}/  list of all Qemu VMs (per node)
+# POST   /vms/qemu/config/{node}/  create VM
+# GET    /vms/qemu/config/{node}/{vmid}  get VM config
+# PUT    /vms/qemu/config/{node}/{vmid}  set VM config
+# DELETE /vms/qemu/config/{node}/{vmid}  destroy VM
 
-# GET    /vms/status/qm  status of all Qemu VMs (cluster wide)
-# GET    /vms/status/qm/{node}/  status of all Qemu VMs (per node)
-# GET    /vms/status/qm/{node}/{vmid}  get VM status
-# PUT    /vms/status/qm/{node}/{vmid}  set VM status
+# 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
 
-# POST    /vms/vncproxy/qm  create vnc proxy
+# POST    /vms/qemu/vncproxy  create vnc proxy
 
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
+    name => 'index', 
+    path => '',  
+    method => 'GET',
+    description => "List cluster nodes.",
+    parameters => {
+    	additionalProperties => 0,
+	properties => {},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => { node => { type => 'string' } },
+	},
+	links => [ { rel => 'child', href => "{node}" } ],
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+	return $rpcenv->get_nodelist();
+    }});
+
+__PACKAGE__->register_method ({
     name => 'vmlist', 
     path => '{node}', 
     method => 'GET',

Modified: qemu-server/pve2/PVE/API2/Qemu/Status.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/Status.pm	2010-09-14 10:07:26 UTC (rev 5146)
+++ qemu-server/pve2/PVE/API2/Qemu/Status.pm	2010-09-14 10:09:49 UTC (rev 5147)
@@ -16,7 +16,30 @@
 
 use base qw(PVE::RESTHandler);
 
+__PACKAGE__->register_method ({
+    name => 'index', 
+    path => '',  
+    method => 'GET',
+    description => "List cluster nodes.",
+    parameters => {
+    	additionalProperties => 0,
+	properties => {},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => { node => { type => 'string' } },
+	},
+	links => [ { rel => 'child', href => "{node}" } ],
+    },
+    code => sub {
+	my ($param) = @_;
 
+	my $rpcenv = PVE::RPCEnvironment::get();
+	return $rpcenv->get_nodelist();
+    }});
+
 __PACKAGE__->register_method ({
     name => 'vmlist', 
     path => '{node}', 

Added: qemu-server/pve2/PVE/API2/Qemu.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu.pm	                        (rev 0)
+++ qemu-server/pve2/PVE/API2/Qemu.pm	2010-09-14 10:09:49 UTC (rev 5147)
@@ -0,0 +1,65 @@
+package PVE::API2::Qemu;
+
+use strict;
+use warnings;
+
+use PVE::RESTHandler;
+use PVE::API2::Qemu::Config;
+use PVE::API2::Qemu::Status;
+use PVE::API2::Qemu::VNC;
+
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Qemu::Config",  
+    path => 'config',
+});
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Qemu::Status",  
+    path => 'status',
+});
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Qemu::VNC",  
+    path => 'vncproxy',
+});
+
+__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;
+    }});
+
+1;




More information about the pve-devel mailing list