[pve-devel] r4863 - pve-manager/pve2/lib/PVE/API2
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu Jul 1 14:57:26 CEST 2010
Author: dietmar
Date: 2010-07-01 12:57:26 +0000 (Thu, 01 Jul 2010)
New Revision: 4863
Modified:
pve-manager/pve2/lib/PVE/API2/Cluster.pm
pve-manager/pve2/lib/PVE/API2/Storage.pm
pve-manager/pve2/lib/PVE/API2/VM.pm
Log:
try to generate better example data
Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm 2010-07-01 11:24:01 UTC (rev 4862)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm 2010-07-01 12:57:26 UTC (rev 4863)
@@ -39,7 +39,8 @@
my $ctime = int(time()/1);
$ctime = 0;
- my $count = 30 + ($ctime % 10);
+ #my $count = 30 + ($ctime % 10);
+ my $count = 4;
my $result = [];
for (my $i = 0; $i < $count; $i++) {
@@ -47,7 +48,7 @@
my $store = int($i / 2);
push @$result, {
name => "node-$i",
- storage => "store-$store",
+# storage => "store-$store",
cpu => 0.5,
maxcpu => 16,
uptime => 20*3600*24,
Modified: pve-manager/pve2/lib/PVE/API2/Storage.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Storage.pm 2010-07-01 11:24:01 UTC (rev 4862)
+++ pve-manager/pve2/lib/PVE/API2/Storage.pm 2010-07-01 12:57:26 UTC (rev 4863)
@@ -37,6 +37,9 @@
sub index {
my ($conn, $resp, $param) = @_;
+
+ my $nodes = [ 'node-0', 'node-1', 'node-2', 'node-3' ]; # fixme: use the real list
+
my $cfg = PVE::Config::read_file ("storagecfg");
my @sids = PVE::Storage::storage_ids ($cfg);
@@ -44,7 +47,17 @@
my $res = [];
foreach my $storeid (@sids) {
my $scfg = PVE::Storage::storage_config ($cfg, $storeid);
- push @$res, { name => $storeid, type => $scfg->{type}, shared => $scfg->{shared} || 0};
+ if ($scfg->{shared}) {
+ my $data = { name => $storeid, storage => $storeid, type => $scfg->{type}, shared => 1};
+ push @$res, $data;
+ } else {
+ # we create a entry for each node
+ foreach my $node (@$nodes) {
+ my $data = { name => "$storeid ($node)", storage => $storeid, node => $node,
+ type => $scfg->{type}, shared => 0};
+ push @$res, $data;
+ }
+ }
}
# $resp->{digest} = $cfg->{digest}; # fixme: how do we handle that
Modified: pve-manager/pve2/lib/PVE/API2/VM.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/VM.pm 2010-07-01 11:24:01 UTC (rev 4862)
+++ pve-manager/pve2/lib/PVE/API2/VM.pm 2010-07-01 12:57:26 UTC (rev 4863)
@@ -38,11 +38,13 @@
$ctime = 0;
my $result = [];
- for (my $i = 0; $i < 10; $i++) {
- for (my $j = 0; $j < 10; $j++) {
+
+ for (my $i = 0; $i < 4; $i++) {
+ for (my $j = 0; $j < 1; $j++) {
my $vmid = $i*100+$j;
my $cpu = (($ctime + $vmid) % 100)/100;
- push @$result, { id => $vmid, name => "VM $vmid", node => "node-$i" , storage => "store-$i", cpu => $cpu, 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 };
+ # storage => "local (node-$i)",
+ push @$result, { id => $vmid, name => "VM $vmid", node => "node-$i" , cpu => $cpu, 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 };
}
}
More information about the pve-devel
mailing list