4 function pcu_link($pcu)
6 return "https://www.planet-lab.org/db/sites/pcu.php?id=" . $pcu['pcu_id'];
9 function pcu_name($pcu)
11 if ( $pcu['hostname'] != NULL and $pcu['hostname'] != "" ):
12 return $pcu['hostname'];
17 function pcu_entry($pcu)
19 if ( count($pcu['complete_entry']) > 0 ) {
20 return join("<BR>", $pcu['complete_entry']);
26 function format_ports($pcu)
29 #print print_r(is_array($pcu)) . "<BR>";
30 #print print_r(array_key_exists('portstatus', $pcu)) . "<BR>";
31 if ( is_array($pcu) && array_key_exists('portstatus', $pcu) )
33 $portstat = $pcu['portstatus'];
35 #foreach ( array('22', '23', '80', '443') $portstat as $port => $state)
36 foreach ( array('22', '23', '80', '443') as $port)
38 $state = $portstat[$port];
42 $color = "lightgreen";
54 $str .= "<span style='background-color: $color'>$port</span> ";
55 # . ": " . $state . "<br>";
58 # print print_r(is_array($pcu)) . "<BR>";
59 # print print_r(array_key_exists('portstatus', $pcu)) . "<BR>";
61 #print_r($pcu['portstatus']);
66 $str = "Closed/Filtered";
70 function DNS_to_color($dns)
87 function reboot_to_color($reboot)
92 return "darkseagreen";
100 case "Unsupported_PCU":
104 if ( strpos($reboot, "error") >= 0)
115 function get_pcuid($pcu) { return $pcu['pcu_id']; }
116 function get_dns($pcu) { return $pcu['dnsmatch']; }
117 function get_dryrun($pcu) { return $pcu['reboot']; }
118 function get_model($pcu) { return $pcu['model']; }
119 function get_category_link($category,$header)
121 return "<a href='printbadpcus.php?category=$category'>$header</a>";
124 include 'soltesz.php';
126 $findbad = $p->load("findbadpcus");
127 $findbadpcus = array_keys($findbad['nodes']);
131 foreach ( $findbadpcus as $pcu_id )
133 if ( is_array($findbad['nodes'][$pcu_id]) )
135 #if ( in_array('values', $findbad['nodes'][$pcu]) )
137 # echo $pcu . " true<BR>";
139 # echo $pcu . " false<br>";
141 if ( array_key_exists('values', $findbad['nodes'][$pcu_id]) )
143 $pculist[] = $findbad['nodes'][$pcu_id]['values'];
147 $total = count($pculist);
152 #$pcu_ids = array_map('get_pcuid', $pculist);
153 #array_multisort($pcu_ids, SORT_ASC, SORT_NUMERIC, $pculist);
155 #$dns_ids = array_map('get_dns', $pculist);
156 #array_multisort($dns_ids, SORT_ASC, SORT_STRING, $pculist);
158 #$dry_ids = array_map('get_dryrun', $pculist);
159 #array_multisort($dry_ids, SORT_ASC, SORT_STRING, $pculist);
160 if ( $_GET['category'] )
162 $category = $_GET['category'];
163 if ( $category == "node_ids" )
165 $newfunc = create_function('$pcu', 'return count($pcu[\'' . $category . '\']);');
167 $newfunc = create_function('$pcu', 'return $pcu[\'' . $category . '\'];');
169 if ( $newfunc != "" )
171 $fields = array_map($newfunc, $pculist);
172 array_multisort($fields, SORT_ASC, SORT_STRING, $pculist);
174 echo "ERROR create_function == null<BR>";
186 //array_multisort($protocols, SORT_ASC, SORT_STRING, $pculist);
189 <title>PLC PCU Info</title>
193 Total PCUs : <?= $total ?>
197 <th><?= get_category_link("pcu_id", "PCU ID") ?></th>
198 <th><?= get_category_link("hostname", "Hostname") ?></th>
199 <th><?= get_category_link("complete_entry", "Incomplete Fields") ?></th>
200 <th><?= get_category_link("dnsmatch", "DNS Status") ?></th>
201 <th><?= get_category_link("portstatus", "Port Status") ?></th>
202 <th><?= get_category_link("reboot", "Dry Run Results") ?></th>
203 <th><?= get_category_link("model", "Model") ?></th>
204 <th><?= get_category_link("node_ids", "Nodes") ?></th>
205 <?php if ( $auth ): ?>
212 <?php foreach ( $pculist as $pcu ): ?>
214 <td><?= $count ?></td>
215 <td id='id<?= $pcu['pcu_id'] ?>'><a href='<?= pcu_link($pcu) ?>'><?= $pcu['pcu_id'] ?></a></td>
216 <td><?= pcu_name($pcu) ?></td>
217 <td><?= pcu_entry($pcu) ?></td>
218 <td bgcolor='<?= DNS_to_color($pcu['dnsmatch']) ?>'><?= $pcu['dnsmatch'] ?></td>
219 <td><?= format_ports($pcu) ?></td>
220 <td bgcolor='<?= reboot_to_color($pcu['reboot']) ?>'><?= $pcu['reboot'] ?></td>
221 <td nowrap><?= $pcu['model'] ?></td>
222 <td><?= count( $pcu['node_ids'] ) ?></td>
223 <?php if ( $auth ): ?>
224 <td><?= ( $pcu['username'] ? $pcu['username'] : " " ) ?></td>
225 <td><?= $pcu['password'] ?></td>
226 <td><?= $pcu['notes'] ?></td>
229 <?php $count += 1; ?>