[pve-devel] r6508 - pve-manager/pve2/lib/PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Aug 19 12:35:51 CEST 2011


Author: dietmar
Date: 2011-08-19 12:35:51 +0200 (Fri, 19 Aug 2011)
New Revision: 6508

Modified:
   pve-manager/pve2/lib/PVE/API2/Cluster.pm
Log:
try to generate numbers


Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-08-19 09:18:40 UTC (rev 6507)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-08-19 10:35:51 UTC (rev 6508)
@@ -135,6 +135,8 @@
 	my $vmlist = PVE::Cluster::get_vmlist() || {};
 	my $idlist = $vmlist->{ids} || {};
 
+
+	# we try to generate 'numbers' by using "$X + 0"
 	foreach my $vmid (keys %$idlist) {
 	    my $data = $idlist->{$vmid};
 
@@ -142,44 +144,27 @@
 
 	    my $entry = {
 		id => "$data->{type}/$vmid",
-		vmid => $vmid, 
+		vmid => $vmid + 0, 
 		node => $data->{node},
 		type => $data->{type},
 	    };
 
 	    if (my $d = $rrd->{"pve2-vm/$vmid"}) {
 
-		$entry->{uptime} = $d->[0];
+		$entry->{uptime} = $d->[0] + 0;
 		$entry->{name} = $d->[1];
 
-		$entry->{maxcpu} = $d->[3];
-		$entry->{cpu} = $d->[4];
-		$entry->{maxmem} = $d->[5];
-		$entry->{mem} = $d->[6];
-		$entry->{maxdisk} = $d->[7];
-		$entry->{disk} = $d->[8];
+		$entry->{maxcpu} = $d->[3] + 0;
+		$entry->{cpu} = $d->[4] + 0;
+		$entry->{maxmem} = $d->[5] + 0;
+		$entry->{mem} = $d->[6] + 0;
+		$entry->{maxdisk} = $d->[7] + 0;
+		$entry->{disk} = $d->[8] + 0;
 	    }
 
 	    push @$res, $entry;
 	}
 
-	if (0) { # fixme: remove test code
-	    my $ctime = time();
-
-	    for (my $i = 5000; $i < (5900 + ($ctime % 100)); $i++) {
-		my $nodeid = int(($i - 5000) / 100);
-		my $entry = {
-		    id => "qemu/$i",
-		    vmid => $i, 
-		    node => sprintf("tnode%05d", $nodeid),
-		    type => 'qemu',
-		    maxcpu => 1,
-		    cpu => ($ctime % 100)/100.0,
-		};
-		push @$res, $entry;
-	    }
-	}
-
 	foreach my $node (@$nodes) {
 	    my $entry = {
 		id => "node/$node",
@@ -188,13 +173,13 @@
 	    };
 	    if (my $d = $rrd->{"pve2-node/$node"}) {
 
-		$entry->{uptime} = $d->[0];
-		$entry->{maxcpu} = $d->[3];
-		$entry->{cpu} = $d->[4];
-		$entry->{maxmem} = $d->[6];
-		$entry->{mem} = $d->[7];
-		$entry->{maxdisk} = $d->[10];
-		$entry->{disk} = $d->[11];
+		$entry->{uptime} = $d->[0] + 0;
+		$entry->{maxcpu} = $d->[3] + 0;
+		$entry->{cpu} = $d->[4] + 0;
+		$entry->{maxmem} = $d->[6] + 0;
+		$entry->{mem} = $d->[7] + 0;
+		$entry->{maxdisk} = $d->[10] + 0;
+		$entry->{disk} = $d->[11] + 0;
 	    }
 
 	    push @$res, $entry;
@@ -217,8 +202,8 @@
 		}; 
 
 		if (my $d = $rrd->{"pve2-storage/$node/$storeid"}) {
-		    $entry->{maxdisk} = $d->[1];
-		    $entry->{disk} = $d->[2];
+		    $entry->{maxdisk} = $d->[1] + 0;
+		    $entry->{disk} = $d->[2] + 0;
 		}
 
 		push @$res, $entry;




More information about the pve-devel mailing list