X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PlanetLabConf%2Fbwlimit.php;h=a35bdebb5fc005b6f496ecfc965b3795da9cb5cc;hb=b815095fec39d567d31901c610de18c611dd5db5;hp=3e3cbc968d49a59a38aff7645ec046cece1b8891;hpb=37a93603272c00a8b2389bbec0c1860382eb8569;p=nodeconfig.git diff --git a/PlanetLabConf/bwlimit.php b/PlanetLabConf/bwlimit.php index 3e3cbc9..a35bdeb 100755 --- a/PlanetLabConf/bwlimit.php +++ b/PlanetLabConf/bwlimit.php @@ -13,10 +13,21 @@ require_once 'plc_api.php'; global $adm; // Look up the node -$nodenetworks = $adm->GetNodeNetworks(array('ip' => $_SERVER['REMOTE_ADDR'])); -if (!empty($nodenetworks)) { - if ($nodenetworks[0]['bwlimit'] !== NULL) { - $rate = $nodenetworks[0]['bwlimit']; +// backwards compatibility with the old 4.2 API +global $__PLC_API_VERSION; +if ( ! method_exists ($adm,"GetInterfaces")) + $__PLC_API_VERSION = 4.2; +else + $__PLC_API_VERSION = 4.3; + +if ($__PLC_API_VERSION==4.2) + $interfaces = $adm->GetNodeNetworks(array('ip' => $_SERVER['REMOTE_ADDR'])); +else + $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR'])); + +if (!empty($interfaces)) { + if ($interfaces[0]['bwlimit'] !== NULL) { + $rate = $interfaces[0]['bwlimit']; if ($rate >= 1000000000 && ($rate % 1000000000) == 0) { printf("%.0fgbit", ($rate / 1000000000.)); } elseif ($rate >= 1000000 && ($rate % 1000000) == 0) { @@ -31,4 +42,4 @@ if (!empty($nodenetworks)) { } } -?> \ No newline at end of file +?>