[pve-devel] r5517 - in pve-manager/pve2: . lib/PVE lib/PVE/API2 www/manager

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Feb 11 13:56:32 CET 2011


Author: dietmar
Date: 2011-02-11 13:56:32 +0100 (Fri, 11 Feb 2011)
New Revision: 5517

Removed:
   pve-manager/pve2/lib/PVE/API2/VM.pm
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/README
   pve-manager/pve2/lib/PVE/API2.pm
   pve-manager/pve2/lib/PVE/API2/Cluster.pm
   pve-manager/pve2/lib/PVE/API2/Makefile.am
   pve-manager/pve2/lib/PVE/API2/Nodes.pm
   pve-manager/pve2/www/manager/PVECache.js
   pve-manager/pve2/www/manager/PVEConsole.js
Log:
fix API hierarchy


Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/ChangeLog	2011-02-11 12:56:32 UTC (rev 5517)
@@ -1,3 +1,7 @@
+2011-02-11  Proxmox Support Team  <support at proxmox.com>
+
+	* lib/PVE/API2/VM.pm: moved code to Cluster.pm
+
 2011-02-09  Proxmox Support Team  <support at proxmox.com>
 
 	* lib/PVE/API2/Services.pm: new class for services.

Modified: pve-manager/pve2/README
===================================================================
--- pve-manager/pve2/README	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/README	2011-02-11 12:56:32 UTC (rev 5517)
@@ -33,13 +33,14 @@
 POST /nodes/{node}/vncshell
 
 GET  /nodes/{node}/qemu/			list/status of all Qemu VMs (per node)
-POST /nodes/{node}/qemu/{vmid}			create VM
-GET  /nodes/{node}/qemu/{vmid}      		get VM config
-PUT  /nodes/{node}/qemu/{vmid}      		set VM config
+POST /nodes/{node}/qemu/			create VM
 DEL  /nodes/{node}/qemu/{vmid}      		detroy VM
 
+GET  /nodes/{node}/qemu/{vmid}/config  		get VM config
+PUT  /nodes/{node}/qemu/{vmid}/config  		set VM config
 GET  /nodes/{node}/qemu/{vmid}/status 		get VM status
 PUT  /nodes/{node}/qemu/{vmid}/status 	    	set VM status
+PUT  /nodes/{node}/qemu/{vmid}/unlink           ulink/delete disk images
 POST /nodes/{node}/qemu/{vmid}/vncproxy	    	create vnc proxy
 
 # scan for available storage devices

Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-02-11 12:56:32 UTC (rev 5517)
@@ -39,6 +39,7 @@
     
 	my $result = [
 	    { name => 'log' },
+	    { name => 'vms' },
 	    { name => 'storage' },
 	    ];
 
@@ -139,4 +140,54 @@
 	return $res;
     }});
 
+__PACKAGE__->register_method({
+    name => 'vms', 
+    path => 'vms', 
+    method => 'GET',
+    description => "Virtual machine index (cluster wide).",
+    parameters => {
+    	additionalProperties => 0,
+	properties => {},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => {
+		id => { type => 'integer' },
+	    },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $vmlist = PVE::Cluster::get_vmlist();
+	my $result = [];
+
+	return $result if !$vmlist;
+
+	my $idlist = $vmlist->{ids};
+	return $result if !$idlist;
+
+	foreach my $vmid (keys %$idlist) {
+	    my $data = $idlist->{$vmid};
+
+	    push @$result, { 
+		id => $vmid, 
+		name => "VM $vmid", 
+		node => $data->{node},
+		type => $data->{type},
+		cpu => 0, 
+		maxcpu => 1, 
+		mem => 1024*1024*1024*6, 
+		maxmem => 1024*1024*1024*24, 
+		disk => 1024*1024*1024*1024*6, 
+		maxdisk => 1024*1024*1024*1024*32, 
+		uptime => 2*3600 
+	    };
+	}
+   
+	return $result;
+    }});
+
 1;

Modified: pve-manager/pve2/lib/PVE/API2/Makefile.am
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Makefile.am	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/lib/PVE/API2/Makefile.am	2011-02-11 12:56:32 UTC (rev 5517)
@@ -5,8 +5,7 @@
 pvelib_DATA = 			\
 	Cluster.pm		\
 	Nodes.pm		\
-	Services.pm		\
-	VM.pm
+	Services.pm
 
 CLEANFILES = *~
 

Modified: pve-manager/pve2/lib/PVE/API2/Nodes.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Nodes.pm	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/lib/PVE/API2/Nodes.pm	2011-02-11 12:56:32 UTC (rev 5517)
@@ -14,11 +14,17 @@
 use PVE::API2::Services;
 use PVE::API2::Storage::Scan;
 use PVE::API2::Storage::Status;
