# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
# Copyright (C) 2004-2006 The Trustees of Princeton University
#
-# $Id: bwmon.py,v 1.1.2.9 2007/04/26 19:09:05 faiyaza Exp $
+# $Id: bwmon.py,v 1.21 2007/06/16 14:30:17 faiyaza Exp $
#
import os
def gethtbs(root_xid, default_xid):
"""
Return dict {xid: {*rates}} of running htbs as reported by tc that have names.
- Turn off HTBs without names.
+ Turn off HTBs without names.
"""
livehtbs = {}
for params in bwlimit.get():
name = bwlimit.get_slice(xid)
-
-
if (name is None) \
- and (xid != root_xid) \
- and (xid != default_xid):
+ and (xid != root_xid) \
+ and (xid != default_xid):
# Orphaned (not associated with a slice) class
name = "%d?" % xid
logger.log("bwmon: Found orphaned HTB %s. Removing." %name)
(version, slices) = pickle.load(f)
f.close()
# Check version of data file
- if version != "$Id: bwmon.py,v 1.1.2.9 2007/04/26 19:09:05 faiyaza Exp $":
+ if version != "$Id: bwmon.py,v 1.21 2007/06/16 14:30:17 faiyaza Exp $":
logger.log("bwmon: Not using old version '%s' data file %s" % (version, datafile))
raise Exception
except Exception:
- version = "$Id: bwmon.py,v 1.1.2.9 2007/04/26 19:09:05 faiyaza Exp $"
+ version = "$Id: bwmon.py,v 1.21 2007/06/16 14:30:17 faiyaza Exp $"
slices = {}
# Get/set special slice IDs
newslicesxids = Set(live.keys()) - Set(livehtbs.keys())
logger.log("bwmon: Found %s new slices" % newslicesxids.__len__())
- # Incase we rebooted and need to bring up the htbs that are in the db but
- # not known to tc.
- #nohtbxids = Set(slices.keys()) - Set(livehtbs.keys())
- #logger.log("bwmon: Found %s slices that should have htbs but dont." % nohtbxids.__len__())
- #newslicesxids.update(nohtbxids)
+ # Incase we rebooted and need to keep track of already running htbs
+ norecxids = Set(livehtbs.keys()) - Set(slices.keys())
+ logger.log("bwmon: Found %s slices that have htbs but not in dat." % norecxids.__len__())
+ # Reset tc counts.
+ for norecxid in norecxids:
+ slices[norecxid] = Slice(norecxid, live[norecxid]['name'], live[norecxid]['_rspec'])
+ slices[norecxid].reset(livehtbs[norecxid]['maxrate'],
+ livehtbs[norecxid]['maxexemptrate'],
+ livehtbs[norecxid]['usedbytes'],
+ livehtbs[norecxid]['usedi2bytes'],
+ live[norecxid]['_rspec'])
# Setup new slices
for newslice in newslicesxids: