[pve-devel] r5958 - in pve-manager/pve2: bin www/new www/new/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Tue May 10 13:02:46 CEST 2011


Author: dietmar
Date: 2011-05-10 13:02:45 +0200 (Tue, 10 May 2011)
New Revision: 5958

Modified:
   pve-manager/pve2/bin/pvestatd
   pve-manager/pve2/www/new/PVEUtils.js
   pve-manager/pve2/www/new/qemu/Config.js
Log:
impl. VM commands


Modified: pve-manager/pve2/bin/pvestatd
===================================================================
--- pve-manager/pve2/bin/pvestatd	2011-05-10 10:53:28 UTC (rev 5957)
+++ pve-manager/pve2/bin/pvestatd	2011-05-10 11:02:45 UTC (rev 5958)
@@ -177,13 +177,18 @@
 
     foreach my $vmid (keys %$vmstatus) {
 	my $d = $vmstatus->{$vmid};
-	next if !$d->{pid}; # not running
-
-	my $data = "$d->{uptime}:$d->{name}:$ctime:$d->{cpus}:$d->{cpu}:" .
-	    "$d->{maxmem}:$d->{mem}:" .
-	    "$d->{maxdisk}:$d->{disk}:" .
-	    "$d->{netin}:$d->{netout}";
-
+	my $data;
+	if ($d->{pid}) { # running
+	    $data = "$d->{uptime}:$d->{name}:$ctime:$d->{cpus}:$d->{cpu}:" .
+		"$d->{maxmem}:$d->{mem}:" .
+		"$d->{maxdisk}:$d->{disk}:" .
+		"$d->{netin}:$d->{netout}";
+	} else {
+	    $data = "0:$d->{name}:$ctime:$d->{cpus}::" .
+		"$d->{maxmem}::" .
+		"$d->{maxdisk}:$d->{disk}:" .
+		":";
+	}
 	PVE::Cluster::broadcast_rrd("pve2-vm/$vmid", $data);
     }
 }

Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js	2011-05-10 10:53:28 UTC (rev 5957)
+++ pve-manager/pve2/www/new/PVEUtils.js	2011-05-10 11:02:45 UTC (rev 5958)
@@ -274,6 +274,9 @@
 	var cpu = value;
 	var maxcpu = record.data.maxcpu;
 
+	if (!record.data.uptime)
+	    return '';
+
 	if (!(Ext.isNumeric(value) && Ext.isNumeric(maxcpu) && (maxcpu >= 1)))
 	    return ''
 
@@ -298,6 +301,9 @@
 	var mem = value;
 	var maxmem = record.data.maxmem;
 	
+	if (!record.data.uptime)
+	    return '';
+
 	if (!(Ext.isNumeric(mem) && maxmem))
 	    return ''
 

Modified: pve-manager/pve2/www/new/qemu/Config.js
===================================================================
--- pve-manager/pve2/www/new/qemu/Config.js	2011-05-10 10:53:28 UTC (rev 5957)
+++ pve-manager/pve2/www/new/qemu/Config.js	2011-05-10 11:02:45 UTC (rev 5958)
@@ -13,6 +13,22 @@
 	if (!vmid) 
 	    throw "no VM ID specified";
 
+	var vm_command = function(cmd) {
+
+	    me.setLoading(true, true);
+	    PVE.Utils.API2Request({
+		params: { command: cmd },
+		url: '/nodes/' + nodename + '/qemu/' + vmid + "/status",
+		method: 'PUT',
+		callback: function() {
+		    me.setLoading(false);
+		},
+		failure: function(response, opts) {
+		    Ext.Msg.alert('Error', response.htmlStatus);
+		}
+	    });
+	};
+
 	var vmname = me.pveSelNode.data.name;
 	var descr = vmname ? "'" + vmname + "' " : '';
 	Ext.apply(me, {
@@ -24,11 +40,31 @@
 		    title: 'Summary',
 		    itemId: 'summary',
 		    tbar: [ 
-			{ text: 'Start'}, 
-			{ text: 'Stop'}, 
-			{ text: 'Reset'}, 
-			{ text: 'Shutdown'}, 
 			{ 
+			    text: 'Start',
+			    handler: function() {
+				vm_command('start');
+			    }			    
+			}, 
+			{ 
+			    text: 'Stop',
+			    handler: function() {
+				vm_command('stop');
+			    }			    
+			}, 
+			{ 
+			    text: 'Reset',
+			    handler: function() {
+				vm_command('reset');
+			    }			    
+			}, 
+			{ 
+			    text: 'Shutdown',
+			    handler: function() {
+				vm_command('shutdown');
+			    }			    
+			}, 
+			{ 
 			    text: 'Remove',
 			    handler: function() {
 				var msg = 'Are you sure you want to remove VM ' + 
@@ -37,9 +73,13 @@
 				    if (btn !== 'yes')
 					return;
 
+				    me.setLoading(true, true);
 				    PVE.Utils.API2Request({
 					url: '/nodes/' + nodename + '/qemu/' + vmid,
 					method: 'DELETE',
+					callback: function() {
+					    me.setLoading(false);
+					},
 					failure: function(response, opts) {
 					    Ext.Msg.alert('Error', response.htmlStatus);
 					}




More information about the pve-devel mailing list