From 6a4f61d8ecb61c7f7715500da2f500bda569ce1f Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 20 Sep 2010 17:37:25 +0200 Subject: [PATCH] show message about leases - leases tab first in nodes section --- planetlab/css/plc_style.css | 7 +- planetlab/slices/leases.js | 1 + planetlab/slices/slice.php | 203 +++++++++++++++++++----------------- 3 files changed, 117 insertions(+), 94 deletions(-) diff --git a/planetlab/css/plc_style.css b/planetlab/css/plc_style.css index cba8b5f..a361c1d 100644 --- a/planetlab/css/plc_style.css +++ b/planetlab/css/plc_style.css @@ -101,7 +101,6 @@ p.node_add { text-align: center; /* font-size: smaller; */ } - p.node_download { font-style: italic; padding: 20px 40px; @@ -179,3 +178,9 @@ div#toggle-container-add-node, div#toggle-container-add-interface { background-color: #e0d0ff; } +p.note_reservable { + font-style: italic; + padding: 20px 40px; + text-align: center; + font-size: larger; +} diff --git a/planetlab/slices/leases.js b/planetlab/slices/leases.js index d1d3d18..367022a 100644 --- a/planetlab/slices/leases.js +++ b/planetlab/slices/leases.js @@ -17,6 +17,7 @@ var radius= 6; var anim_delay=500; /* decorations / headers */ +/* note: looks like the 'font' attr is not effective... */ // vertical rules var attr_rules={'fill':"#888", 'stroke-dasharray':'- ', 'stroke-width':0.5}; diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php index ab5796d..a586212 100644 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@ -25,7 +25,6 @@ require_once 'toggle.php'; require_once 'form.php'; require_once 'raphael.php'; -plc_debug('legend',reservable_legend()); // keep css separate for now drupal_set_html_head(' @@ -439,6 +438,116 @@ $toggle=new PlekitToggle ('my-slice-nodes',$nodes_message, 'visible'=>get_arg('show_nodes',false))); $toggle->start(); +////////// show a notice to people having attached a reservable node +if (count($reservable_nodes) && $privileges) { + $mark=reservable_mark(); + print << +You have attached one or more reservable nodes to your slice. +Reservable nodes show up with the '$mark' mark. +Your slice will be available only during timeslots +where you have obtained leases. +You can manage your leases in the tab below. +
+Please note that as of August 2010 this feature is experimental. +Feedback is appreciated at devel@planet-lab.org +

+EOF; +} + +//////////////////// reservable nodes area +$count=count($reservable_nodes); +if ($count && $privileges) { + // having reservable nodes in white lists looks a bit off scope for now... + $toggle_nodes=new PlekitToggle('my-slice-nodes-reserve', + "Leases - " . count($reservable_nodes) . " reservable node(s)", + array('visible'=>get_arg('show_nodes_resa',false))); + $toggle_nodes->start(); + $grain=$api->GetLeaseGranularity(); + if ($profiling) plc_debug_prof('6 granul',$grain); + // where to start from, expressed as an offset in hours from now + $resa_offset=$_GET['resa_offset']; + if ( ! $resa_offset ) $resa_offset=0; + $rough_start=time()+$resa_offset*3600; + // xxx should be configurable + $resa_slots=$_GET['resa_slots']; + if ( ! $resa_slots ) $resa_slots = 36; + // for now, show the next 72 hours, or 72 grains, which ever is smaller + $duration=$resa_slots*$grain; + $steps=$duration/$grain; + $start=intval($rough_start/$grain)*$grain; + $end=$rough_start+$duration; + $lease_columns=array('lease_id','name','t_from','t_until','hostname','name'); + $leases=$api->GetLeases(array(']t_until'=>$rough_start,'[t_from'=>$end,'-SORT'=>'t_from'),$lease_columns); + if ($profiling) plc_debug_prof('7 leases',count($leases)); + // hash nodes -> leases + $host_hash=array(); + foreach ($leases as $lease) { + $hostname=$lease['hostname']; + if ( ! $host_hash[$hostname] ) { + $host_hash[$hostname]=array(); + } + // resync within the table + $lease['nfrom']=($lease['t_from']-$start)/$grain; + $lease['nuntil']=($lease['t_until']-$start)/$grain; + $host_hash[$hostname] []= $lease; + } + # leases_data is the name used by leases.js to locate this table + echo ""; + # pass (slice_id,slicename) as the [0,0] coordinate as thead>tr>td + echo ""; + # the timeslot headers read (timestamp,label) + $day_names=array('Su','M','Tu','W','Th','F','Sa'); + for ($i=0; $i<$steps; $i++) { + $timestamp=($start+$i*$grain); + $day=$day_names[intval(strftime("%w",$timestamp))]; + $label=$day . strftime(" %H:%M",$timestamp); + // expose in each header cell the full timestamp, and how to display it - use & as a separator*/ + echo ""; + } + echo ""; + // todo - sort on hostnames + function sort_hostname ($a,$b) { return ($a['hostname']<$b['hostname'])?-1:1;} + usort($reservable_nodes,sort_hostname); + foreach ($reservable_nodes as $node) { + echo ""; + $hostname=$node['hostname']; + $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 */ + /* while ($leases && ($leases[0]['name']==$lease['name']) && ($leases[0]['nfrom']==$lease['nuntil'])) { + $lease['nuntil']=$leases[0]['nuntil']; + array_shift($leases); + }*/ + $duration=$lease['nuntil']-$counter; + echo ""; + $counter=$lease['nuntil']; + } else { + echo ""; + $counter+=1; + } + } + echo ""; + } + echo "
" . $slice['slice_id'] . '&' . $slice['name'] . "" . implode("&",array($timestamp,$label)) . "
". $node['hostname'] . "" . $lease['lease_id'] . '&' . $lease['name'] . "
\n"; + + // the general layout for the scheduler + echo <<< EOF +
+ +
+ + +
+EOF; + + $toggle_nodes->end(); + } + //////////////////// nodes currently in $toggle_nodes=new PlekitToggle('my-slice-nodes-current', count_english($slice_nodes,"node") . " currently in $name", @@ -553,98 +662,6 @@ if ($privileges) { $toggle_nodes->end(); } -//////////////////// reservable nodes area -$count=count($reservable_nodes); -if ($count && $privileges) { - // having reservable nodes in white lists looks a bit off scope for now... - $toggle_nodes=new PlekitToggle('my-slice-nodes-reserve', - count_english($reservable_nodes,"reservable node") . " in slice", - array('visible'=>get_arg('show_nodes_resa',false))); - $toggle_nodes->start(); - $grain=$api->GetLeaseGranularity(); - if ($profiling) plc_debug_prof('6 granul',$grain); - // where to start from, expressed as an offset in hours from now - $resa_offset=$_GET['resa_offset']; - if ( ! $resa_offset ) $resa_offset=0; - $rough_start=time()+$resa_offset*3600; - // xxx should be configurable - $resa_slots=$_GET['resa_slots']; - if ( ! $resa_slots ) $resa_slots = 36; - // for now, show the next 72 hours, or 72 grains, which ever is smaller - $duration=$resa_slots*$grain; - $steps=$duration/$grain; - $start=intval($rough_start/$grain)*$grain; - $end=$rough_start+$duration; - $lease_columns=array('lease_id','name','t_from','t_until','hostname','name'); - $leases=$api->GetLeases(array(']t_until'=>$rough_start,'[t_from'=>$end,'-SORT'=>'t_from'),$lease_columns); - if ($profiling) plc_debug_prof('7 leases',count($leases)); - // hash nodes -> leases - $host_hash=array(); - foreach ($leases as $lease) { - $hostname=$lease['hostname']; - if ( ! $host_hash[$hostname] ) { - $host_hash[$hostname]=array(); - } - // resync within the table - $lease['nfrom']=($lease['t_from']-$start)/$grain; - $lease['nuntil']=($lease['t_until']-$start)/$grain; - $host_hash[$hostname] []= $lease; - } - # leases_data is the name used by leases.js to locate this table - echo ""; - # pass (slice_id,slicename) as the [0,0] coordinate as thead>tr>td - echo ""; - # the timeslot headers read (timestamp,label) - $day_names=array('Su','M','Tu','W','Th','F','Sa'); - for ($i=0; $i<$steps; $i++) { - $timestamp=($start+$i*$grain); - $day=$day_names[intval(strftime("%w",$timestamp))]; - $label=$day . strftime(" %H:%M",$timestamp); - // expose in each header cell the full timestamp, and how to display it - use & as a separator*/ - echo ""; - } - echo ""; - // todo - sort on hostnames - function sort_hostname ($a,$b) { return ($a['hostname']<$b['hostname'])?-1:1;} - usort($reservable_nodes,sort_hostname); - foreach ($reservable_nodes as $node) { - echo ""; - $hostname=$node['hostname']; - $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 */ - /* while ($leases && ($leases[0]['name']==$lease['name']) && ($leases[0]['nfrom']==$lease['nuntil'])) { - $lease['nuntil']=$leases[0]['nuntil']; - array_shift($leases); - }*/ - $duration=$lease['nuntil']-$counter; - echo ""; - $counter=$lease['nuntil']; - } else { - echo ""; - $counter+=1; - } - } - echo ""; - } - echo "
" . $slice['slice_id'] . '&' . $slice['name'] . "" . implode("&",array($timestamp,$label)) . "
". $node['hostname'] . "" . $lease['lease_id'] . '&' . $lease['name'] . "
\n"; - - // the general layout for the scheduler - echo <<< EOF -
- -
- - -
-EOF; - - $toggle_nodes->end(); - } $toggle->end(); // very wide values get abbreviated -- 2.47.0