git://git.onelab.eu
/
util-vserver.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a83dcc9
)
- merge changes from HEAD
author
Mark Huang
<mlhuang@cs.princeton.edu>
Fri, 15 Dec 2006 20:39:53 +0000
(20:39 +0000)
committer
Mark Huang
<mlhuang@cs.princeton.edu>
Fri, 15 Dec 2006 20:39:53 +0000
(20:39 +0000)
python/bwlimit.py
patch
|
blob
|
history
diff --git
a/python/bwlimit.py
b/python/bwlimit.py
index
cbb3e57
..
1942bb5
100644
(file)
--- a/
python/bwlimit.py
+++ b/
python/bwlimit.py
@@
-46,7
+46,7
@@
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
-# $Id: bwlimit.py,v 1.1
2 2006/04/24 20:04:13 mlhuang
Exp $
+# $Id: bwlimit.py,v 1.1
4 2006/12/13 21:48:14 faiyaza
Exp $
#
import sys, os, re, getopt
#
import sys, os, re, getopt
@@
-303,14
+303,17
@@
def tc(cmd):
return run(TC + " " + cmd)
return run(TC + " " + cmd)
-def init(dev
, bwcap
):
+def init(dev
= dev, bwcap = bwmax
):
"""
(Re)initialize the bandwidth limits on this node
"""
"""
(Re)initialize the bandwidth limits on this node
"""
- #
l
oad the module used to manage exempt classes
+ #
L
oad the module used to manage exempt classes
run("/sbin/modprobe ip_set_iphash")
run("/sbin/modprobe ip_set_iphash")
+ # Save current settings
+ paramslist = get(None, dev)
+
# Delete root qdisc 1: if it exists. This will also automatically
# delete any child classes.
for line in tc("qdisc show dev %s" % dev):
# Delete root qdisc 1: if it exists. This will also automatically
# delete any child classes.
for line in tc("qdisc show dev %s" % dev):
@@
-352,6
+355,14
@@
def init(dev, bwcap):
# up here.
on(default_xid, dev, share = default_share)
# up here.
on(default_xid, dev, share = default_share)
+ # Restore old settings
+ for (xid, share,
+ minrate, maxrate,
+ minexemptrate, maxexemptrate,
+ bytes, exemptbytes) in paramslist:
+ if xid not in (root_xid, default_xid):
+ on(xid, dev, share, minrate, maxrate, minexemptrate, maxexemptrate)
+
def get(xid = None, dev = dev):
"""
def get(xid = None, dev = dev):
"""
@@
-497,8
+508,12
@@
def on(xid, dev = dev, share = None, minrate = None, maxrate = None, minexemptra
maxexemptrate = get_tc_rate(maxexemptrate)
# Sanity checks
maxexemptrate = get_tc_rate(maxexemptrate)
# Sanity checks
+ if maxrate < bwmin:
+ maxrate = bwmin
if maxrate > bwcap:
maxrate = bwcap
if maxrate > bwcap:
maxrate = bwcap
+ if minrate < bwmin:
+ minrate = bwmin
if minrate > maxrate:
minrate = maxrate
if maxexemptrate > bwmax:
if minrate > maxrate:
minrate = maxrate
if maxexemptrate > bwmax: