850e864ad361ae7616f1218a3976c33981dcc4d5
[nodeconfig.git] / PlanetLabConf / bwlimit.php
1 <?php
2 //
3 // Deprecated. Node Manager manages the node bandwidth limit.
4 //
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2006 The Trustees of Princeton University
7 //
8 // $Id$
9 //
10
11 // Get admin API handle
12 require_once 'plc_api.php';
13 global $adm;
14
15 // Look up the node
16 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
17 if (!empty($interfaces)) {
18   if ($interfaces[0]['bwlimit'] !== NULL) {
19     $rate = $interfaces[0]['bwlimit'];
20     if ($rate >= 1000000000 && ($rate % 1000000000) == 0) {
21       printf("%.0fgbit", ($rate / 1000000000.));
22     } elseif ($rate >= 1000000 && ($rate % 1000000) == 0) {
23       printf("%.0fmbit", ($rate / 1000000.));
24     } elseif ($rate >= 1000) {
25       printf("%.0fkbit", ($rate / 1000.));
26     } else {
27       printf("%.0fbit", $rate);
28     }
29   } else {
30     print "-1";
31   }
32 }
33
34 ?>