4 require_once 'plc_login.php';
6 // Get session and API handles
7 require_once 'plc_session.php';
11 require_once 'plc_drupal.php';
12 include 'plc_header.php';
15 require_once 'plc_functions.php';
16 require_once 'plc_objects.php';
17 require_once 'plc_peers.php';
18 require_once 'plc_visibletags2.php';
19 require_once 'linetabs.php';
20 require_once 'table2.php';
21 require_once 'nifty.php';
22 require_once 'toggle.php';
23 require_once 'columns.php';
25 // keep css separate for now
26 drupal_set_html_head('
27 <link href="/planetlab/css/my_slice.css" rel="stylesheet" type="text/css" />
31 ini_set("memory_limit","64M");
34 // --------------------
35 // recognized URL arguments
36 $peerscope=$_GET['peerscope'];
37 $pattern=$_GET['pattern'];
38 $site_id=intval($_GET['site_id']);
39 $slice_id=intval($_GET['slice_id']);
40 $person_id=intval($_GET['person_id']);
45 $tabs []= tab_nodes();
46 if (count (plc_my_site_ids()) == 1) {
47 $tabs []= tab_nodes_mysite();
49 $tabs []= tab_nodes_all_mysite();
51 $tabs []= tab_nodes_local();
53 // --------------------
57 // performs sanity check and summarize the result in a single column
58 function node_status ($node) {
61 if ($node['node_type'] != 'regular' && $node['node_type'] != 'reservable' )
62 $messages []= $node['node_type'];
64 // checks on local nodes only
65 if ( ( ! $node['peer_id']) ) {
66 // has it got interfaces
67 if (count($node['interface_ids']) == 0)
68 $messages []= "No interface";
70 return plc_vertical_table($messages,'plc-warning');
74 $first_time_configuration = false;
77 $default_configuration = "ID:f|hostname:f|ST:f|AU:f|RES:f";
79 $default_configuration = "hostname:f|ST:f|AU:f|RES:f";
81 //$extra_default = "LCN|DN|R|L|OS|MS|SN";
82 $column_configuration = "";
83 $slice_column_configuration = "";
84 $show_configuration = "";
87 $PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id']));
88 //print_r($PersonTags);
89 foreach ($PersonTags as $ptag) {
90 if ($ptag['tagname'] == 'columnconf')
92 $column_configuration = $ptag['value'];
93 $conf_tag_id = $ptag['person_tag_id'];
95 if ($ptag['tagname'] == 'showconf')
97 $show_configuration = $ptag['value'];
98 $show_tag_id = $ptag['person_tag_id'];
102 //print("column configuration = ".$column_configuration);
104 $nodesconf_exists = false;
105 if ($column_configuration == "")
107 $first_time_configuration = true;
108 $column_configuration = "nodes;default";
109 $nodesconf_exists = true;
112 $slice_conf = explode(";",$column_configuration);
113 for ($i=0; $i<count($slice_conf); $i++ ) {
114 if ($slice_conf[$i] == "nodes")
117 $slice_column_configuration = $slice_conf[$i];
118 $nodesconf_exists = true;
124 $slice_column_configuration = $slice_conf[$i];
129 if ($nodesconf_exists == false)
130 $column_configuration = $column_configuration.";nodes;default";
131 //panos: need to define an "empty" configuration here (for the moment A column
132 //will be added by default the first time
135 if ($slice_column_configuration == "" || $slice_column_configuration == "default")
136 $full_configuration = $default_configuration;
139 $full_configuration = $default_configuration."|".$slice_column_configuration;
141 //print("full configuration = ".$full_configuration);
144 $node_fixed_columns=array('node_type','site_id','boot_state','last_contact','interface_ids','peer_id', 'slice_ids');
146 $fix_columns = array();
148 $fix_columns[]=array('tagname'=>'node_id', 'header'=>'ID', 'type'=>'string', 'title'=>'The ID the node');
149 $fix_columns[]=array('tagname'=>'hostname', 'header'=>'hostname', 'type'=>'string', 'title'=>'The name of the node');
150 $fix_columns[]=array('tagname'=>'peer_id', 'header'=>'AU', 'type'=>'string', 'title'=>'Authority');
151 $fix_columns[]=array('tagname'=>'run_level', 'header'=>'ST', 'type'=>'string', 'title'=>'Status');
152 $fix_columns[]=array('tagname'=>'node_type', 'header'=>'RES', 'type'=>'string', 'title'=>'Reservable');
155 $visibletags = new VisibleTags ($api, 'node');
156 $visibletags->columns();
157 $tag_columns = $visibletags->headers();
159 //columns that are not defined as extra myslice tags
160 $extra_columns = array();
162 $extra_columns[]=array('tagname'=>'sitename', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'fetched'=>true, 'source'=>'myplc');
163 $extra_columns[]=array('tagname'=>'domain', 'header'=>'DN', 'type'=>'string', 'title'=>'Toplevel domain name', 'fetched'=>true, 'source'=>'myplc');
164 $extra_columns[]=array('tagname'=>'ipaddress', 'header'=>'IP', 'type'=>'string', 'title'=>'IP Address', 'fetched'=>true, 'source'=>'myplc');
165 $extra_columns[]=array('tagname'=>'fcdistro', 'header'=>'OS', 'type'=>'string', 'title'=>'Operating system', 'fetched'=>false, 'source'=>'myplc');
166 $extra_columns[]=array('tagname'=>'date_created', 'header'=>'DA', 'source'=>'myplc', 'type'=>'date', 'title'=>'Date added', 'fetched'=>false);
167 $extra_columns[]=array('tagname'=>'arch', 'header'=>'A', 'source'=>'myplc', 'type'=>'string', 'title'=>'Architecture', 'fetched'=>false);
168 if (plc_is_admin()) {
169 $extra_columns[]=array('tagname'=>'deployment', 'header'=>'DL', 'source'=>'myplc', 'type'=>'string', 'title'=>'Deployment', 'fetched'=>false);
173 //NOTE: Uncomment these lines if CoMon provides information for your nodes
175 if (MYSLICE_COMON_AVAILABLE)
177 $extra_columns[]=array('tagname'=>'bwlimit', 'header'=>'BW', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Bandwidth limit', 'fetched'=>false);
178 $extra_columns[]=array('tagname'=>'numcores', 'header'=>'CC', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Number of CPU Cores', 'fetched'=>false);
179 $extra_columns[]=array('tagname'=>'cpuspeed', 'header'=>'CR', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'CPU clock rate', 'fetched'=>false);
180 $extra_columns[]=array('tagname'=>'disksize', 'header'=>'DS', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Disk size', 'fetched'=>false);
181 $extra_columns[]=array('tagname'=>'gbfree', 'header'=>'DF', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Currently available disk space', 'fetched'=>false);
182 $extra_columns[]=array('tagname'=>'memsize', 'header'=>'MS', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Memory size', 'fetched'=>false);
183 $extra_columns[]=array('tagname'=>'numslices', 'header'=>'SM', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Number of slices in memory', 'fetched'=>false);
184 $extra_columns[]=array('tagname'=>'uptime', 'header'=>'UT', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Continuous uptime until now', 'fetched'=>false);
189 if (MYSLICE_TOPHAT_AVAILABLE)
191 $extra_columns[]=array('tagname'=>'asn', 'header'=>'AS', 'source'=>'tophat', 'type'=>'string', 'title'=>'AS Number', 'fetched'=>false);
192 $extra_columns[]=array('tagname'=>'city', 'header'=>'LCY', 'source'=>'tophat', 'type'=>'string', 'title'=>'City', 'fetched'=>false);
193 $extra_columns[]=array('tagname'=>'region', 'header'=>'LRN', 'source'=>'tophat', 'type'=>'string', 'title'=>'Region', 'fetched'=>false);
194 $extra_columns[]=array('tagname'=>'country', 'header'=>'LCN', 'source'=>'tophat', 'type'=>'string', 'title'=>'Country', 'fetched'=>false);
195 $extra_columns[]=array('tagname'=>'continent', 'header'=>'LCT', 'source'=>'tophat', 'type'=>'string', 'title'=>'Continent', 'fetched'=>false);
196 //$extra_columns[]=array('tagname'=>'hopcount', 'header'=>'HC', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Hop count from reference node', 'fetched'=>false);
197 ////$extra_columns[]=array('tagname'=>'rtt', 'header'=>'RTT', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Round trip time from reference node', 'fetched'=>false);
198 ////$extra_columns[]=array('tagname'=>'agents', 'header'=>'MA', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Co-located measurement agents', 'fetched'=>true);
199 ////$extra_columns[]=array('tagname'=>'agents_sonoma', 'header'=>'MAS', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Co-located SONoMA agents', 'fetched'=>true);
200 ////$extra_columns[]=array('tagname'=>'agents_etomic', 'header'=>'MAE', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Co-located ETOMIC agents', 'fetched'=>true);
201 ////$extra_columns[]=array('tagname'=>'agents_tdmi', 'header'=>'MAT', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Co-located TDMI agents', 'fetched'=>true);
202 ////$extra_columns[]=array('tagname'=>'agents_dimes', 'header'=>'MAD', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Co-located DIMES agents', 'fetched'=>true);
206 $ConfigureColumns =new PlekitColumns($full_configuration, $fix_columns, $tag_columns, $extra_columns);
208 $visiblecolumns = $ConfigureColumns->node_tags();
210 $node_columns=array_merge($node_fixed_columns,$visiblecolumns);
212 //$visibletags = new VisibleTags ($api, 'node');
213 //$visiblecolumns = $visibletags->column_names();
215 //print_r($visiblecolumns);
216 //$node_columns=array_merge($node_fixed_columns,$visiblecolumns);
219 // server-side filtering - set pattern in $_GET for filtering on hostname
221 $node_filter['hostname']=$pattern;
222 $title .= " matching " . $pattern;
224 $node_filter['hostname']="*";
227 // server-side selection on peerscope
228 $peerscope=new PeerScope($api,$_GET['peerscope']);
229 $node_filter=array_merge($node_filter,$peerscope->filter());
230 $title .= ' - ' . $peerscope->label();
233 $sites=$api->GetSites(array($site_id));
236 $login_base=$site['login_base'];
237 $title .= t_site($site);
238 $tabs []= tab_site($site);
239 $node_filter['site_id']=array($site_id);
243 $slices=$api->GetSlices(array($slice_id),array('node_ids','name'));
245 $title .= t_slice($slice);
246 $tabs []= tab_slice($slice);
247 $node_filter['node_id'] = $slice['node_ids'];
250 // person_id is set : this is mostly oriented towards people managing several sites
252 // avoid doing a useless call to GetPersons if the person_id is already known though $plc,
253 // as this is mostly done for the 'all my sites nodes' link
254 if ($person_id == plc_my_person_id()) {
255 $person=plc_my_person();
256 $site_ids = plc_my_site_ids();
258 // fetch the person's site_ids
259 $persons = $api->GetPersons(array('person_id'=>$person_id),array('person_id','email','site_ids'));
261 $site_ids=$person['site_ids'];
263 $title .= t_person($person);
264 $node_filter['site_id']=$site_ids;
268 //print("getting nodes ".$node_columns);
269 //print_r($node_columns);
270 $nodes=$api->GetNodes($node_filter,$node_columns);
272 //print("<p> GOT NODES </p>");
275 $ConfigureColumns->fetch_live_data($nodes);
277 $show_columns_message = TRUE;
278 $show_conf = explode(";",$show_configuration);
279 foreach ($show_conf as $ss) {
281 $show_columns_message = FALSE;
286 // build site_ids - interface_ids
288 $interface_ids=array();
289 if ($nodes) foreach ($nodes as $node) {
290 $site_ids []= $node['site_id'];
291 $interface_ids = array_merge ($interface_ids,$node['interface_ids']);
294 // fetch related interfaces
295 $interface_columns=array('ip','node_id','interface_id');
296 $interface_filter=array('is_primary'=>TRUE,'interface_id'=>$interface_ids);
297 $interfaces=$api->GetInterfaces($interface_filter,$interface_columns);
299 $interface_hash=array();
300 foreach ($interfaces as $interface) $interface_hash[$interface['node_id']]=$interface;
302 // fetch related sites
303 $site_columns=array('site_id','login_base');
304 $site_filter=array('site_id'=>$site_ids);
305 $sites=$api->GetSites($site_filter,$site_columns);
308 foreach ($sites as $site) $site_hash[$site['site_id']]=$site;
310 // --------------------
311 drupal_set_title($title);
313 plekit_linetabs($tabs);
316 drupal_set_message ('No node found');
320 $nifty=new PlekitNifty ('','objects-list','big');
322 $headers = array (); $offset=0;
324 $notes [] = "For information about the different columns please see the <b>node table layout</b> tab above or <b>mouse over</b> the column headers";
329 if (plc_is_admin()) {
330 $short="I"; $long="node_id"; $type='int';
331 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
334 $short="P"; $long="Peer"; $type='string';
335 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
336 $short="D"; $long="toplevel domain name"; $type='string';
337 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
338 $headers["Site"]="string";
339 $headers["Hostname"]="string";
340 $short="IP"; $long="IP Address"; $type='sortIPAddress';
341 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
342 $short="ST"; $long=Node::status_footnote(); $type='string';
343 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
344 $short="SL"; $long="Number of slivers"; $type='int';
345 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
347 $headers=array_merge($headers,$visibletags->headers());
348 $notes=array_merge($notes,$visibletags->notes());
349 $short="?"; $long="extra status info"; $type='string';
350 $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
353 $info_header = array();
354 $short="?"; $long="extra status info"; $type='string';
355 $info_header[$short]=array('type'=>$type,'title'=>$long, 'label'=>'?', 'header'=>'?', 'visible'=>true);
356 //$notes []= "$short = $long";
357 //$info_header["?"] = "none";
358 $headers = array_merge($ConfigureColumns->get_headers(),$info_header);
360 if ($first_time_configuration)
361 $column_conf_visible = '1';
363 $column_conf_visible = '0';
366 This tab allows you to customize the columns in the node tables,
367 below. Information on the nodes comes from a variety of monitoring
368 sources. If you, as either a user or a provider of monitoring data,
369 would like to see additional columns made available, please send us
370 your request in mail to <a
371 href="mailto:support@myslice.info">support@myslice.info</a>. You can
372 find more information about the MySlice project at <a
373 href="http://trac.myslice.info">http://trac.myslice.info</a>.
375 $toggle_nodes=new PlekitToggle('nodes-layout',
377 array('visible'=>$column_conf_visible,
378 'info-text'=>$layout_help,
379 'info-visible'=>$show_columns_message));
380 $toggle_nodes->start();
381 print("<div id='debug'></div>");
382 print("<input type='hidden' id='slice_id' value='nodes' />");
383 print("<input type='hidden' id='person_id' value='".$plc->person['person_id']."' />");
384 print("<input type='hidden' id='conf_tag_id' value='".$conf_tag_id."' />");
385 print("<input type='hidden' id='show_tag_id' value='".$show_tag_id."' />");
386 print("<input type='hidden' id='show_configuration' value='".$show_configuration."' />");
387 print("<input type='hidden' id='column_configuration' value='".$slice_column_configuration."' />");
388 print("<br><input type='hidden' size=80 id='full_column_configuration' value='".$column_configuration."' />");
389 print("<input type='hidden' id='defaultConf' value='".$default_configuration."'></input>");
393 $ConfigureColumns->configuration_panel_html(true);
394 $ConfigureColumns->javascript_init();
395 $toggle_nodes->end();
397 $table_options = array('notes'=>$notes,
400 'configurable'=>true);
402 # initial sort on hostnames
403 $table=new PlekitTable ("nodes",$headers,3+$offset, $table_options);
406 $peers = new Peers ($api);
408 foreach ($nodes as $node) {
409 //$node_obj = new Node ($node);
411 $hostname=$node['hostname'];
412 $node_id=$node['node_id'];
413 $site_id=$node['site_id'];
414 $site=$site_hash[$site_id];
415 $login_base = $site['login_base'];
416 $ip=$interface_hash[$node['node_id']]['ip'];
417 $interface_id=$interface_hash[$node['node_id']]['interface_id'];
418 $peer_id=$node['peer_id'];
421 $table->cell($node['node_id'], array('display'=>'none'));
422 if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id));
423 $table->cell (l_node_t($node_id,$hostname));
424 $peers->cell ($table,$peer_id);
426 //prefetch some columns
427 $node['domain'] = topdomain($hostname);
428 $node['sitename'] = l_site_t($site_id,$login_base);
430 $node['ipaddress'] = l_interface_t($interface_id,$ip);
432 $node['ipaddress'] = "n/a";
434 list($label,$class) = Node::status_label_class_($node);
435 $table->cell ($label,array('class'=>$class));
436 $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
437 //$table->cell (count($node['slice_ids']));
438 //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
439 $ConfigureColumns->cells($table, $node);
440 $table->cell (node_status($node));
449 //plekit_linetabs ($tabs,"bottom");
452 include 'plc_footer.php';