6 require_once 'plc_login.php';
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api, $adm;
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
17 require_once 'plc_functions.php';
18 require_once 'plc_sorts.php';
21 $_person= $plc->person;
22 $_roles= $_person['role_ids'];
24 $header_tablesort_js='
25 <script type="text/javascript" src="/planetlab/tablesort/tablesort.js"></script>
26 <script type="text/javascript" src="/planetlab/tablesort/customsort.js"></script>
27 <script type="text/javascript" src="/planetlab/tablesort/paginate.js"></script>
28 <script type="text/javascript" src="/planetlab/js/plc_paginate.js"></script>
29 <script type="text/javascript" src="/planetlab/js/plc_filter.js"></script>
32 $header_tablesort_css='
33 <link href="/planetlab/css/plc_style.css" rel="stylesheet" type="text/css" />
34 <link href="/planetlab/css/plc_table.css" rel="stylesheet" type="text/css" />
35 <link href="/planetlab/css/plc_paginate.css" rel="stylesheet" type="text/css" />
38 drupal_set_html_head($header_tablesort_js);
39 drupal_set_html_head($header_tablesort_css);
41 // --------------------
42 $nodepattern=$_GET['nodepattern'];
43 $peerscope=$_GET['peerscope'];
48 <!------------------------------------------------------------>
53 // fetch nodes - use nodepattern for server-side filtering
54 $node_columns=array('hostname','site_id','node_id','boot_state','interface_ids','peer_id');
56 $node_filter['hostname']=$nodepattern;
58 $node_filter=array('hostname'=>"*");
61 // server-side selection on peerscope
62 list ( $peer_filter, $peer_label) = plc_peer_info($api,$_GET['peerscope']);
63 $node_filter=array_merge($node_filter,$peer_filter);
67 $title .= " matching " . $nodepattern;
69 $title .= ' (' . $peer_label . ')';
70 drupal_set_title($title);
73 $nodes=$api->GetNodes($node_filter,$node_columns);
75 // build site_ids - interface_ids
77 $interface_ids=array();
78 foreach ($nodes as $node) {
79 $site_ids []= $node['site_id'];
80 $interface_ids = array_merge ($interface_ids,$node['interface_ids']);
83 // fetch related interfaces
84 $interface_columns=array('ip','node_id','interface_id');
85 $interface_filter=array('is_primary'=>TRUE,'interface_id'=>$interface_ids);
86 $interfaces=$api->GetInterfaces($interface_filter,$interface_columns);
88 $interface_hash=array();
89 foreach ($interfaces as $interface) {
90 $interface_hash[$interface['node_id']]=$interface;
93 // fetch related sites
94 $site_columns=array('site_id','login_base');
95 $site_filter=array('site_id'=>$site_ids);
96 $sites=$api->GetSites($site_filter,$site_columns);
99 foreach ($sites as $site) {
100 $site_hash[$site['site_id']]=$site;
104 $peer_columns=array('peer_id','shortname');
105 $peer_filter=array();
106 $peers = $api->GetPeers($peer_filter,$peer_columns);
109 foreach ($peers as $peer) {
110 $peer_hash[$peer['peer_id']]=$peer;
115 <!------------------------------------------------------------>
116 <!-- instantiate generic mechanisms for nodes -->
117 <script type"text/javascript">
118 function nodes_paginator (opts) {
119 plc_table_paginator (opts,"nodes");
121 function nodes_filter () {
122 plc_table_filter("nodes","search_text","nodes_and");
126 <!------------------------------------------------------------>
127 <table class='table_dialogs'> <tr>
128 <td class='table_flushleft'>
129 <form class='table_size'>
130 <input class='table_size_input' type='text' id='tablesize_text' value="<?php echo $tablesize; ?>"
131 onkeyup='plc_table_setsize("nodes","tablesize_text", "<?php echo $tablesize; ?>" );'
132 size=3 maxlength=3 />
133 <label class='table_size_label'> Items per page </label>
134 <img class='table_reset' src="/planetlab/icons/clear.png"
135 onmousedown='plc_table_size_reset("nodes","tablesize_text","999");'>
139 <td class='table_flushright'>
140 <form class='table_search'>
141 <label class='table_search_label'> Search </label>
142 <input class='table_search_input' type='text' id='search_text'
143 onkeyup='nodes_filter();'
144 size=40 maxlength=256 />
146 <input id='nodes_and' class='table_search_and'
147 type='checkbox' checked='checked' onchange='nodes_filter();' />
148 <img class='table_reset' src="/planetlab/icons/clear.png"
149 onmousedown='plc_table_filter_reset("nodes","search_text");'>
154 <!------------------------------------------------------------>
155 <!-- <div class="fdtablePaginaterWrap" id="nodes-fdtablePaginaterWrapTop"><p></p></div> -->
157 <!------------------------------------------------------------>
158 <table id="nodes" cellpadding="0" cellspacing="0" border="0"
159 class="plc_table sortable-onload-4 rowstyle-alt colstyle-alt no-arrow paginationcallback-nodes_paginator max-pages-15 paginate-<?php print $tablesize; ?>">
162 <th class="sortable plc_table">Peer</th>
163 <th class="sortable plc_table">Region</th>
164 <th class="sortable plc_table">Site</th>
165 <th class="sortable plc_table">State</th>
166 <th class="sortable plc_table">Hostname</th>
167 <th class="sortable-sortIPAddress plc_table">IP</th>
168 <th class="sortable plc_table">Load</th>
169 <th class="sortable plc_table">Avg Load</th>
176 $fake1=1; $fake2=3.14; $fake_i=0;
177 foreach ($nodes as $node) {
178 $hostname=$node['hostname'];
179 $node_id=$node['node_id'];
180 $site_id=$node['site_id'];
181 $site=$site_hash[$site_id];
182 $login_base = $site['login_base'];
183 $node_id=$node['node_id'];
184 $ip=$interface_hash[$node['node_id']]['ip'];
185 $interface_id=$interface_hash[$node['node_id']]['interface_id'];
186 if ( ! $node['peer_id'] ) {
189 $shortname=$peer_hash[$node['peer_id']]['shortname'];
191 printf ('<tr id="%s">',$hostname);
192 printf ('<td class="plc_table"> %s </td>',$shortname);
193 printf ('<td class="plc_table"> %s </td>',topdomain($hostname));
194 printf ('<td class="plc_table"> <a href="/db/sites/index.php?id=%s">%s</a></td>',$site_id,$login_base);
195 printf ('<td class="plc_table"> %s </td>',$node['boot_state']);
196 printf ('<td class="plc_table"> <a href="/db/nodes/index.php?id=%s">%s</a></td>',$node_id,$hostname);
197 printf ('<td class="plc_table"> <a href="/db/nodes/interfaces.php?id=%s">%s</a></td>', $interface_id,$ip);
198 printf ('<td class="plc_table"> %s </td>', $fake1);
199 printf ('<td class="plc_table"> %s </td>', $fake2);
202 if ($fake_i % 5 == 0) $fake1 += 3;
203 if ($fake_i % 3 == 0) $fake2 +=5; else $fake2 -= $fake_i;
213 <!-- <div class="fdtablePaginaterWrap" id="nodes-fdtablePaginaterWrapBottom"><p></p></div> -->
215 <p class='plc_filter_note'>
216 Notes: Enter & or | in the search area to alternate between <bold>AND</bold> and <bold>OR</bold> search modes
218 Hold down the shift key to select multiple columns to sort