+use PVE::API2::Qemu;
 use JSON;
 
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
+    subclass => "PVE::API2::Qemu",  
+    path => 'qemu',
+});
+
+__PACKAGE__->register_method ({
     subclass => "PVE::API2::Services",  
     path => 'services',
 });
@@ -64,6 +70,7 @@
 	    { name => 'scan' },
 	    { name => 'storage' },
 	    { name => 'upload' },
+	    { name => 'qemu' },
 	    ];
 
 	return $result;

Deleted: pve-manager/pve2/lib/PVE/API2/VM.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/VM.pm	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/lib/PVE/API2/VM.pm	2011-02-11 12:56:32 UTC (rev 5517)
@@ -1,107 +0,0 @@
-package PVE::API2::VM;
-
-use strict;
-use warnings;
-
-use PVE::SafeSyslog;
-use PVE::RESTHandler;
-use PVE::Cluster;
-
-use Data::Dumper; # fixme: remove
-
-use base qw(PVE::RESTHandler);
-
-use PVE::API2::Qemu;
-
-__PACKAGE__->register_method ({
-    subclass => "PVE::API2::Qemu",  
-    path => 'qemu',
-});
-
-__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 = [ { subdir => 'index' } ];
-
-	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;
-    }});
-
-__PACKAGE__->register_method({
-    name => 'vmlist', 
-    path => 'index', 
-    method => 'GET',
-    description => "Virtual machine index.",
-    parameters => {
-    	additionalProperties => 0,
-	properties => {},
-    },
-    returns => {
-	type => 'array',
-	items => {
-	    type => "object",
-	    properties => {},
-	},
-#	links => [ { rel => 'child', href => "{id}" } ],
-    },
-    code => sub {
-	my ($param) = @_;
-
-	my $vmlist = PVE::Cluster::get_vmlist();
-	my $result = [];
-
-	return $result if !$vmlist;
-
-	my $idlist = $vmlist->{ids};
-	return $result if !$idlist;
-
-	foreach my $vmid (keys %$idlist) {
-	    my $data = $idlist->{$vmid};
-
-	    push @$result, { 
-		id => $vmid, 
-		name => "VM $vmid", 
-		node => $data->{node},
-		type => $data->{type},
-		cpu => 0, 
-		maxcpu => 1, 
-		mem => 1024*1024*1024*6, 
-		maxmem => 1024*1024*1024*24, 
-		disk => 1024*1024*1024*1024*6, 
-		maxdisk => 1024*1024*1024*1024*32, 
-		uptime => 2*3600 
-	    };
-	}
-   
-	return $result;
-    }});
-
-1;

Modified: pve-manager/pve2/lib/PVE/API2.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2.pm	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/lib/PVE/API2.pm	2011-02-11 12:56:32 UTC (rev 5517)
@@ -9,18 +9,12 @@
 use base qw(PVE::RESTHandler);
 
 # preload classes
-use PVE::API2::VM;
 use PVE::API2::Cluster;
 use PVE::API2::Nodes;
 use PVE::API2::AccessControl;
 use PVE::API2::Storage::Config;
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::VM",  
-    path => 'vms',
-});
-
-__PACKAGE__->register_method ({
     subclass => "PVE::API2::Cluster",  
     path => 'cluster',
 });

Modified: pve-manager/pve2/www/manager/PVECache.js
===================================================================
--- pve-manager/pve2/www/manager/PVECache.js	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/www/manager/PVECache.js	2011-02-11 12:56:32 UTC (rev 5517)
@@ -37,7 +37,7 @@
 		itype: 'vm',
 		idProperty: 'id',
 		autoDestroy: false,
-		url: '/api2/json/vms/index',
+		url: '/api2/json/cluster/vms',
 		fields: fields
 	    });
 

Modified: pve-manager/pve2/www/manager/PVEConsole.js
===================================================================
--- pve-manager/pve2/www/manager/PVEConsole.js	2011-02-11 12:54:42 UTC (rev 5516)
+++ pve-manager/pve2/www/manager/PVEConsole.js	2011-02-11 12:56:32 UTC (rev 5517)
@@ -175,7 +175,7 @@
 
 	var vm_command = function(cmd, reload_applet) {
 	    Ext.Ajax.request({
-		url: "/api2/json/vms/qemu/status/" + node + "/" + vmid,
+		url: "/api2/json/nodes/" + node + "/qemu/" + vmid + "/status",
 		params: { command: cmd },
 		method: 'PUT',
 		failure: function(response, opts) {
@@ -261,8 +261,8 @@
 
 	Ext.apply(self, {
 	    tbar: tbar,
-	    url: "/api2/json/vms/qemu/vncproxy",
-	    params: { node: node, vmid: vmid }
+	    url: "/api2/json/nodes/" + node + "/qemu/" + vmid + "/vncproxy",
+	    method: 'POST'
 	});
 
 	PVE.Console.superclass.initComponent.call(self);



More information about the pve-devel mailing list