fixed: show no slices when user has no slices
[plewww.git] / planetlab / slices / leases-data.php
index 71d2433..a39a639 100644 (file)
@@ -23,7 +23,6 @@ $reservable_nodes=$api->GetNodes(array('|slice_ids'=>intval($slice_id), 'node_ty
 
 // where to start from, expressed as an offset in hours from now
 $rough_start=time()+$leases_offset*3600;
-// show the next 36 grains 
 $duration=$leases_slots*$leases_granularity;
 $steps=$duration/$leases_granularity;
 $start=intval($rough_start/$leases_granularity)*$leases_granularity;
@@ -62,13 +61,14 @@ usort($reservable_nodes,"sort_hostname");
 foreach ($reservable_nodes as $node) {
   echo "<tr><th scope='row'>". $node['hostname'] . "</th>";
   $hostname=$node['hostname'];
-  $leases=$host_hash[$hostname];
+  $leases=NULL;
+  if (array_key_exists($hostname,$host_hash) ) $leases=$host_hash[$hostname];
   $counter=0;
   while ($counter<$steps) {
     if ($leases && ($leases[0]['nfrom']<=$counter)) {
       $lease=array_shift($leases);
       /* nicer display, merge two consecutive leases for the same slice 
-        avoid doing that for now, as it might makes things confusing */
+        avoid doing that for now, as it might make things confusing */
       /* while ($leases && ($leases[0]['name']==$lease['name']) && ($leases[0]['nfrom']==$lease['nuntil'])) {
         $lease['nuntil']=$leases[0]['nuntil'];
         array_shift($leases);