6 require_once 'plc_login.php';
8 // Get session and API handles
9 require_once 'plc_session.php';
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
17 require_once 'plc_functions.php';
18 require_once 'plc_peers.php';
19 require_once 'plc_objects.php';
20 require_once 'plc_visibletags.php';
21 require_once 'linetabs.php';
22 require_once 'table.php';
23 require_once 'details.php';
24 require_once 'toggle.php';
25 require_once 'form.php';
26 require_once 'raphael.php';
28 // keep css separate for now
29 drupal_set_html_head('
30 <link href="/planetlab/css/my_slice.css" rel="stylesheet" type="text/css" />
31 <script src="/planetlab/slices/leases.js" type="text/javascript" charset="utf-8"></script>
34 // -------------------- admins potentially need to get full list of users
35 ini_set('memory_limit','32M');
38 if ($_GET['profiling']) $profiling=true;
40 if ($profiling) plc_debug_prof_start();
42 // --------------------
43 // recognized URL arguments
44 $slice_id=intval($_GET['id']);
45 if ( ! $slice_id ) { plc_error('Malformed URL - id not set'); return; }
48 // have to name columns b/c we need the non-native 'omf_control' column
49 $slice_columns=array('slice_id','name','peer_id','site_id','person_ids','node_ids','expires',
50 'url','description','instantiation','omf_control');
51 $slices= $api->GetSlices( array($slice_id), $slice_columns);
54 drupal_set_message ("Slice " . $slice_id . " not found");
60 if ($profiling) plc_debug_prof('2: slice',count($slices));
61 // pull all node info to vars
62 $name= $slice['name'];
63 $expires = date( "d/m/Y", $slice['expires'] );
64 $site_id= $slice['site_id'];
66 $person_ids=$slice['person_ids'];
69 $peer_id= $slice['peer_id'];
70 $peers=new Peers ($api);
71 $local_peer = ! $peer_id;
73 if ($profiling) plc_debug_prof('3: peers',count($peers));
76 $sites= $api->GetSites( array( $site_id ) );
78 $site_name= $site['name'];
80 if ($profiling) plc_debug_prof('4: sites',count($sites));
81 //////////////////////////////////////// building blocks for the renew area
83 global $DAY; $DAY = 24*60*60;
84 global $WEEK; $WEEK = 7 * $DAY;
85 global $MAX_WEEKS; $MAX_WEEKS= 8; // weeks from today
86 global $GRACE_DAYS; $GRACE_DAYS=10; // days for renewal promoted on top
87 global $NOW; $NOW=mktime();
89 ////////////////////////////////////////////////////////////
90 // make the renew area on top and open if the expiration time is less than 10 days from now
91 function renew_needed ($slice) {
92 global $DAY, $NOW, $GRACE_DAYS;
93 $current_exp=$slice['expires'];
95 $time_left = $current_exp - $NOW;
96 $visible = $time_left/$DAY <= $GRACE_DAYS;
100 function renew_area ($slice,$site,$visible) {
101 global $DAY, $WEEK, $MAX_WEEKS, $GRACE_DAYS, $NOW;
103 $current_exp=$slice['expires'];
104 $current_text = gmstrftime("%A %b-%d-%y %T %Z", $current_exp);
105 $max_exp= $NOW + ($MAX_WEEKS * $WEEK); // seconds since epoch
106 $max_text = gmstrftime("%A %b-%d-%y %T %Z", $max_exp);
108 // xxx some extra code needed to enable this area only if the slice description is OK:
109 // description and url must be non void
111 new PlekitToggle('renew',"Expires $current_text - Renew this slice",
113 "Enter this zone if you wish to renew your slice",
114 'visible'=>$visible));
117 // xxx message could take roles into account
118 if ($site['max_slices']<=0) {
120 <p class='my-slice-renewal'>Slice creation and renewal have been temporarily disabled for your
121 <site. This may have occurred because your site's nodes have been down
122 or unreachable for several weeks, and multiple attempts to contact
123 your site's PI(s) and Technical Contact(s) have all failed. If so,
124 contact your site's PI(s) and Technical Contact(s) and ask them to
125 bring up your site's nodes. Please visit your <a
126 href='/db/sites/index.php?id=$site_id'>site details</a> page to find
127 out more about your site's nodes, and how to contact your site's PI(s)
128 and Technical Contact(s).</p>
133 // xxx this is a rough cut and paste from the former UI
134 // showing a datepicker view could be considered as well with some extra work
135 // calculate possible extension lengths
136 $selectors = array();
137 foreach ( array ( 1 => "One more week",
138 2 => "Two more weeks",
139 3 => "Three more weeks",
140 4 => "One more month" ) as $weeks => $text ) {
141 $candidate_exp = $current_exp + $weeks*$WEEK;
142 if ( $candidate_exp < $max_exp) {
143 $selectors []= array('display'=>"$text (" . gmstrftime("%A %b-%d-%y %T %Z", $candidate_exp) . ")",
144 'value'=>$candidate_exp);
145 $max_renewal_weeks=$weeks;
146 $max_renewal_date= gmstrftime("%A %b-%d-%y %T %Z", $candidate_exp);
150 if ( empty( $selectors ) ) {
152 <div class='my-slice-renewal'>
153 Slices annot be renewed more than $MAX_WEEKS weeks from now, i.e. not beyond $max_text.
154 For this reason, the current slice cannot be renewed any further into the future, try again closer to expiration date.
159 <div class='my-slice-renewal'>
160 <p>You <span class='bold'>must</span> provide a short description,
161 as well as a link to a project website, before renewing it.
163 <br/> Please make sure to provide reasonable details on <span class='bold'>
164 the kind of traffic</span>, and <span class='bold'>copyrights</span> if relevant.
165 Do <span class='bold'>not</span> provide bogus information; if a complaint is lodged against
166 your slice and your PlanetLab Operations Center is unable to determine what the normal behavior
167 of your slice is, your slice may be deleted to resolve the complaint.</p>
169 <p><span class='bold'>NOTE:</span>
170 Slices cannot be renewed beyond another $max_renewal_weeks week(s) ($max_renewal_date).
175 $form = new PlekitForm (l_actions(),
176 array('action'=>'renew-slice',
177 'slice_id'=>$slice['slice_id']));
179 print $form->label_html('expires','Duration');
180 print $form->select_html('expires',$selectors,array('label'=>'Pick one'));
181 print $form->submit_html('renew-button','Renew');
189 ////////////////////////////////////////////////////////////
191 $am_in_slice = in_array(plc_my_person_id(),$person_ids);
194 drupal_set_title("My slice " . $name);
196 drupal_set_title("Slice " . $name);
199 $privileges = ( $local_peer && (plc_is_admin() || plc_is_pi() || $am_in_slice));
200 $tags_privileges = $privileges || plc_is_admin();
203 $tabs [] = tab_nodes_slice($slice_id);
204 $tabs [] = tab_site($site);
206 // are these the right privileges for deletion ?
208 $tabs ['Delete']= array('url'=>l_actions(),
210 'values'=>array('action'=>'delete-slice','slice_id'=>$slice_id),
211 'bubble'=>"Delete slice $name",
212 'confirm'=>"Are you sure to delete slice $name");
214 $tabs["Events"]=array_merge(tablook_event(),
215 array('url'=>l_event("Slice","slice",$slice_id),
216 'bubble'=>"Events for slice $name"));
217 $tabs["Comon"]=array_merge(tablook_comon(),
218 array('url'=>l_comon("slice_id",$slice_id),
219 'bubble'=>"Comon page about slice $name"));
222 plekit_linetabs($tabs);
224 ////////////////////////////////////////
225 $peers->block_start($peer_id);
227 //////////////////////////////////////// renewal area
228 // (1) close to expiration : show on top and open
231 $renew_visible = renew_needed ($slice);
232 if ($renew_visible) renew_area ($slice,$site,true);
236 //////////////////// details
237 // default for opening the details section or not ?
239 $default_show_details = true;
241 $default_show_details = ! $renew_visible;
245 new PlekitToggle ('my-slice-details',"Details",
247 'Display and modify details for that slice',
248 'visible'=>get_arg('show_details',$default_show_details)));
251 $details=new PlekitDetails($privileges);
252 $details->form_start(l_actions(),array('action'=>'update-slice',
253 'slice_id'=>$slice_id,
258 $details->th_td("Peer",$peers->peer_link($peer_id));
263 $details->th_td('Name',$slice['name']);
264 $details->th_td('Description',$slice['description'],'description',
265 array('input_type'=>'textarea',
266 'width'=>50,'height'=>5));
267 $details->th_td('URL',$slice['url'],'url',array('width'=>50));
268 $details->tr_submit("submit","Update Slice");
269 $details->th_td('Expires',$expires);
270 $details->th_td('Instantiation',$slice['instantiation']);
271 $details->th_td("OMF-friendly", ($slice['omf_control'] ? 'Yes' : 'No') . " [to change: see 'omf_control' in the tags section below]");
272 $details->th_td('Site',l_site_obj($site));
273 // xxx show the PIs here
274 //$details->th_td('PIs',...);
277 $details->form_end();
280 //////////////////// persons
281 $person_columns = array('email','person_id','first_name','last_name','roles');
282 // get persons in slice
283 if (!empty($person_ids))
284 $persons=$api->GetPersons(array('person_id'=>$slice['person_ids']),$person_columns);
285 // just propose to add everyone else
286 // xxx this is maybe too much for admins as it slows stuff down
287 // as regular persons can see only a fraction of the db anyway
289 $api->GetPersons(array('~person_id'=>$slice['person_ids'],
293 $count=count($persons);
295 if ($profiling) plc_debug_prof('4: persons',count($persons));
297 new PlekitToggle ('my-slice-persons',"$count Users",
299 'Manage accounts attached to this slice',
300 'visible'=>get_arg('show_persons',false)));
303 ////////// people currently in
305 // hide if both current+add are included
306 // so user can chose which section is of interest
308 $toggle_persons = new PlekitToggle ('my-slice-persons-current',
309 "$count people currently in $name",
310 array('visible'=>get_arg('show_persons_current',!$privileges)));
311 $toggle_persons->start();
314 $headers['email']='string';
315 $headers['first']='string';
316 $headers['last']='string';
317 $headers['R']='string';
318 if ($privileges) $headers[plc_delete_icon()]="none";
319 $table=new PlekitTable('persons',$headers,'0',
320 array('notes_area'=>false));
321 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
324 if ($persons) foreach ($persons as $person) {
326 $table->cell(l_person_obj($person));
327 $table->cell($person['first_name']);
328 $table->cell($person['last_name']);
329 $table->cell(plc_vertical_table ($person['roles']));
330 if ($privileges) $table->cell ($form->checkbox_html('person_ids[]',$person['person_id']));
337 $table->tfoot_start();
340 $table->cell($form->submit_html ("remove-persons-from-slice","Remove selected"),
341 array('hfill'=>true,'align'=>'right'));
345 $toggle_persons->end();
347 ////////// people to add
349 $count=count($potential_persons);
350 $toggle_persons = new PlekitToggle ('my-slice-persons-add',
351 "$count people may be added to $name",
352 array('visible'=>get_arg('show_persons_add',false)));
353 $toggle_persons->start();
354 if ( ! $potential_persons ) {
356 echo "<p class='not-relevant'>No person to add</p>";
359 $headers['email']='string';
360 $headers['first']='string';
361 $headers['last']='string';
362 $headers['R']='string';
363 $headers['+']="none";
364 $options = array('notes_area'=>false,
367 // show search for admins only as other people won't get that many names to add
368 if ( ! plc_is_admin() ) $options['search_area']=false;
370 $table=new PlekitTable('add_persons',$headers,'0',$options);
371 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
374 if ($potential_persons) foreach ($potential_persons as $person) {
376 $table->cell(l_person_obj($person));
377 $table->cell($person['first_name']);
378 $table->cell($person['last_name']);
379 $table->cell(plc_vertical_table ($person['roles']));
380 $table->cell ($form->checkbox_html('person_ids[]',$person['person_id']));
384 $table->tfoot_start();
386 $table->cell($form->submit_html ("add-persons-in-slice","Add selected"),
387 array('hfill'=>true,'align'=>'right'));
392 $toggle_persons->end();
396 //////////////////////////////////////////////////////////// Nodes
397 // the nodes details to display here
398 // (1) we search for the tag types for which 'category' matches 'node*/ui*'
399 // all these tags will then be tentatively displayed in this area
400 // (2) further information can also be optionally specified in the category:
401 // (.) we split the category with '/' and search for assignments of the form var=value
402 // (.) header can be set to supersede the column header (default is tagname)
403 // (.) rank can be used for ordering the columns (default is tagname)
404 // (.) type is passed to the javascript table, for sorting (default is 'string')
406 // minimal list as a start
407 $node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist',
408 'run_level','boot_state','last_contact','node_type');
409 // create a VisibleTags object : basically the list of tag columns to show
410 $visibletags = new VisibleTags ($api, 'node');
411 $visiblecolumns = $visibletags->column_names();
412 $node_columns=array_merge($node_fixed_columns,$visiblecolumns);
414 // optimizing calls to GetNodes
415 $all_nodes=$api->GetNodes(NULL,$node_columns);
416 //$slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),$node_columns);
417 //$potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),$node_columns);
418 $slice_nodes=array();
419 $potential_nodes=array();
420 $reservable_nodes=array();
421 foreach ($all_nodes as $node) {
422 if (in_array($node['node_id'],$slice['node_ids'])) {
423 $slice_nodes[]=$node;
424 if ($node['node_type']=='reservable') $reservable_nodes[]=$node;
426 $potential_nodes[]=$node;
429 if ($profiling) plc_debug_prof('5: nodes',count($slice_nodes));
431 // outline the number of reservable nodes
432 $nodes_message=count_english($slice_nodes,"node");
433 if (count($reservable_nodes)) $nodes_message .= " (" . count($reservable_nodes) . " reservable)";
434 $toggle=new PlekitToggle ('my-slice-nodes',$nodes_message,
436 'Manage nodes attached to this slice',
437 'visible'=>get_arg('show_nodes',false)));
440 ////////// show a notice to people having attached a reservable node
441 if (count($reservable_nodes) && $privileges) {
442 $mark=reservable_mark();
444 <p class='note_reservable'>
445 You have attached one or more <span class='bold'>reservable nodes</span> to your slice.
446 Reservable nodes show up with the '$mark' mark.
447 Your slice will be available <span class='bold'>only during timeslots
448 where you have obtained leases</span>.
449 You can manage your leases in the tab below.
451 Please note that as of August 2010 this feature is experimental.
452 Feedback is appreciated at <a href="mailto:devel@planet-lab.org">devel@planet-lab.org</a>
457 //////////////////// reservable nodes area
458 $count=count($reservable_nodes);
459 if ($count && $privileges) {
460 // having reservable nodes in white lists looks a bit off scope for now...
461 $toggle_nodes=new PlekitToggle('my-slice-nodes-reserve',
462 "Leases - " . count($reservable_nodes) . " reservable node(s)",
463 array('visible'=>get_arg('show_nodes_resa',false)));
464 $toggle_nodes->start();
465 $grain=$api->GetLeaseGranularity();
466 if ($profiling) plc_debug_prof('6 granul',$grain);
467 // where to start from, expressed as an offset in hours from now
468 $resa_offset=$_GET['resa_offset'];
469 if ( ! $resa_offset ) $resa_offset=0;
470 $rough_start=time()+$resa_offset*3600;
471 // xxx should be configurable
472 $resa_slots=$_GET['resa_slots'];
473 if ( ! $resa_slots ) $resa_slots = 36;
474 // for now, show the next 72 hours, or 72 grains, which ever is smaller
475 $duration=$resa_slots*$grain;
476 $steps=$duration/$grain;
477 $start=intval($rough_start/$grain)*$grain;
478 $end=$rough_start+$duration;
479 $lease_columns=array('lease_id','name','t_from','t_until','hostname','name');
480 $leases=$api->GetLeases(array(']t_until'=>$rough_start,'[t_from'=>$end,'-SORT'=>'t_from'),$lease_columns);
481 if ($profiling) plc_debug_prof('7 leases',count($leases));
482 // hash nodes -> leases
484 foreach ($leases as $lease) {
485 $hostname=$lease['hostname'];
486 if ( ! $host_hash[$hostname] ) {
487 $host_hash[$hostname]=array();
489 // resync within the table
490 $lease['nfrom']=($lease['t_from']-$start)/$grain;
491 $lease['nuntil']=($lease['t_until']-$start)/$grain;
492 $host_hash[$hostname] []= $lease;
494 # leases_data is the name used by leases.js to locate this table
495 echo "<table id='leases_data'>";
496 # pass (slice_id,slicename) as the [0,0] coordinate as thead>tr>td
497 echo "<thead><tr><td>" . $slice['slice_id'] . '&' . $slice['name'] . "</td>";
498 # the timeslot headers read (timestamp,label)
499 $day_names=array('Su','M','Tu','W','Th','F','Sa');
500 for ($i=0; $i<$steps; $i++) {
501 $timestamp=($start+$i*$grain);
502 $day=$day_names[intval(strftime("%w",$timestamp))];
503 $label=$day . strftime(" %H:%M",$timestamp);
504 // expose in each header cell the full timestamp, and how to display it - use & as a separator*/
505 echo "<th>" . implode("&",array($timestamp,$label)) . "</th>";
507 echo "</tr></thead><tbody>";
508 // todo - sort on hostnames
509 function sort_hostname ($a,$b) { return ($a['hostname']<$b['hostname'])?-1:1;}
510 usort($reservable_nodes,sort_hostname);
511 foreach ($reservable_nodes as $node) {
512 echo "<tr><th scope='row'>". $node['hostname'] . "</th>";
513 $hostname=$node['hostname'];
514 $leases=$host_hash[$hostname];
516 while ($counter<$steps) {
517 if ($leases && ($leases[0]['nfrom']<=$counter)) {
518 $lease=array_shift($leases);
519 /* nicer display, merge two consecutive leases for the same slice
520 avoid doing that for now, as it might makes things confusing */
521 /* while ($leases && ($leases[0]['name']==$lease['name']) && ($leases[0]['nfrom']==$lease['nuntil'])) {
522 $lease['nuntil']=$leases[0]['nuntil'];
523 array_shift($leases);
525 $duration=$lease['nuntil']-$counter;
526 echo "<td colspan='$duration'>" . $lease['lease_id'] . '&' . $lease['name'] . "</td>";
527 $counter=$lease['nuntil'];
535 echo "</tbody></table>\n";
537 // the general layout for the scheduler
539 <div id='leases_area'></div>
541 <div id='leases_buttons'>
542 <button id='leases_clear' type='submit'>Clear</button>
543 <button id='leases_submit' type='submit'>Submit</button>
547 $toggle_nodes->end();
550 //////////////////// nodes currently in
551 $toggle_nodes=new PlekitToggle('my-slice-nodes-current',
552 count_english($slice_nodes,"node") . " currently in $name",
553 array('visible'=>get_arg('show_nodes_current',!$privileges)));
554 $toggle_nodes->start();
558 $headers['peer']='string';
559 $headers['hostname']='string';
560 $short="-S-"; $long=Node::status_footnote(); $type='string';
561 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
562 $short=reservable_mark(); $long=reservable_legend(); $type='string';
563 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
564 // the extra tags, configured for the UI
565 $headers=array_merge($headers,$visibletags->headers());
566 $notes=array_merge($notes,$visibletags->notes());
568 if ($privileges) $headers[plc_delete_icon()]="none";
570 $table_options = array('notes'=>$notes,
573 $table=new PlekitTable('nodes',$headers,'1',$table_options);
575 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
578 if ($slice_nodes) foreach ($slice_nodes as $node) {
580 $peers->cell($table,$node['peer_id']);
581 $table->cell(l_node_obj($node));
582 $run_level=$node['run_level'];
583 list($label,$class) = Node::status_label_class_($node);
584 $table->cell ($label,array('class'=>$class));
585 $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
586 foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
588 if ($privileges) $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));
595 $table->tfoot_start();
598 $table->cell($form->submit_html ("remove-nodes-from-slice","Remove selected"),
599 array('hfill'=>true,'align'=>'right'));
603 $toggle_nodes->end();
605 //////////////////// nodes to add
607 $new_potential_nodes = array();
608 if ($potential_nodes) foreach ($potential_nodes as $node) {
609 $emptywl=empty($node['slice_ids_whitelist']);
610 $inwl = (!emptywl) and in_array($slice['slice_id'],$node['slice_ids_whitelist']);
611 if ($emptywl or $inwl)
612 $new_potential_nodes[]=$node;
614 $potential_nodes=$new_potential_nodes;
616 $count=count($potential_nodes);
617 $toggle_nodes=new PlekitToggle('my-slice-nodes-add',
618 count_english($potential_nodes,"more node") . " available",
619 array('visible'=>get_arg('show_nodes_add',false)));
620 $toggle_nodes->start();
622 if ( $potential_nodes ) {
625 $headers['peer']='string';
626 $headers['hostname']='string';
627 $short="-S-"; $long=Node::status_footnote(); $type='string';
628 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
629 $short=reservable_mark(); $long=reservable_legend(); $type='string';
630 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
631 // the extra tags, configured for the UI
632 $headers=array_merge($headers,$visibletags->headers());
633 $notes=array_merge($notes,$visibletags->notes());
634 $headers['+']="none";
636 $table=new PlekitTable('add_nodes',$headers,'1', $table_options);
637 $form=new PlekitForm(l_actions(),
638 array('slice_id'=>$slice['slice_id']));
641 if ($potential_nodes) foreach ($potential_nodes as $node) {
643 $peers->cell($table,$node['peer_id']);
644 $table->cell(l_node_obj($node));
645 list($label,$class) = Node::status_label_class_($node);
646 $table->cell ($label,array('class'=>$class));
647 $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
648 foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
649 $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));
653 $table->tfoot_start();
655 $table->cell($form->submit_html ("add-nodes-in-slice","Add selected"),
656 array('hfill'=>true,'align'=>'right'));
661 $toggle_nodes->end();
666 // very wide values get abbreviated
667 $tag_value_threshold=24;
668 //////////////////////////////////////////////////////////// Tags
669 //if ( $local_peer ) {
670 $tags=$api->GetSliceTags (array('slice_id'=>$slice_id));
671 if ($profiling) plc_debug_prof('8 slice tags',count($tags));
672 function get_tagname ($tag) { return $tag['tagname'];}
673 $tagnames = array_map ("get_tagname",$tags);
675 $toggle = new PlekitToggle ('slice-tags',count_english_warning($tags,'tag'),
676 array('bubble'=>'Inspect and set tags on tat slice',
677 'visible'=>get_arg('show_tags',false)));
684 "NodeGroup"=>"string");
685 if ($tags_privileges) $headers[plc_delete_icon()]="none";
687 $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
688 $table=new PlekitTable("slice_tags",$headers,'0',$table_options);
689 $form=new PlekitForm(l_actions(),
690 array('slice_id'=>$slice['slice_id']));
694 foreach ($tags as $tag) {
696 if ($tag['node_id']) {
697 $tag_nodes = $api->GetNodes(array('node_id'=>$tag['node_id']));
698 if ($profiling) plc_debug_prof('9 node for slice tag',count($tag_nodes));
700 $node = $tag_nodes[0];
701 $node_name = $node['hostname'];
704 $nodegroup_name="n/a";
705 if ($tag['nodegroup_id']) {
706 $nodegroups=$api->GetNodeGroups(array('nodegroup_id'=>$tag['nodegroup_id']));
707 if ($profiling) plc_debug_prof('10 nodegroup for slice tag',$nodegroup);
709 $nodegroup = $nodegroups[0];
710 $nodegroup_name = $nodegroup['groupname'];
714 $table->cell(l_tag_obj($tag));
715 // very wide values get abbreviated
716 $table->cell(truncate_and_popup($tag['value'],$tag_value_threshold));
717 $table->cell($node_name);
718 $table->cell($nodegroup_name);
719 if ($tags_privileges) $table->cell ($form->checkbox_html('slice_tag_ids[]',$tag['slice_tag_id']));
723 if ($tags_privileges) {
724 $table->tfoot_start();
726 $table->cell($form->submit_html ("delete-slice-tags","Remove selected"),
727 array('hfill'=>true,'align'=>'right'));
731 function tag_selector ($tag) {
732 return array("display"=>$tag['tagname'],"value"=>$tag['tag_type_id']);
734 $all_tags= $api->GetTagTypes( array ("category"=>"slice*","-SORT"=>"+tagname"), array("tagname","tag_type_id"));
735 if ($profiling) plc_debug_prof('11 tagtypes',count($all_tags));
736 $selector_tag=array_map("tag_selector",$all_tags);
738 function node_selector($node) {
739 return array("display"=>$node["hostname"],"value"=>$node['node_id']);
741 $selector_node=array_map("node_selector",$slice_nodes);
743 function nodegroup_selector($ng) {
744 return array("display"=>$ng["groupname"],"value"=>$ng['nodegroup_id']);
746 $all_nodegroups = $api->GetNodeGroups( array("groupname"=>"*"), array("groupname","nodegroup_id"));
747 if ($profiling) plc_debug_prof('13 nodegroups',count($all_nodegroups));
748 $selector_nodegroup=array_map("nodegroup_selector",$all_nodegroups);
750 $table->cell($form->select_html("tag_type_id",$selector_tag,array('label'=>"Choose Tag")));
751 $table->cell($form->text_html("value","",array('width'=>8)));
752 $table->cell($form->select_html("node_id",$selector_node,array('label'=>"All Nodes")));
753 $table->cell($form->select_html("nodegroup_id",$selector_nodegroup,array('label'=>"No Nodegroup")));
754 $table->cell($form->submit_html("add-slice-tag","Set Tag"),array('columns'=>2,'align'=>'left'));
764 //////////////////////// renew slice
766 if ( ! $renew_visible) renew_area ($slice,$site,false);
769 $peers->block_end($peer_id);
771 if ($profiling) plc_debug_prof_end();
774 include 'plc_footer.php';