X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fslices%2Fslice.php;h=af265b6e00100a2925f9d2a66e3eb5caccfc3fc8;hb=1ce86fd37ce8da9b475847a59394c0241a8dbbff;hp=4e23205797fd4600c956f2faf028c3a2879a2855;hpb=d7cc4e048eea83c6bb75bef519723a918a9c44d0;p=plewww.git diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php index 4e23205..af265b6 100644 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@ -1,7 +1,5 @@ +'); + +// -------------------- admins potentially need to get full list of users +//error_reporting(0); + +$profiling=false; +if ($_GET['profiling']) $profiling=true; + +if ($profiling) plc_debug_prof_start(); // -------------------- // recognized URL arguments $slice_id=intval($_GET['id']); if ( ! $slice_id ) { plc_error('Malformed URL - id not set'); return; } -function renew_area ($slice,$site) { +//////////////////// +// have to name columns b/c we need the non-native 'omf_control' column +$slice_columns=array('slice_id','name','peer_id','site_id','person_ids','node_ids','expires', + 'url','description','instantiation','omf_control'); +$slices= $api->GetSlices( array($slice_id), $slice_columns); + +if (empty($slices)) { + drupal_set_message ("Slice " . $slice_id . " not found"); + return; + } + +$slice=$slices[0]; + +if ($profiling) plc_debug_prof('1: slice',count($slices)); +// pull all node info to vars +$name= $slice['name']; +$expires = date( "d/m/Y", $slice['expires'] ); +$site_id= $slice['site_id']; + +$person_ids=$slice['person_ids']; + +// get peers +$peer_id= $slice['peer_id']; +$peers=new Peers ($api); +$local_peer = ! $peer_id; + +if ($profiling) plc_debug_prof('2: peers',count($peers)); + +// gets site info +$sites= $api->GetSites( array( $site_id ) ); +$site=$sites[0]; +$site_name= $site['name']; +$max_slices = $site['max_slices']; + +if ($profiling) plc_debug_prof('3: sites',count($sites)); +//////////////////////////////////////// building blocks for the renew area +// Constants +global $DAY; $DAY = 24*60*60; +global $WEEK; $WEEK = 7 * $DAY; +global $MAX_WEEKS; $MAX_WEEKS= 8; // weeks from today +global $GRACE_DAYS; $GRACE_DAYS=10; // days for renewal promoted on top +global $NOW; $NOW=mktime(); + +//////////////////////////////////////////////////////////// utility for the renew tab +// make the renew area on top and open if the expiration time is less than 10 days from now +function renew_needed ($slice) { + global $DAY, $NOW, $GRACE_DAYS; + $current_exp=$slice['expires']; + + $time_left = $current_exp - $NOW; + $visible = $time_left/$DAY <= $GRACE_DAYS; + return $visible; +} + +function renew_area ($slice,$site,$visible) { + global $DAY, $WEEK, $MAX_WEEKS, $GRACE_DAYS, $NOW; - // Constants - $week= 7 * 24 * 60 * 60; // seconds - $max_renewal_length= 8; // weeks from today - $max_expiration= mktime() + ($max_renewal_length * $week); // seconds since epoch - $max_expiration_date= gmstrftime("%A %b-%d-%y %T %Z", $max_expiration); - - // the renew area + $current_exp=$slice['expires']; + $current_text = gmstrftime("%A %b-%d-%y %T %Z", $current_exp); + $max_exp= $NOW + ($MAX_WEEKS * $WEEK); // seconds since epoch + $max_text = gmstrftime("%A %b-%d-%y %T %Z", $max_exp); + // xxx some extra code needed to enable this area only if the slice description is OK: // description and url must be non void - $toggle=new PlekitToggle('renew',"Renew this slice", - array("trigger-bubble"=>"Enter this zone if you wish to renew your slice", - 'start-visible'=>true)); + $toggle= + new PlekitToggle('renew',"Expires $current_text - Renew this slice", + array("bubble"=> + "Enter this zone if you wish to renew your slice", + 'visible'=>$visible)); $toggle->start(); // xxx message could take roles into account if ($site['max_slices']<=0) { $message= <<< EOF -
Slice creation and renewal have been temporarily disabled for your -site. This may have occurred because your site's nodes have been down +
Slice creation and renewal have been temporarily disabled for your
+ area under construction ';
-
- // // display form
- // echo "