c8851596a678b75bed5c848dfbbe7627a6d1e05f
[plewww.git] / planetlab / nodes / newindex.php
1 <?php
2
3 // $Id: index.php 1175 2008-02-07 16:20:15Z thierry $
4
5 // Require login
6 require_once 'plc_login.php';
7
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api, $adm;
11
12 // Print header
13 require_once 'plc_drupal.php';
14 drupal_set_title('New Nodes');
15 include 'plc_header.php';
16
17 // Common functions
18 require_once 'plc_functions.php';
19 require_once 'plc_sorts.php';
20
21 // find person roles
22 $_person= $plc->person;
23 $_roles= $_person['role_ids'];
24
25 $header_js='
26 <script type="text/javascript" src="/planetlab/tablesort/tablesort.js"></script>
27 <script type="text/javascript" src="/planetlab/tablesort/customsort.js"></script>
28 <script type="text/javascript" src="/planetlab/tablesort/paginate.js"></script>
29 <script type="text/javascript" src="/planetlab/tablesort/more.js"></script>
30 <body OnLoad="init();">
31 ';
32 $header_css='
33 <link href="/planetlab/css/demo.css" rel="stylesheet" type="text/css" />
34 <link href="/planetlab/css/more.css" rel="stylesheet" type="text/css" />
35 <!--[if IE]>
36 <style type="text/css">
37 ul.fdtablePaginater {display:inline-block;}
38 mul.fdtablePaginater {display:inline;}
39 ul.fdtablePaginater li {float:left;}
40 ul.fdtablePaginater {text-align:center;}
41 table { border-bottom:1px solid #C1DAD7; }
42 </style>
43 <![endif]-->
44 ';
45
46 $header_unused='
47 ';
48
49 drupal_set_html_head($header_js);
50 drupal_set_html_head($header_css);
51
52 $site_columns=array("site_id","login_base");
53 $site_filter=array("login_base"=>"*");
54 $sites=$api->GetSites($site_filter,$site_columns);
55
56 $site_hash=array();
57 foreach ($sites as $site) {
58     $site_hash[$site["site_id"]]=$site;
59 }
60
61 $node_columns=array("hostname","site_id","node_id","boot_state");
62 $node_filter=array("hostname"=>"*");
63 $nodes=$api->GetNodes($node_filter,$node_columns);
64
65 $interface_columns=array("ip","node_id");
66 $interface_filter=array("is_primary"=>TRUE);
67 $interfaces=$api->GetInterfaces($interface_filter,$interface_columns);
68
69 $interface_hash=array();
70 foreach ($interfaces as $interface) {
71     $interface_hash[$interface['node_id']]=$interface;
72 }
73
74 ?>
75
76 <table id="theTable" cellpadding="0" cellspacing="0" border="0" 
77 class="sortable-onload-2 rowstyle-alt colstyle-alt no-arrow paginate-50 max-pages-10">
78 <thead>
79 <tr>
80 <th align=top>Select </th>
81 <th class="sortable">State</th>
82 <th class="sortable">Hostname</th>
83 <th class="sortable">Site</th>
84 <th class="sortable">Region</th>
85 <th class="sortable-sortIPAddress">IP</th>
86 <th class="sortable">Load</th>
87 <th class="sortable">Avg Load</th>
88 </tr>
89 </thead>
90 <tbody>
91
92 <?php
93
94 foreach ($nodes as $node) {
95     $hostname=$node['hostname'];
96     $site=$site_hash[$node['site_id']];
97     $login_base = $site['login_base'];
98     $node_id=$node['node_id'];
99     $ip=$interface_hash[$node['node_id']]['ip'];
100     printf ('<tr id="%s">',$hostname);
101     printf ('<td> <input type="checkbox" id="%s"></td>',$hostname);
102     printf ('<td> %s </td>',$node['boot_state']);
103     printf ('<td> %s </td>',$hostname);
104     printf ('<td> %s </td>',$login_base);
105     printf ('<td> %s </td>',topdomain($hostname));
106     printf ('<td> %s </td>',$ip);
107     printf ('<td> 1.0 </td>');
108     printf ('<td> 10.0 </td>');
109     printf ( '</tr>');
110 }
111
112 ?>
113 </tbody>
114 <tfoot>
115 </tfoot>
116 </table>
117