- net_*_rate are in kbps because of XML-RPC maxint limitations
authorMark Huang <mlhuang@cs.princeton.edu>
Tue, 6 Feb 2007 22:28:18 +0000 (22:28 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Tue, 6 Feb 2007 22:28:18 +0000 (22:28 +0000)
- get primary bwlimit from GetSlivers() call, fix up default allocation
  appropriately

sm.py

diff --git a/sm.py b/sm.py
index cdb42ee..956a11e 100644 (file)
--- a/sm.py
+++ b/sm.py
@@ -23,12 +23,12 @@ DEFAULT_ALLOCATION = {
     'cpu_min': 0, # ms/s
     'cpu_share': 32, # proportional share
     # bandwidth parameters
-    'net_min_rate': bwmin, # bps
-    'net_max_rate': bwmax, # bps
+    'net_min_rate': bwmin / 1000, # kbps
+    'net_max_rate': bwmax / 1000, # kbps
     'net_share': 1, # proportional share
     # bandwidth parameters over routes exempt from node bandwidth limits
-    'net_i2_min_rate': bwmin, # bps
-    'net_i2_max_rate': bwmax, # bps
+    'net_i2_min_rate': bwmin / 1000, # kbps
+    'net_i2_max_rate': bwmax / 1000, # kbps
     'net_i2_share': 1, # proportional share
     'disk_max': 5000000 # bytes
     }
@@ -51,6 +51,12 @@ def GetSlivers(data, fullupdate=True):
     except: logger.log_exc()
 
     if data.has_key('node_id') and data['node_id'] != node_id: return
+
+    if data.has_key('networks'):
+        for network in data['networks']:
+            if network['is_primary'] and network['bwlimit'] is not None:
+                DEFAULT_ALLOCATION['net_max_rate'] = network['bwlimit'] / 1000
+
     for sliver in data['slivers']:
         rec = sliver.copy()
         rec.setdefault('timestamp', data['timestamp'])